[FIX] Migrate autoTranslate.translateMessage to REST API (#4029)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2022-05-27 14:33:21 -03:00 committed by GitHub
parent 1ce7d5cf6a
commit a527b320e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 10 deletions

View File

@ -291,13 +291,7 @@ const MessageActions = React.memo(
}); });
const translatedMessage = getMessageTranslation(message, room.autoTranslateLanguage); const translatedMessage = getMessageTranslation(message, room.autoTranslateLanguage);
if (!translatedMessage) { if (!translatedMessage) {
const m = { await Services.translateMessage(message.id, room.autoTranslateLanguage);
_id: message.id,
rid: message.subscription ? message.subscription.id : '',
u: message.u,
msg: message.msg
};
await Services.translateMessage(m, room.autoTranslateLanguage);
} }
} catch (e) { } catch (e) {
log(e); log(e);

View File

@ -0,0 +1,5 @@
export type AutoTranslateEndpoints = {
'autotranslate.translateMessage': {
POST: (params: { messageId: string; targetLanguage: string }) => void;
};
};

View File

@ -19,6 +19,7 @@ import { VideoConferenceEndpoints } from './videoConference';
import { CommandsEndpoints } from './commands'; import { CommandsEndpoints } from './commands';
import { PushTokenEndpoints } from './pushToken'; import { PushTokenEndpoints } from './pushToken';
import { DirectoryEndpoint } from './directory'; import { DirectoryEndpoint } from './directory';
import { AutoTranslateEndpoints } from './autotranslate';
export type Endpoints = ChannelsEndpoints & export type Endpoints = ChannelsEndpoints &
ChatEndpoints & ChatEndpoints &
@ -40,4 +41,5 @@ export type Endpoints = ChannelsEndpoints &
VideoConferenceEndpoints & VideoConferenceEndpoints &
CommandsEndpoints & CommandsEndpoints &
PushTokenEndpoints & PushTokenEndpoints &
DirectoryEndpoint; DirectoryEndpoint &
AutoTranslateEndpoints;

View File

@ -751,8 +751,8 @@ export const saveAutoTranslate = ({
export const getSupportedLanguagesAutoTranslate = (): Promise<{ language: string; name: string }[]> => export const getSupportedLanguagesAutoTranslate = (): Promise<{ language: string; name: string }[]> =>
sdk.methodCallWrapper('autoTranslate.getSupportedLanguages', 'en'); sdk.methodCallWrapper('autoTranslate.getSupportedLanguages', 'en');
export const translateMessage = (message: any, targetLanguage: string) => export const translateMessage = (messageId: string, targetLanguage: string) =>
sdk.methodCallWrapper('autoTranslate.translateMessage', message, targetLanguage); sdk.post('autotranslate.translateMessage', { messageId, targetLanguage });
export const findOrCreateInvite = ({ rid, days, maxUses }: { rid: string; days: number; maxUses: number }): any => export const findOrCreateInvite = ({ rid, days, maxUses }: { rid: string; days: number; maxUses: number }): any =>
// RC 2.4.0 // RC 2.4.0