mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
minor updates
This commit is contained in:
@@ -30,7 +30,7 @@ const makeChatsSocket = (config: SocketConfig) => {
|
||||
const fetchImageUrl = async(jid: string) => {
|
||||
const response = await query({
|
||||
json: ['query', 'ProfilePicThumb', jid],
|
||||
expect200: true,
|
||||
expect200: false,
|
||||
requiresPhoneConnection: false
|
||||
})
|
||||
return response.eurl as string | undefined
|
||||
|
||||
@@ -222,8 +222,10 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
||||
{ epoch: currentEpoch().toString(), type: 'relay' },
|
||||
[ new BinaryNode('message', {}, message) ]
|
||||
)
|
||||
const flag = message.key.remoteJid === getState().user?.jid ? WAFlag.acknowledge : WAFlag.ignore // acknowledge when sending message to oneself
|
||||
const isMsgToMe = message.key.remoteJid === getState().user?.jid
|
||||
const flag = isMsgToMe ? WAFlag.acknowledge : WAFlag.ignore // acknowledge when sending message to oneself
|
||||
const mID = message.key.id
|
||||
const finalState = isMsgToMe ? WAMessageStatus.READ : WAMessageStatus.SERVER_ACK
|
||||
|
||||
message.status = WAMessageStatus.PENDING
|
||||
const promise = query({
|
||||
@@ -236,14 +238,14 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
||||
|
||||
if(waitForAck) {
|
||||
await promise
|
||||
message.status = WAMessageStatus.SERVER_ACK
|
||||
message.status = finalState
|
||||
} else {
|
||||
const emitUpdate = (status: WAMessageStatus) => {
|
||||
message.status = status
|
||||
ev.emit('messages.update', [ { key: message.key, status } ])
|
||||
}
|
||||
promise
|
||||
.then(() => emitUpdate(WAMessageStatus.SERVER_ACK))
|
||||
.then(() => emitUpdate(finalState))
|
||||
.catch(() => emitUpdate(WAMessageStatus.ERROR))
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export default(
|
||||
}
|
||||
break
|
||||
case 'last':
|
||||
logger.info('recv last message on all chats')
|
||||
for(const msg of newMessages) {
|
||||
const jid = msg.key.remoteJid!
|
||||
const list = assertMessageList(jid)
|
||||
@@ -185,6 +186,7 @@ export default(
|
||||
chats,
|
||||
contacts,
|
||||
messages,
|
||||
groupMetadata,
|
||||
state,
|
||||
listen,
|
||||
loadMessages: async(jid: string, count: number, cursor: WAMessageCursor, sock: Connection | undefined) => {
|
||||
@@ -237,7 +239,7 @@ export default(
|
||||
if(!contact) {
|
||||
return sock?.fetchImageUrl(jid)
|
||||
}
|
||||
if(!contact.imgUrl) {
|
||||
if(typeof contact.imgUrl === 'undefined') {
|
||||
contact.imgUrl = await sock?.fetchImageUrl(jid)
|
||||
}
|
||||
return contact.imgUrl
|
||||
|
||||
Reference in New Issue
Block a user