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 fetchImageUrl = async(jid: string) => {
|
||||||
const response = await query({
|
const response = await query({
|
||||||
json: ['query', 'ProfilePicThumb', jid],
|
json: ['query', 'ProfilePicThumb', jid],
|
||||||
expect200: true,
|
expect200: false,
|
||||||
requiresPhoneConnection: false
|
requiresPhoneConnection: false
|
||||||
})
|
})
|
||||||
return response.eurl as string | undefined
|
return response.eurl as string | undefined
|
||||||
|
|||||||
@@ -222,8 +222,10 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
{ epoch: currentEpoch().toString(), type: 'relay' },
|
{ epoch: currentEpoch().toString(), type: 'relay' },
|
||||||
[ new BinaryNode('message', {}, message) ]
|
[ 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 mID = message.key.id
|
||||||
|
const finalState = isMsgToMe ? WAMessageStatus.READ : WAMessageStatus.SERVER_ACK
|
||||||
|
|
||||||
message.status = WAMessageStatus.PENDING
|
message.status = WAMessageStatus.PENDING
|
||||||
const promise = query({
|
const promise = query({
|
||||||
@@ -236,14 +238,14 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
if(waitForAck) {
|
if(waitForAck) {
|
||||||
await promise
|
await promise
|
||||||
message.status = WAMessageStatus.SERVER_ACK
|
message.status = finalState
|
||||||
} else {
|
} else {
|
||||||
const emitUpdate = (status: WAMessageStatus) => {
|
const emitUpdate = (status: WAMessageStatus) => {
|
||||||
message.status = status
|
message.status = status
|
||||||
ev.emit('messages.update', [ { key: message.key, status } ])
|
ev.emit('messages.update', [ { key: message.key, status } ])
|
||||||
}
|
}
|
||||||
promise
|
promise
|
||||||
.then(() => emitUpdate(WAMessageStatus.SERVER_ACK))
|
.then(() => emitUpdate(finalState))
|
||||||
.catch(() => emitUpdate(WAMessageStatus.ERROR))
|
.catch(() => emitUpdate(WAMessageStatus.ERROR))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export default(
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'last':
|
case 'last':
|
||||||
|
logger.info('recv last message on all chats')
|
||||||
for(const msg of newMessages) {
|
for(const msg of newMessages) {
|
||||||
const jid = msg.key.remoteJid!
|
const jid = msg.key.remoteJid!
|
||||||
const list = assertMessageList(jid)
|
const list = assertMessageList(jid)
|
||||||
@@ -185,6 +186,7 @@ export default(
|
|||||||
chats,
|
chats,
|
||||||
contacts,
|
contacts,
|
||||||
messages,
|
messages,
|
||||||
|
groupMetadata,
|
||||||
state,
|
state,
|
||||||
listen,
|
listen,
|
||||||
loadMessages: async(jid: string, count: number, cursor: WAMessageCursor, sock: Connection | undefined) => {
|
loadMessages: async(jid: string, count: number, cursor: WAMessageCursor, sock: Connection | undefined) => {
|
||||||
@@ -237,7 +239,7 @@ export default(
|
|||||||
if(!contact) {
|
if(!contact) {
|
||||||
return sock?.fetchImageUrl(jid)
|
return sock?.fetchImageUrl(jid)
|
||||||
}
|
}
|
||||||
if(!contact.imgUrl) {
|
if(typeof contact.imgUrl === 'undefined') {
|
||||||
contact.imgUrl = await sock?.fetchImageUrl(jid)
|
contact.imgUrl = await sock?.fetchImageUrl(jid)
|
||||||
}
|
}
|
||||||
return contact.imgUrl
|
return contact.imgUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user