mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: implement "treatCiphertextMessagesAsReal" flag
This commit is contained in:
@@ -124,6 +124,8 @@ type SocketConfig = {
|
||||
fetchAgent?: Agent
|
||||
/** should the QR be printed in the terminal */
|
||||
printQRInTerminal: boolean
|
||||
/** fires a conversationTimestamp & read count update on CIPHERTEXT messages */
|
||||
treatCiphertextMessagesAsReal: boolean
|
||||
/**
|
||||
* fetch a message from your store
|
||||
* implement this so that messages failed to send (solves the "this message can take a while" issue) can be retried
|
||||
|
||||
@@ -30,6 +30,7 @@ const BASE_CONNECTION_CONFIG: CommonSocketConfig<any> = {
|
||||
emitOwnEvents: true,
|
||||
defaultQueryTimeoutMs: 60_000,
|
||||
customUploadHosts: [],
|
||||
treatCiphertextMessagesAsReal: true
|
||||
}
|
||||
|
||||
export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
|
||||
|
||||
@@ -13,7 +13,7 @@ const STATUS_MAP = {
|
||||
} as { [_: string]: WAMessageStatus }
|
||||
|
||||
const makeMessagesSocket = (config: LegacySocketConfig) => {
|
||||
const { logger } = config
|
||||
const { logger, treatCiphertextMessagesAsReal } = config
|
||||
const sock = makeChatsSocket(config)
|
||||
const {
|
||||
ev,
|
||||
@@ -120,7 +120,13 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
|
||||
ev.emit('groups.update', [ { id: jid, ...update } ])
|
||||
}
|
||||
|
||||
if(message.message) {
|
||||
if(
|
||||
(
|
||||
!!message.message ||
|
||||
(message.messageStubType === WAMessageStubType.CIPHERTEXT && treatCiphertextMessagesAsReal)
|
||||
)
|
||||
&& !message.message!.protocolMessage
|
||||
) {
|
||||
chatUpdate.conversationTimestamp = +toNumber(message.messageTimestamp)
|
||||
// add to count if the message isn't from me & there exists a message
|
||||
if(!message.key.fromMe) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { makeChatsSocket } from './chats'
|
||||
import { extractGroupMetadata } from './groups'
|
||||
|
||||
export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const { logger } = config
|
||||
const { logger, treatCiphertextMessagesAsReal } = config
|
||||
const sock = makeChatsSocket(config)
|
||||
const {
|
||||
ev,
|
||||
@@ -548,7 +548,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
() => processMessage(msg, chat)
|
||||
)
|
||||
|
||||
if(!!msg.message && !msg.message!.protocolMessage) {
|
||||
if(
|
||||
(
|
||||
!!msg.message ||
|
||||
(msg.messageStubType === WAMessageStubType.CIPHERTEXT && treatCiphertextMessagesAsReal)
|
||||
)
|
||||
&& !msg.message!.protocolMessage
|
||||
) {
|
||||
chat.conversationTimestamp = toNumber(msg.messageTimestamp)
|
||||
if(!msg.key.fromMe) {
|
||||
chat.unreadCount = (chat.unreadCount || 0) + 1
|
||||
|
||||
@@ -35,6 +35,8 @@ export type CommonSocketConfig<T> = {
|
||||
emitOwnEvents: boolean
|
||||
/** provide a cache to store media, so does not have to be re-uploaded */
|
||||
mediaCache?: NodeCache
|
||||
|
||||
/** custom upload hosts to upload media to */
|
||||
customUploadHosts: MediaConnInfo['hosts']
|
||||
/** fires a conversationTimestamp & read count update on CIPHERTEXT messages */
|
||||
treatCiphertextMessagesAsReal: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user