1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-27 14:28:53 +09:00

Fix(backend): broken emoji copy

This commit is contained in:
ltlapy 2023-04-04 23:34:29 +09:00
parent 5aeee9b95b
commit ddae52fe0f

View File

@ -2,8 +2,6 @@ import { Inject, Injectable } from '@nestjs/common';
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import type { EmojisRepository } from '@/models/index.js'; import type { EmojisRepository } from '@/models/index.js';
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
import { ModerationLogService } from '@/core/ModerationLogService.js';
import { IdService } from '@/core/IdService.js'; import { IdService } from '@/core/IdService.js';
import type { DriveFile } from '@/models/entities/DriveFile.js'; import type { DriveFile } from '@/models/entities/DriveFile.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
@ -58,12 +56,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
@Inject(DI.emojisRepository) @Inject(DI.emojisRepository)
private emojisRepository: EmojisRepository, private emojisRepository: EmojisRepository,
private customEmojiService: CustomEmojiService,
private moderationLogService: ModerationLogService,
// private emojiEntityService: EmojiEntityService, private emojiEntityService: EmojiEntityService,
// private idService: IdService, private idService: IdService,
// private globalEventService: GlobalEventService, private globalEventService: GlobalEventService,
private driveService: DriveService, private driveService: DriveService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
@ -82,9 +78,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
throw new ApiError(); throw new ApiError();
} }
const copied = await this.customEmojiService.add({ const copied = await this.emojisRepository.insert({
id: this.idService.genId(),
updatedAt: new Date(),
name: emoji.name, name: emoji.name,
category: null,
host: null, host: null,
aliases: [], aliases: [],
originalUrl: driveFile.url, originalUrl: driveFile.url,
@ -95,8 +92,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
await this.db.queryResultCache?.remove(['meta_emojis']); await this.db.queryResultCache?.remove(['meta_emojis']);
this.moderationLogService.insertModerationLog(me, 'copyEmoji', { this.globalEventService.publishBroadcastStream('emojiAdded', {
emojiId: emoji.id, emoji: await this.emojiEntityService.packDetailed(copied.id),
}); });
return { return {