diff --git a/lib/actions/message-report-actions.js b/lib/actions/message-report-actions.js --- a/lib/actions/message-report-actions.js +++ b/lib/actions/message-report-actions.js @@ -4,7 +4,9 @@ MessageReportCreationRequest, MessageReportCreationResult, } from '../types/message-report-types.js'; -import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; +import { extractKeyserverIDFromID } from '../utils/action-utils.js'; +import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; +import { useKeyserverCall } from '../utils/keyserver-call.js'; const sendMessageReportActionTypes = Object.freeze({ started: 'SEND_MESSAGE_REPORT_STARTED', @@ -13,12 +15,27 @@ }); const sendMessageReport = ( - callServerEndpoint: CallServerEndpoint, + callKeyserverEndpoint: CallKeyserverEndpoint, ): (( - request: MessageReportCreationRequest, + input: MessageReportCreationRequest, ) => Promise) => - async request => { - return await callServerEndpoint('create_message_report', request); + async input => { + const keyserverID = extractKeyserverIDFromID(input.messageID); + const requests = { [keyserverID]: input }; + + const responses = await callKeyserverEndpoint( + 'create_message_report', + requests, + ); + const response = responses[keyserverID]; + + return { messageInfo: response.messageInfo }; }; -export { sendMessageReportActionTypes, sendMessageReport }; +function useSendMessageReport(): ( + input: MessageReportCreationRequest, +) => Promise { + return useKeyserverCall(sendMessageReport); +} + +export { sendMessageReportActionTypes, useSendMessageReport }; diff --git a/native/chat/message-report-utils.js b/native/chat/message-report-utils.js --- a/native/chat/message-report-utils.js +++ b/native/chat/message-report-utils.js @@ -3,13 +3,10 @@ import * as React from 'react'; import { - sendMessageReport, + useSendMessageReport, sendMessageReportActionTypes, } from 'lib/actions/message-report-actions.js'; -import { - useServerCall, - useDispatchActionPromise, -} from 'lib/utils/action-utils.js'; +import { useDispatchActionPromise } from 'lib/utils/action-utils.js'; import { displayActionResultModal } from '../navigation/action-result-modal.js'; import type { TooltipRoute } from '../tooltip/tooltip.react.js'; @@ -24,7 +21,7 @@ ): () => mixed { const messageID = route.params.item.messageInfo.id; const dispatchActionPromise = useDispatchActionPromise(); - const callSendMessageReport = useServerCall(sendMessageReport); + const callSendMessageReport = useSendMessageReport(); return React.useCallback(() => { if (!messageID) { Alert.alert(