feat: implement message retry handling

so if a message fails to decrypt on the other user's end -- it can be retried
This commit is contained in:
Adhiraj Singh
2021-12-04 13:47:24 +05:30
parent 903871d180
commit 78fd72c8e5
6 changed files with 91 additions and 33 deletions

View File

@@ -117,6 +117,8 @@ export type AnyMessageContent = AnyRegularMessageContent | {
export type MessageRelayOptions = {
messageId?: string
/** only send to a specific participant */
participant?: string
additionalAttributes?: { [_: string]: string }
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
//cachedDevices?: (jid: string) => Promise<string[] | undefined>

View File

@@ -18,6 +18,7 @@ import { ConnectionState } from './State'
import { GroupMetadata, ParticipantAction } from './GroupMetadata'
import { MessageInfoUpdate, MessageUpdateType, WAMessage, WAMessageUpdate, WAMessageKey } from './Message'
import { proto } from '../../WAProto'
export type WAVersion = [number, number, number]
export type WABrowserDescription = [string, string, string]
@@ -54,6 +55,11 @@ export type SocketConfig = {
mediaCache?: NodeCache
/** map to store the retry counts for failed messages */
msgRetryCounterMap?: { [msgId: string]: number }
/**
* 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
* */
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
}
export enum DisconnectReason {