fix: Do not convert langs to lowercase

This commit is contained in:
Essem 2024-02-03 13:26:29 -06:00
parent 112272c254
commit 4f45e72799
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
6 changed files with 6 additions and 29 deletions

View file

@ -63,7 +63,6 @@ import { trackPromise } from '@/misc/promise-tracker.js';
import { isUserRelated } from '@/misc/is-user-related.js'; import { isUserRelated } from '@/misc/is-user-related.js';
import { isNotNull } from '@/misc/is-not-null.js'; import { isNotNull } from '@/misc/is-not-null.js';
import { IdentifiableError } from '@/misc/identifiable-error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js';
import { langmap } from '@/misc/langmap.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -339,13 +338,6 @@ export class NoteCreateService implements OnApplicationShutdown {
data.text = null; data.text = null;
} }
if (data.lang) {
if (!Object.keys(langmap).includes(data.lang.toLowerCase())) throw new Error('invalid param');
data.lang = data.lang.toLowerCase();
} else {
data.lang = null;
}
let tags = data.apHashtags; let tags = data.apHashtags;
let emojis = data.apEmojis; let emojis = data.apEmojis;
let mentionedUsers = data.apMentions; let mentionedUsers = data.apMentions;

View file

@ -52,7 +52,6 @@ import { isReply } from '@/misc/is-reply.js';
import { trackPromise } from '@/misc/promise-tracker.js'; import { trackPromise } from '@/misc/promise-tracker.js';
import { isUserRelated } from '@/misc/is-user-related.js'; import { isUserRelated } from '@/misc/is-user-related.js';
import { IdentifiableError } from '@/misc/identifiable-error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js';
import { langmap } from '@/misc/langmap.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'edited'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'edited';
@ -360,13 +359,6 @@ export class NoteEditService implements OnApplicationShutdown {
data.text = null; data.text = null;
} }
if (data.lang) {
if (!Object.keys(langmap).includes(data.lang.toLowerCase())) throw new Error('invalid param');
data.lang = data.lang.toLowerCase();
} else {
data.lang = null;
}
let tags = data.apHashtags; let tags = data.apHashtags;
let emojis = data.apEmojis; let emojis = data.apEmojis;
let mentionedUsers = data.apMentions; let mentionedUsers = data.apMentions;

View file

@ -256,7 +256,7 @@ export class ApNoteService {
let lang: string | null = null; let lang: string | null = null;
if (note.contentMap != null) { if (note.contentMap != null) {
const key = Object.keys(note.contentMap)[0].toLowerCase(); const key = Object.keys(note.contentMap)[0];
lang = Object.keys(langmap).includes(key) ? key : null; lang = Object.keys(langmap).includes(key) ? key : null;
} }
@ -474,7 +474,7 @@ export class ApNoteService {
let lang: string | null = null; let lang: string | null = null;
if (note.contentMap != null) { if (note.contentMap != null) {
const key = Object.keys(note.contentMap)[0].toLowerCase(); const key = Object.keys(note.contentMap)[0];
lang = Object.keys(langmap).includes(key) ? key : null; lang = Object.keys(langmap).includes(key) ? key : null;
} }

View file

@ -376,10 +376,10 @@ export const iso639Langs3 = {
export const langmapNoRegion = Object.assign({}, iso639Langs1, iso639Langs3); export const langmapNoRegion = Object.assign({}, iso639Langs1, iso639Langs3);
export const iso639Regional = { export const iso639Regional = {
'zh-hans': { 'zh-Hans': {
nativeName: '中文(简体)', nativeName: '中文(简体)',
}, },
'zh-hant': { 'zh-Hant': {
nativeName: '中文(繁體)', nativeName: '中文(繁體)',
}, },
}; };

View file

@ -380,13 +380,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} }
} }
if (ps.lang) {
if (!Object.keys(langmap).includes(ps.lang.toLowerCase())) throw new Error('invalid param');
ps.lang = ps.lang.toLowerCase();
} else {
ps.lang = null;
}
let channel: MiChannel | null = null; let channel: MiChannel | null = null;
if (ps.channelId != null) { if (ps.channelId != null) {
channel = await this.channelsRepository.findOneBy({ id: ps.channelId, isArchived: false }); channel = await this.channelsRepository.findOneBy({ id: ps.channelId, isArchived: false });

View file

@ -376,10 +376,10 @@ export const iso639Langs3 = {
export const langmapNoRegion = Object.assign({}, iso639Langs1, iso639Langs3); export const langmapNoRegion = Object.assign({}, iso639Langs1, iso639Langs3);
export const iso639Regional = { export const iso639Regional = {
'zh-hans': { 'zh-Hans': {
nativeName: '中文(简体)', nativeName: '中文(简体)',
}, },
'zh-hant': { 'zh-Hant': {
nativeName: '中文(繁體)', nativeName: '中文(繁體)',
}, },
}; };