1
0
Fork 1
mirror of https://example.com synced 2024-11-22 11:26:38 +09:00

chore: rename default emoji mod permission from 'none' to 'unauthorized' considering name collision in Rust

This commit is contained in:
naskya 2023-11-11 10:03:45 +09:00
parent 198bfe4d37
commit 8b8a498c54
Signed by: naskya
GPG key ID: 164DFF24E2D40139
21 changed files with 49 additions and 29 deletions

View file

@ -2170,7 +2170,7 @@ _feeds:
emojiModPerm: "Custom emoji management"
emojiModPermDescription: "Add: Allow this user to add new custom emojis and to set tag/category/license to newly added custom emojis.\nAdd and Edit: \"Add\" Permission + Allow this user to edit the name/category/tag/license of the existing custom emojis.\nAllow All: \"Add and Edit\" Permission + Allow this user to delete existing custom emojis."
_emojiModPerm:
none: "Deny All"
unauthorized: "Deny All"
add: "Add"
mod: "Add and Edit"
full: "Allow All"

View file

@ -2004,7 +2004,7 @@ confirm: "確認"
emojiModPerm: "カスタム絵文字の管理"
emojiModPermDescription: "追加: カスタム絵文字の新規追加と新規追加されたカスタム絵文字(正確には、タグとカテゴリとライセンスが設定されていないカスタム絵文字)へのタグとカテゴリとライセンスの設定を許可します。\n追加と変更:「追加」の権限に加え、既存の絵文字の名前・カテゴリ・タグ・ライセンスの変更を許可します。\n全て許可:「追加と変更」の権限に加え、既存のカスタム絵文字の削除を許可します。\nこの設定にかかわらず、サーバーの管理者およびモデレーターには「全て許可」の権限が与えられます。"
_emojiModPerm:
none: "不許可"
unauthorized: "不許可"
add: "追加"
mod: "追加と変更"
full: "全て許可"

View file

@ -2000,7 +2000,7 @@ disableToast: 不顯示「歡迎回來,◯◯」
emojiModPerm: 自訂表情符號的管理
emojiModPermDescription: "新增: 允許新增自訂表情符號,並允許設定尚未設定標籤/類別/授權條款的現有自訂表情符號。\n新增及編輯: 除了「新增」的權限之外,也允許編輯現有自訂表情符號的標籤/類別/授權條款\n全部允許: 除了「新增及編輯」的權限之外,也允許刪除現有的自訂表情符號。\n伺服器管理員及板主無論此設定為何皆有「全部允許」的權限。"
_emojiModPerm:
none: 不允許
unauthorized: 不允許
add: 新增
mod: 新增及編輯
full: 全部允許

View file

@ -0,0 +1,15 @@
export class EmojimodEnumRelabel1699658378432 {
name = "EmojimodEnumRelabel1699658378432";
async up(queryRunner) {
await queryRunner.query(
`ALTER TYPE "public"."user_emojimodperm_enum" RENAME VALUE 'none' TO 'unauthorized'`,
);
}
async down(queryRunner) {
await queryRunner.query(
`ALTER TYPE "public"."user_emojimodperm_enum" RENAME VALUE 'unauthorized' TO 'none'`,
);
}
}

View file

@ -182,7 +182,7 @@ pub enum UserEmojimodpermEnum {
Mod,
#[default]
#[sea_orm(string_value = "none")]
None,
Unauthorized,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm(

View file

@ -9,11 +9,11 @@ import {
import { id } from "../id.js";
import { DriveFile } from "./drive-file.js";
// none: no permission
// add: add custom emojis to the server
// mod: add permission + modify {category, tags, license} of existing custom emojis
// full: mod permission + {rename, delete} existing custom emojis
export type EmojiModPerm = "none" | "add" | "mod" | "full";
// unauthorized: no permission
// add: add custom emojis to the server
// mod: add permission + modify {category, tags, license} of existing custom emojis
// full: mod permission + {rename, delete} existing custom emojis
export type EmojiModPerm = "unauthorized" | "add" | "mod" | "full";
@Entity()
@Index(["usernameLower", "host"], { unique: true })
@ -187,8 +187,8 @@ export class User {
@Column({
type: "enum",
enum: ["none", "add", "mod", "full"],
default: "none",
enum: ["unauthorized", "add", "mod", "full"],
default: "unauthorized",
})
public emojiModPerm: EmojiModPerm;

View file

@ -450,7 +450,7 @@ export const UserRepository = db.getRepository(User).extend({
avatarUrl: this.getAvatarUrlSync(user),
avatarBlurhash: user.avatar?.blurhash || null,
avatarColor: null, // 後方互換性のため
emojiModPerm: user.emojiModPerm ?? "none",
emojiModPerm: user.emojiModPerm ?? "unauthorized",
isAdmin: user.isAdmin || falsy,
isModerator: user.isModerator || falsy,
isBot: user.isBot || falsy,

View file

@ -41,7 +41,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji mod permission (or add permission if there is no alias)
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const emojis = await Emojis.findBy({

View file

@ -38,7 +38,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji add permission
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const file = await DriveFiles.findOneBy({ id: ps.fileId });

View file

@ -28,7 +28,9 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => {
// require emoji add permission
if (!(user.isAdmin || user.isModerator || user.emojiModPerm !== "none"))
if (
!(user.isAdmin || user.isModerator || user.emojiModPerm !== "unauthorized")
)
throw new ApiError(meta.errors.accessDenied);
createImportCustomEmojisJob(user, ps.fileId);

View file

@ -104,7 +104,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji add permission
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const q = makePaginationQuery(

View file

@ -98,7 +98,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji add permission
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const q = makePaginationQuery(

View file

@ -41,7 +41,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji mod permission (or add permission if there is no alias)
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const emojis = await Emojis.findBy({

View file

@ -40,7 +40,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji mod permission (or add permission if there is no category)
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const emojis = await Emojis.findBy({

View file

@ -40,7 +40,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji mod permission (or add permission if there is no license)
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm === "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const emojis = await Emojis.findBy({

View file

@ -49,7 +49,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// require emoji mod permission (or add permission if there is no category/alias/license)
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "none"))
if (!(me.isAdmin || me.isModerator || me.emojiModPerm !== "unauthorized"))
throw new ApiError(meta.errors.accessDenied);
const emoji = await Emojis.findOneBy({ id: ps.id });

View file

@ -25,12 +25,15 @@ export default define(meta, paramDef, async (ps) => {
throw new Error("user not found");
}
if (!["none", "add", "mod", "full"].includes(ps.emojiModPerm)) {
throw new Error("emojiModPerm must be 'none', 'add', 'mod', or 'full'");
if (!["unauthorized", "add", "mod", "full"].includes(ps.emojiModPerm)) {
throw new Error(
"emojiModPerm must be 'unauthorized', 'add', 'mod', or 'full'",
);
}
const _emojiModPerm =
(ps.emojiModPerm as "none" | "add" | "mod" | "full") ?? "none";
(ps.emojiModPerm as "unauthorized" | "add" | "mod" | "full") ??
"unauthorized";
await Users.update(user.id, {
emojiModPerm: _emojiModPerm,

View file

@ -14,7 +14,7 @@ export type Account = firefish.entities.MeDetailed;
export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator);
export const iAmAdmin = $i?.isAdmin;
export const iAmEmojiMod = iAmModerator || $i?.emojiModPerm !== "none";
export const iAmEmojiMod = iAmModerator || $i?.emojiModPerm !== "unauthorized";
export async function signout() {
waiting();

View file

@ -189,8 +189,8 @@
i18n.ts.originalFeature
}}</span></template
>
<option value="none">
{{ i18n.ts._emojiModPerm.none }}
<option value="unauthorized">
{{ i18n.ts._emojiModPerm.unauthorized }}
</option>
<option value="add">
{{ i18n.ts._emojiModPerm.add }}

View file

@ -81,7 +81,7 @@
><span class="text">{{ i18n.ts.controlPanel }}</span>
</MkA>
<MkA
v-else-if="$i.emojiModPerm !== 'none'"
v-else-if="$i.emojiModPerm !== 'unauthorized'"
v-click-anime
v-tooltip.noDelay.right="i18n.ts.customEmojis"
class="item _button"

View file

@ -93,7 +93,7 @@
><span class="text">{{ i18n.ts.controlPanel }}</span>
</MkA>
<MkA
v-else-if="$i.emojiModPerm !== 'none'"
v-else-if="$i.emojiModPerm !== 'unauthorized'"
v-click-anime
v-tooltip.noDelay.right="i18n.ts.customEmojis"
class="item _button"