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 @@ -1,9 +1,7 @@ // @flow -import invariant from 'invariant'; import * as React from 'react'; -import type { CallSingleKeyserverEndpointResultInfo } from '../keyserver-conn/call-single-keyserver-endpoint.js'; import { extractKeyserverIDFromIDOptional, extractKeyserverIDFromID, @@ -183,12 +181,6 @@ callKeyserverEndpoint: CallKeyserverEndpoint, ): ((input: SendTextMessageInput) => Promise) => async input => { - let resultInfo; - const getResultInfo = ( - passedResultInfo: CallSingleKeyserverEndpointResultInfo, - ) => { - resultInfo = passedResultInfo; - }; const { threadID, localID, text, sidebarCreation } = input; let payload = { threadID, localID, text }; if (sidebarCreation) { @@ -201,19 +193,10 @@ const responses = await callKeyserverEndpoint( 'create_text_message', requests, - { - getResultInfo, - }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callKeyserverEndpoint resolves', ); return { id: responses[keyserverID].newMessageInfo.id, time: responses[keyserverID].newMessageInfo.time, - interface: resultInterface, }; }; @@ -242,12 +225,6 @@ callKeyserverEndpoint: CallKeyserverEndpoint, ): ((input: SendMultimediaMessageInput) => Promise) => async input => { - let resultInfo; - const getResultInfo = ( - passedResultInfo: CallSingleKeyserverEndpointResultInfo, - ) => { - resultInfo = passedResultInfo; - }; const { threadID, localID, mediaMessageContents, sidebarCreation } = input; let payload = { threadID, localID, mediaMessageContents }; if (sidebarCreation) { @@ -260,17 +237,10 @@ const responses = await callKeyserverEndpoint( 'create_multimedia_message', requests, - { getResultInfo }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callKeyserverEndpoint resolves', ); return { id: responses[keyserverID].newMessageInfo.id, time: responses[keyserverID].newMessageInfo.time, - interface: resultInterface, }; }; @@ -294,12 +264,6 @@ input: LegacySendMultimediaMessageInput, ) => Promise) => async input => { - let resultInfo; - const getResultInfo = ( - passedResultInfo: CallSingleKeyserverEndpointResultInfo, - ) => { - resultInfo = passedResultInfo; - }; const { threadID, localID, mediaIDs, sidebarCreation } = input; let payload = { threadID, localID, mediaIDs }; if (sidebarCreation) { @@ -312,17 +276,10 @@ const responses = await callKeyserverEndpoint( 'create_multimedia_message', requests, - { getResultInfo }, - ); - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callKeyserverEndpoint resolves', ); return { id: responses[keyserverID].newMessageInfo.id, time: responses[keyserverID].newMessageInfo.time, - interface: resultInterface, }; }; @@ -342,13 +299,6 @@ callKeyserverEndpoint: CallKeyserverEndpoint, ): ((input: SendReactionMessageRequest) => Promise) => async input => { - let resultInfo; - const getResultInfo = ( - passedResultInfo: CallSingleKeyserverEndpointResultInfo, - ) => { - resultInfo = passedResultInfo; - }; - const keyserverID = extractKeyserverIDFromID(input.threadID); const requests = { [keyserverID]: { @@ -363,19 +313,10 @@ const responses = await callKeyserverEndpoint( 'create_reaction_message', requests, - { getResultInfo }, ); - - const resultInterface = resultInfo?.interface; - invariant( - resultInterface, - 'getResultInfo not called before callKeyserverEndpoint resolves', - ); - return { id: responses[keyserverID].newMessageInfo.id, time: responses[keyserverID].newMessageInfo.time, - interface: resultInterface, }; }; diff --git a/lib/keyserver-conn/call-single-keyserver-endpoint.js b/lib/keyserver-conn/call-single-keyserver-endpoint.js --- a/lib/keyserver-conn/call-single-keyserver-endpoint.js +++ b/lib/keyserver-conn/call-single-keyserver-endpoint.js @@ -36,9 +36,6 @@ // null timeout means no timeout, which is the default for // defaultPerformHTTPMultipartUpload +timeout: ?number, // in milliseconds - // getResultInfo will be called right before callSingleKeyserverEndpoint - // successfully resolves and includes additional information about the request - +getResultInfo: (resultInfo: CallSingleKeyserverEndpointResultInfo) => mixed, +performHTTPMultipartUpload: boolean | PerformHTTPMultipartUpload, // onProgress and abortHandler only work with performHTTPMultipartUpload +onProgress: (percent: number) => void, @@ -48,11 +45,6 @@ +urlPrefixOverride: string, }>; -export type CallSingleKeyserverEndpointResultInfoInterface = 'socket' | 'REST'; -export type CallSingleKeyserverEndpointResultInfo = { - +interface: CallSingleKeyserverEndpointResultInfoInterface, -}; - export type CallSingleKeyserverEndpointResponse = Partial<{ +cookieChange: ServerSessionChange, +currentUserInfo: CurrentUserInfo, @@ -114,9 +106,7 @@ !options?.urlPrefixOverride ) { try { - const result = await socketAPIHandler({ endpoint, input }); - options?.getResultInfo?.({ interface: 'socket' }); - return result; + return socketAPIHandler({ endpoint, input }); } catch (e) { if (endpointIsSocketOnly(endpoint)) { throw e; @@ -245,7 +235,6 @@ if (error) { throw new ServerError(error, payload); } - options?.getResultInfo?.({ interface: 'REST' }); return json; } 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 @@ -143,7 +143,6 @@ } from './messages/update-relationship.js'; import { rawUpdateRelationshipMessageInfoValidator } from './messages/update-relationship.js'; import { type RelativeUserInfo, type UserInfos } from './user-types.js'; -import type { CallSingleKeyserverEndpointResultInfoInterface } from '../keyserver-conn/call-single-keyserver-endpoint.js'; import { values } from '../utils/objects.js'; import { tID, tNumber, tShape, tUserID } from '../utils/validation-utils.js'; @@ -606,7 +605,6 @@ export type SendMessageResult = { +id: string, +time: number, - +interface: CallSingleKeyserverEndpointResultInfoInterface, }; export type SendMessagePayload = { @@ -614,7 +612,6 @@ +serverID: string, +threadID: string, +time: number, - +interface: CallSingleKeyserverEndpointResultInfoInterface, }; export type SendTextMessageRequest = { diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js --- a/native/chat/reaction-message-utils.js +++ b/native/chat/reaction-message-utils.js @@ -104,7 +104,6 @@ serverID: result.id, threadID, time: result.time, - interface: result.interface, }; } catch (e) { Alert.alert( diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -410,7 +410,6 @@ serverID: result.id, threadID, time: result.time, - interface: result.interface, }; } catch (e) { const copy = cloneError(e); @@ -650,7 +649,6 @@ serverID: result.id, threadID: messageInfo.threadID, time: result.time, - interface: result.interface, }; } catch (e) { const copy = cloneError(e); diff --git a/web/chat/reaction-message-utils.js b/web/chat/reaction-message-utils.js --- a/web/chat/reaction-message-utils.js +++ b/web/chat/reaction-message-utils.js @@ -9,7 +9,6 @@ sendReactionMessageActionTypes, } from 'lib/actions/message-actions.js'; import { useModalContext } from 'lib/components/modal-provider.react.js'; -import type { CallSingleKeyserverEndpointResultInfoInterface } from 'lib/keyserver-conn/call-single-keyserver-endpoint.js'; import type { ReactionInfo } from 'lib/selectors/chat-selectors'; import { dmOperationSpecificationTypes, @@ -106,14 +105,11 @@ }); const serverID: string = result.id; const time: number = result.time; - const interfaceInfo: CallSingleKeyserverEndpointResultInfoInterface = - result.interface; return { localID, serverID, threadID, time, - interface: interfaceInfo, }; } catch (e) { pushModal( diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -584,7 +584,6 @@ serverID: result.id, threadID, time: result.time, - interface: result.interface, }; } catch (e) { const copy = cloneError(e); @@ -1446,7 +1445,6 @@ serverID: result.id, threadID: messageInfo.threadID, time: result.time, - interface: result.interface, }; } catch (e) { const copy = cloneError(e);