Skip to content

Commit

Permalink
Merge pull request yojo-art#11 from team-shahu/feat/emoji-not-deleted
Browse files Browse the repository at this point in the history
feat: 絵文字を登録したユーザーがアカウントを消去しても継続して絵文字の使用ができるように
  • Loading branch information
chan-mai authored Jun 14, 2024
2 parents 121d784 + 6b365ea commit dcba2ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- 通知にフォロバボタンを表示
- 二要素認証のバックアップコードを保存するように促すダイアログを表示するように
- カスタムフォント機能
- 絵文字を登録したユーザーがアカウントを消去しても継続して絵文字の使用ができるように

## Special Thanks
- [Misskey](https://github.com/misskey-dev/misskey)
Expand Down
10 changes: 10 additions & 0 deletions packages/backend/src/core/CustomEmojiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { UtilityService } from '@/core/UtilityService.js';
import { query } from '@/misc/prelude/url.js';
import type { Serialized } from '@/types.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
import { DriveService } from '@/core/DriveService.js';

const parseEmojiStrRegexp = /^([-\w]+)(?:@([\w.-]+))?$/;

Expand All @@ -39,6 +40,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
private emojiEntityService: EmojiEntityService,
private moderationLogService: ModerationLogService,
private globalEventService: GlobalEventService,
private driveService: DriveService,
) {
this.cache = new MemoryKVCache<MiEmoji | null>(1000 * 60 * 60 * 12);

Expand Down Expand Up @@ -68,6 +70,14 @@ export class CustomEmojiService implements OnApplicationShutdown {
localOnly: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction: MiRole['id'][];
}, moderator?: MiUser): Promise<MiEmoji> {
// システムユーザーとして再アップロード
if (!data.driveFile.user?.isRoot) {
data.driveFile = await this.driveService.uploadFromUrl({
url: data.driveFile.url,
user: null,
force: true,
});
}
const emoji = await this.emojisRepository.insertOne({
id: this.idService.gen(),
updatedAt: new Date(),
Expand Down

0 comments on commit dcba2ce

Please sign in to comment.