diff --git a/lib/actions/message-actions.js b/lib/actions/message-actions.js --- a/lib/actions/message-actions.js +++ b/lib/actions/message-actions.js @@ -5,6 +5,7 @@ import type { FetchMessageInfosPayload, SendMessageResult, + SendReactionMessageResult, SimpleMessagesPayload, } from '../types/message-types'; import type { MediaMessageServerDBContent } from '../types/messages/media.js'; @@ -201,6 +202,41 @@ success: 'SEND_REACTION_MESSAGE_SUCCESS', failed: 'SEND_REACTION_MESSAGE_FAILED', }); +const sendReactionMessage = ( + callServerEndpoint: CallServerEndpoint, +): (( + threadID: string, + targetMessageID: string, + reaction: string | null, +) => Promise) => async ( + threadID, + targetMessageID, + reaction, +) => { + let resultInfo; + const getResultInfo = (passedResultInfo: CallServerEndpointResultInfo) => { + resultInfo = passedResultInfo; + }; + const response = await callServerEndpoint( + 'create_reaction_message', + { + threadID, + targetMessageID, + reaction, + }, + { getResultInfo }, + ); + const resultInterface = resultInfo?.interface; + invariant( + resultInterface, + 'getResultInfo not called before callServerEndpoint resolves', + ); + return { + id: response.newMessageInfo.id, + newMessageInfo: response.newMessageInfo, + interface: resultInterface, + }; +}; const saveMessagesActionType = 'SAVE_MESSAGES'; const processMessagesActionType = 'PROCESS_MESSAGES'; @@ -220,6 +256,7 @@ sendMultimediaMessage, legacySendMultimediaMessage, sendReactionMessageActionTypes, + sendReactionMessage, saveMessagesActionType, processMessagesActionType, messageStorePruneActionType, diff --git a/lib/types/message-types.js b/lib/types/message-types.js --- a/lib/types/message-types.js +++ b/lib/types/message-types.js @@ -518,6 +518,13 @@ +time: number, +interface: CallServerEndpointResultInfoInterface, }; + +export type SendReactionMessageResult = { + +id: string, + +newMessageInfo: RawMessageInfo, + +interface: CallServerEndpointResultInfoInterface, +}; + export type SendMessagePayload = { +localID: string, +serverID: string,