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 @@ -201,6 +201,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, + time: response.newMessageInfo.time, + interface: resultInterface, + }; +}; const saveMessagesActionType = 'SAVE_MESSAGES'; const processMessagesActionType = 'PROCESS_MESSAGES'; @@ -220,6 +255,7 @@ sendMultimediaMessage, legacySendMultimediaMessage, sendReactionMessageActionTypes, + sendReactionMessage, saveMessagesActionType, processMessagesActionType, messageStorePruneActionType,