mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: get language from event itself
This commit is contained in:
parent
acbdae29ae
commit
6c93153117
1 changed files with 2 additions and 13 deletions
|
|
@ -38,18 +38,7 @@ const translateController: AppController = async (c) => {
|
||||||
|
|
||||||
const viewerPubkey = await c.get('signer')?.getPublicKey();
|
const viewerPubkey = await c.get('signer')?.getPublicKey();
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
if (targetLang.toLowerCase() === event?.language?.toLowerCase()) {
|
||||||
|
|
||||||
let sourceLang = (await kysely
|
|
||||||
.selectFrom('nostr_events')
|
|
||||||
.select('language').where('id', '=', id)
|
|
||||||
.limit(1)
|
|
||||||
.execute())[0]?.language as LanguageCode | undefined;
|
|
||||||
if (!sourceLang) {
|
|
||||||
sourceLang = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetLang.toLowerCase() === sourceLang?.toLowerCase()) {
|
|
||||||
return c.json({ error: 'Source and target languages are the same. No translation needed.' }, 400);
|
return c.json({ error: 'Source and target languages are the same. No translation needed.' }, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +64,7 @@ const translateController: AppController = async (c) => {
|
||||||
status?.spoiler_text ?? '',
|
status?.spoiler_text ?? '',
|
||||||
mediaAttachments,
|
mediaAttachments,
|
||||||
null,
|
null,
|
||||||
sourceLang,
|
event.language,
|
||||||
targetLang,
|
targetLang,
|
||||||
{ signal },
|
{ signal },
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue