Skip to content

Commit 8ae9d2e

Browse files
committed
enhance: カスタム絵文字にライセンス情報を付与できるように
Resolve #10091
1 parent a9bc22e commit 8ae9d2e

File tree

12 files changed

+36
-0
lines changed

12 files changed

+36
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ You should also include the user name that made the change.
1717
- ノートごとに絵文字リアクションを受け取るか設定できるように
1818
- ノート検索の利用可否をロールで制御可能に(デフォルトでオフ)
1919
- ロールの並び順を設定可能に
20+
- カスタム絵文字にライセンス情報を付与できるように
2021
- 指定した文字列を含む投稿の公開範囲をホームにできるように
2122
- enhance(client): 設定から自分のロールを確認できるように
2223
- enhance(client): DM作成時にメンションも含むように

locales/ja-JP.yml

+1
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ resetPasswordConfirm: "パスワードリセットしますか?"
974974
sensitiveWords: "センシティブワード"
975975
sensitiveWordsDescription: "設定したワードが含まれるノートの公開範囲をホームにします。改行で区切って複数設定できます。"
976976
notesSearchNotAvailable: "ノート検索は利用できません。"
977+
license: "ライセンス"
977978

978979
_achievements:
979980
earnedAt: "獲得日時"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export class addPropsForCustomEmoji1678945242650 {
2+
name = 'addPropsForCustomEmoji1678945242650'
3+
4+
async up(queryRunner) {
5+
await queryRunner.query(`ALTER TABLE "emoji" ADD "license" character varying(1024)`);
6+
}
7+
8+
async down(queryRunner) {
9+
await queryRunner.query(`ALTER TABLE "emoji" DROP COLUMN "license"`);
10+
}
11+
}

packages/backend/src/core/CustomEmojiService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class CustomEmojiService {
4444
category: string | null;
4545
aliases: string[];
4646
host: string | null;
47+
license: string | null;
4748
}): Promise<Emoji> {
4849
const emoji = await this.emojisRepository.insert({
4950
id: this.idService.genId(),
@@ -55,6 +56,7 @@ export class CustomEmojiService {
5556
originalUrl: data.driveFile.url,
5657
publicUrl: data.driveFile.webpublicUrl ?? data.driveFile.url,
5758
type: data.driveFile.webpublicType ?? data.driveFile.type,
59+
license: data.license,
5860
}).then(x => this.emojisRepository.findOneByOrFail(x.identifiers[0]));
5961

6062
if (data.host == null) {

packages/backend/src/core/entities/EmojiEntityService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class EmojiEntityService {
5050
host: emoji.host,
5151
// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
5252
url: emoji.publicUrl || emoji.originalUrl,
53+
license: emoji.license,
5354
};
5455
}
5556

packages/backend/src/models/entities/Emoji.ts

+5
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ export class Emoji {
5555
array: true, length: 128, default: '{}',
5656
})
5757
public aliases: string[];
58+
59+
@Column('varchar', {
60+
length: 1024, nullable: true,
61+
})
62+
public license: string | null;
5863
}

packages/backend/src/models/json-schema/emoji.ts

+4
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@ export const packedEmojiDetailedSchema = {
5959
type: 'string',
6060
optional: false, nullable: false,
6161
},
62+
license: {
63+
type: 'string',
64+
optional: false, nullable: true,
65+
},
6266
},
6367
} as const;

packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export class ImportCustomEmojisProcessorService {
102102
host: null,
103103
aliases: emojiInfo.aliases,
104104
driveFile,
105+
license: emojiInfo.license,
105106
});
106107
}
107108

packages/backend/src/server/api/endpoints/admin/emoji/add.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
5656
category: null,
5757
aliases: [],
5858
host: null,
59+
license: null,
5960
});
6061

6162
this.moderationLogService.insertModerationLog(me, 'addEmoji', {

packages/backend/src/server/api/endpoints/admin/emoji/copy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
8787
originalUrl: driveFile.url,
8888
publicUrl: driveFile.webpublicUrl ?? driveFile.url,
8989
type: driveFile.webpublicType ?? driveFile.type,
90+
license: emoji.license,
9091
}).then(x => this.emojisRepository.findOneByOrFail(x.identifiers[0]));
9192

9293
await this.db.queryResultCache?.remove(['meta_emojis']);

packages/backend/src/server/api/endpoints/admin/emoji/update.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const paramDef = {
3535
aliases: { type: 'array', items: {
3636
type: 'string',
3737
} },
38+
license: { type: 'string', nullable: true },
3839
},
3940
required: ['id', 'name', 'aliases'],
4041
} as const;
@@ -64,6 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
6465
name: ps.name,
6566
category: ps.category,
6667
aliases: ps.aliases,
68+
license: ps.license,
6769
});
6870

6971
await this.db.queryResultCache?.remove(['meta_emojis']);

packages/frontend/src/pages/emoji-edit-dialog.vue

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<template #label>{{ i18n.ts.tags }}</template>
2323
<template #caption>{{ i18n.ts.setMultipleBySeparatingWithSpace }}</template>
2424
</MkInput>
25+
<MkInput v-model="license">
26+
<template #label>{{ i18n.ts.license }}</template>
27+
</MkInput>
2528
<MkButton danger @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
2629
</div>
2730
</MkSpacer>
@@ -45,6 +48,7 @@ let dialog = $ref(null);
4548
let name: string = $ref(props.emoji.name);
4649
let category: string = $ref(props.emoji.category);
4750
let aliases: string = $ref(props.emoji.aliases.join(' '));
51+
let license: string = $ref(props.emoji.license ?? '');
4852
4953
const emit = defineEmits<{
5054
(ev: 'done', v: { deleted?: boolean, updated?: any }): void,
@@ -61,6 +65,7 @@ async function update() {
6165
name,
6266
category,
6367
aliases: aliases.split(' '),
68+
license: license === '' ? null : license,
6469
});
6570
6671
emit('done', {
@@ -69,6 +74,7 @@ async function update() {
6974
name,
7075
category,
7176
aliases: aliases.split(' '),
77+
license: license === '' ? null : license,
7278
},
7379
});
7480

0 commit comments

Comments
 (0)