bug fixes

This commit is contained in:
Adhiraj Singh
2021-07-17 23:21:56 +05:30
parent 9ea23a2d12
commit bd86f95a9c
2 changed files with 16 additions and 12 deletions

View File

@@ -79,6 +79,13 @@ const makeChatsSocket = (config: SocketConfig) => {
)
ev.emit('messages.update', updates)
break
case 'mute':
if(attributes.mute === '0') {
ev.emit('chats.update', [{ jid, mute: null }])
} else {
ev.emit('chats.update', [{ jid, mute: attributes.mute }])
}
break
default:
logger.warn({ node }, `received unrecognized chat update`)
break
@@ -251,7 +258,7 @@ const makeChatsSocket = (config: SocketConfig) => {
...sock,
sendChatsQuery,
fetchImageUrl,
chatRead: async(jid: string, count: number, fromMessage: WAMessageKey) => {
chatRead: async(fromMessage: WAMessageKey, count: number) => {
if(count < 0) {
count = -2
}
@@ -260,7 +267,7 @@ const makeChatsSocket = (config: SocketConfig) => {
new BinaryNode(
'read',
{
jid,
jid: fromMessage.remoteJid,
count: count.toString(),
index: fromMessage.id,
owner: fromMessage.fromMe ? 'true' : 'false'
@@ -269,7 +276,7 @@ const makeChatsSocket = (config: SocketConfig) => {
],
[ WAMetric.read, WAFlag.ignore ]
)
ev.emit ('chats.update', [{ jid, count: count < 0 ? -1 : 0 }])
ev.emit ('chats.update', [{ jid: fromMessage.remoteJid, count: count < 0 ? -1 : 0 }])
},
/**
* Modify a given chat (archive, pin etc.)

View File

@@ -256,7 +256,7 @@ export const makeSocket = ({
if(expect200 && Math.floor(responseStatusCode/100) !== 2) {
const message = STATUS_CODES[responseStatusCode] || 'unknown'
throw new Boom(
`Unexpected status in '${Object.values(json)[0] || 'query'}': ${message}(${responseStatusCode})`,
`Unexpected status in '${Array.isArray(json) ? json[0] : (json?.header || 'query')}': ${message}(${responseStatusCode})`,
{ data: { query: json, message }, statusCode: response.status }
)
}
@@ -345,19 +345,16 @@ export const makeSocket = ({
waitForMessage,
query,
/** Generic function for action, set queries */
setQuery: async(nodes: BinaryNode[], binaryTag: WATag = [WAMetric.group, WAFlag.ignore], tag?: string) => (
query({
json: new BinaryNode(
'action',
{ epoch: epoch.toString(), type: 'set' },
nodes
),
setQuery: async(nodes: BinaryNode[], binaryTag: WATag = [WAMetric.group, WAFlag.ignore], tag?: string) => {
const json = new BinaryNode('action', { epoch: epoch.toString(), type: 'set' }, nodes)
return query({
json,
binaryTag,
tag,
expect200: true,
requiresPhoneConnection: true
}) as Promise<{ status: number }>
),
},
currentEpoch: () => epoch,
end
}