diff --git a/app/containers/MessageActions/index.tsx b/app/containers/MessageActions/index.tsx index 1c7ca9536..811d01180 100644 --- a/app/containers/MessageActions/index.tsx +++ b/app/containers/MessageActions/index.tsx @@ -291,13 +291,7 @@ const MessageActions = React.memo( }); const translatedMessage = getMessageTranslation(message, room.autoTranslateLanguage); if (!translatedMessage) { - const m = { - _id: message.id, - rid: message.subscription ? message.subscription.id : '', - u: message.u, - msg: message.msg - }; - await Services.translateMessage(m, room.autoTranslateLanguage); + await Services.translateMessage(message.id, room.autoTranslateLanguage); } } catch (e) { log(e); diff --git a/app/definitions/rest/v1/autotranslate.ts b/app/definitions/rest/v1/autotranslate.ts new file mode 100644 index 000000000..ed39817ac --- /dev/null +++ b/app/definitions/rest/v1/autotranslate.ts @@ -0,0 +1,5 @@ +export type AutoTranslateEndpoints = { + 'autotranslate.translateMessage': { + POST: (params: { messageId: string; targetLanguage: string }) => void; + }; +}; diff --git a/app/definitions/rest/v1/index.ts b/app/definitions/rest/v1/index.ts index 4289f55c6..385da8927 100644 --- a/app/definitions/rest/v1/index.ts +++ b/app/definitions/rest/v1/index.ts @@ -19,6 +19,7 @@ import { VideoConferenceEndpoints } from './videoConference'; import { CommandsEndpoints } from './commands'; import { PushTokenEndpoints } from './pushToken'; import { DirectoryEndpoint } from './directory'; +import { AutoTranslateEndpoints } from './autotranslate'; export type Endpoints = ChannelsEndpoints & ChatEndpoints & @@ -40,4 +41,5 @@ export type Endpoints = ChannelsEndpoints & VideoConferenceEndpoints & CommandsEndpoints & PushTokenEndpoints & - DirectoryEndpoint; + DirectoryEndpoint & + AutoTranslateEndpoints; diff --git a/app/lib/services/restApi.ts b/app/lib/services/restApi.ts index 58eac22c4..1e26271d9 100644 --- a/app/lib/services/restApi.ts +++ b/app/lib/services/restApi.ts @@ -751,8 +751,8 @@ export const saveAutoTranslate = ({ export const getSupportedLanguagesAutoTranslate = (): Promise<{ language: string; name: string }[]> => sdk.methodCallWrapper('autoTranslate.getSupportedLanguages', 'en'); -export const translateMessage = (message: any, targetLanguage: string) => - sdk.methodCallWrapper('autoTranslate.translateMessage', message, targetLanguage); +export const translateMessage = (messageId: string, targetLanguage: string) => + sdk.post('autotranslate.translateMessage', { messageId, targetLanguage }); export const findOrCreateInvite = ({ rid, days, maxUses }: { rid: string; days: number; maxUses: number }): any => // RC 2.4.0