refactor: drop lang from user_profile

This commit is contained in:
naskya 2024-02-21 03:25:45 +09:00
parent 7c42a3b614
commit 9fbca3fd95
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
10 changed files with 21 additions and 33 deletions

View file

@ -9,6 +9,7 @@ Breaking changes are indicated by the :warning: icon.
- `mod`: `add` permission + edit the name/category/tag/license of the existing custom emojis
- `full`: `mod` permission + delete existing custom emojis
- Emoji moderators are able to access to the endpoints under `admin/emoji/`
- Removed `lang` from the response of `i` and the request parameter of `i/update`.
## v20240217

View file

@ -5,6 +5,7 @@ Critical security updates are indicated by the :warning: icon.
## Unreleased
- Add the ability to give regular (non-moderator) users permission to manage custom emojis
- Fix a bug that made impossible to update user profiles under some conditions
## :warning: v20240217-1

View file

@ -1,12 +1,16 @@
BEGIN;
DELETE FROM "migrations" WHERE name IN (
'DropUserProfileLanguage1708452631156',
'EmojiModerator1692825433698',
'RemoveNsfwDetection1705848938166',
'FirefishUrlMove1707850084123',
'RemoveNativeUtilsMigration1705877093218'
);
-- drop-user-profile-language
ALTER TABLE "user_profile" ADD COLUMN "lang" character varying(32);
-- emoji-moderator
ALTER TABLE "user" DROP COLUMN "emojiModPerm";
DROP TYPE "public"."user_emojimodperm_enum";

View file

@ -0,0 +1,13 @@
export class DropUserProfileLanguage1708452631156 {
name = "DropUserProfileLanguage1708452631156";
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "lang"`);
}
async down(queryRunner) {
await queryRunner.query(
`ALTER TABLE "user_profile" ADD COLUMN "lang" character varying(32)`,
);
}
}

View file

@ -54,12 +54,6 @@ export class UserProfile {
verified?: boolean;
}[];
@Column("varchar", {
length: 32,
nullable: true,
})
public lang: string | null;
@Column("varchar", {
length: 512,
nullable: true,

View file

@ -504,7 +504,6 @@ export const UserRepository = db.getRepository(User).extend({
description: profile!.description,
location: profile!.location,
birthday: profile!.birthday,
lang: profile!.lang,
fields: profile!.fields,
followersCount: followersCount || 0,
followingCount: followingCount || 0,

View file

@ -204,12 +204,6 @@ export const packedUserDetailedNotMeOnlySchema = {
optional: false,
example: "2018-03-12",
},
lang: {
type: "string",
nullable: true,
optional: false,
example: "ja-JP",
},
fields: {
type: "array",
nullable: false,

View file

@ -11,7 +11,6 @@ import type { User } from "@/models/entities/user.js";
import type { UserProfile } from "@/models/entities/user-profile.js";
import { notificationTypes } from "@/types.js";
import { normalizeForSearch } from "@/misc/normalize-for-search.js";
import { langmap } from "@/misc/langmap.js";
import { verifyLink } from "@/services/fetch-rel-me.js";
import { ApiError } from "@/server/api/error.js";
import define from "@/server/api/define.js";
@ -88,11 +87,6 @@ export const paramDef = {
description: { ...Users.descriptionSchema, nullable: true },
location: { ...Users.locationSchema, nullable: true },
birthday: { ...Users.birthdaySchema, nullable: true },
lang: {
type: "string",
enum: Object.keys(langmap),
nullable: true,
},
avatarId: { type: "string", format: "misskey:id", nullable: true },
bannerId: { type: "string", format: "misskey:id", nullable: true },
fields: {
@ -159,7 +153,6 @@ export default define(meta, paramDef, async (ps, _user, token) => {
if (ps.name !== undefined) updates.name = ps.name;
if (ps.description !== undefined) profileUpdates.description = ps.description;
if (typeof ps.lang === "string") profileUpdates.lang = ps.lang;
if (ps.location !== undefined) profileUpdates.location = ps.location;
if (ps.birthday !== undefined) profileUpdates.birthday = ps.birthday;
if (ps.ffVisibility !== undefined)

View file

@ -12,7 +12,7 @@ async function follow(userId: User["id"], follower: User) {
/*
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('follow')) return;
const locale = locales[userProfile.lang || 'ja-JP'];
const locale = locales['en-US'];
const i18n = new I18n(locale);
// TODO: render user information html
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);
@ -23,7 +23,7 @@ async function receiveFollowRequest(userId: User["id"], follower: User) {
/*
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('receiveFollowRequest')) return;
const locale = locales[userProfile.lang || 'ja-JP'];
const locale = locales['en-US'];
const i18n = new I18n(locale);
// TODO: render user information html
sendEmail(userProfile.email, i18n.t('_email._receiveFollowRequest.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);

View file

@ -74,13 +74,6 @@
<template #prefix><i :class="icon('ph-cake')"></i></template>
</FormInput>
<FormSelect v-model="profile.lang" class="_formBlock">
<template #label>{{ i18n.ts.language }}</template>
<option v-for="x in Object.keys(langmap)" :key="x" :value="x">
{{ langmap[x].nativeName }}
</option>
</FormSelect>
<FormSlot class="_formBlock">
<FormFolder>
<template #icon><i :class="icon('ph-table')"></i></template>
@ -163,7 +156,6 @@ import MkButton from "@/components/MkButton.vue";
import FormInput from "@/components/form/input.vue";
import FormTextarea from "@/components/form/textarea.vue";
import FormSwitch from "@/components/form/switch.vue";
import FormSelect from "@/components/form/select.vue";
import FormSplit from "@/components/form/split.vue";
import FormFolder from "@/components/form/folder.vue";
import FormSlot from "@/components/form/slot.vue";
@ -171,7 +163,6 @@ import { selectFile } from "@/scripts/select-file";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { langmap } from "@/scripts/langmap";
import { definePageMetadata } from "@/scripts/page-metadata";
import { host } from "@/config";
import icon from "@/scripts/icon";
@ -181,7 +172,6 @@ const profile = reactive({
description: $i?.description,
location: $i?.location,
birthday: $i?.birthday,
lang: $i?.lang,
isBot: $i?.isBot,
isCat: $i?.isCat,
speakAsCat: $i?.speakAsCat,
@ -238,7 +228,6 @@ function save() {
description: convertEmptyStringToNull(profile.description),
location: convertEmptyStringToNull(profile.location),
birthday: convertEmptyStringToNull(profile.birthday),
lang: convertEmptyStringToNull(profile.lang),
isBot: !!profile.isBot,
isCat: !!profile.isCat,
speakAsCat: profile.isCat ? !!profile.speakAsCat : undefined,