Skip to content

Commit

Permalink
feat: 絵文字を登録する際にシステムユーザーとして再アップロード (kokonect-link#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 authored Oct 18, 2024
2 parents 10e333b + 355c669 commit d070349
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Cherrypick 4.11.1
- Fix: (Opensearch利用時)高度な検索でリプライ除外にするとエラーがでる
- Fix: ノート編集時に3001文字以上の場合編集できない問題を修正
- Fix: 通知APIがページ境界で重複する問題の修正
- Change: 絵文字を登録する際にシステムユーザーとして再アップロードするように
(Cherry-picked from https://github.com/team-shahu/misskey/pull/11)

### Misc

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.emojisCache = new MemoryKVCache<MiEmoji | null>(1000 * 60 * 60 * 12); // 12h

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 d070349

Please sign in to comment.