refactor: move processMessage out of socket

This commit is contained in:
Adhiraj Singh
2022-03-29 14:04:14 +05:30
parent 89e35ec18a
commit ab9b232838
3 changed files with 221 additions and 176 deletions

View File

@@ -253,4 +253,19 @@ export const fetchLatestBaileysVersion = async() => {
error
}
}
}
}
const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = {
'played': proto.WebMessageInfo.WebMessageInfoStatus.PLAYED,
'read': proto.WebMessageInfo.WebMessageInfoStatus.READ,
'read-self': proto.WebMessageInfo.WebMessageInfoStatus.READ
}
export const getStatusFromReceiptType = (type: string | undefined) => {
const status = STATUS_MAP[type]
if(typeof type === 'undefined') {
return proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK
}
return status
}