diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 16cc761..dc800e0 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -7,16 +7,14 @@ import { KEY_BUNDLE_TYPE } from "../Defaults" import { makeChatsSocket } from "./chats" import { extractGroupMetadata } from "./groups" -const getStatusFromReceiptType = (type: string | undefined) => { - if(type === 'read' || type === 'read-self') { - return proto.WebMessageInfo.WebMessageInfoStatus.READ - } - if(typeof type === 'undefined') { - return proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK - } - return undefined +const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = { + 'played': proto.WebMessageInfo.WebMessageInfoStatus.PLAYED, + 'read': proto.WebMessageInfo.WebMessageInfoStatus.READ, + 'read-self': proto.WebMessageInfo.WebMessageInfoStatus.READ } +const getStatusFromReceiptType = (type: string | undefined) => STATUS_MAP[type] + export const makeMessagesRecvSocket = (config: SocketConfig) => { const { logger } = config const sock = makeChatsSocket(config) @@ -606,4 +604,4 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { }) return { ...sock, processMessage, sendMessageAck } -} \ No newline at end of file +}