update CustomEmojiService.ts

update add-request.ts
update delete.ts
update DriveFileEntityService.ts
update update-request.ts
update update.ts

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-10-28 16:58:36 +09:00
parent 1a6f0026e6
commit 1ed0e7e8a3
No known key found for this signature in database
GPG Key ID: 068E54E2C33BEF9A
6 changed files with 9 additions and 12 deletions

View File

@ -60,7 +60,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
}
@bindThis
public async Request(data: {
public async request(data: {
driveFile: MiDriveFile;
name: string;
category: string | null;
@ -196,7 +196,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
}
}
@bindThis
public async RequestUpdate(id: MiEmoji['id'], data: {
public async updateRequest(id: MiEmoji['id'], data: {
driveFile?: MiDriveFile;
name?: string;
category?: string | null;
@ -332,7 +332,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
}
}
@bindThis
public async RequestDelete(id: MiEmojiRequest['id']) {
public async deleteRequest(id: MiEmojiRequest['id']) {
const emoji = await this.emojiRequestsRepository.findOneByOrFail({ id: id });
await this.emojiRequestsRepository.delete(emoji.id);

View File

@ -135,10 +135,7 @@ export class DriveFileEntityService {
}
@bindThis
public async getFromUrl(url: string): Promise<MiDriveFile | null> {
const file = await this.driveFilesRepository.findOneBy({ url: url });
if (file === null ) return null;
return file;
return this.driveFilesRepository.findOneBy({ url: url });
}
@bindThis
public async calcDriveUsageOf(user: MiUser['id'] | { id: MiUser['id'] }): Promise<number> {

View File

@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
const emoji = await this.customEmojiService.Request({
const emoji = await this.customEmojiService.request({
driveFile,
name: ps.name,
category: ps.category ?? null,

View File

@ -42,7 +42,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
await this.customEmojiService.delete(ps.id, me);
}
if (RequestEmoji != null) {
await this.customEmojiService.RequestDelete(ps.id);
await this.customEmojiService.deleteRequest(ps.id);
}
});
}

View File

@ -101,9 +101,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
localOnly: ps.localOnly ?? false,
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
}, me);
await this.customEmojiService.RequestDelete(ps.id);
await this.customEmojiService.deleteRequest(ps.id);
} else {
await this.customEmojiService.RequestUpdate(ps.id, {
await this.customEmojiService.updateRequest(ps.id, {
name: ps.name,
category: ps.category ?? null,
aliases: ps.aliases ?? [],

View File

@ -101,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} else {
const file = await this.driveFileEntityService.getFromUrl(emoji.originalUrl);
if (file === null) throw new ApiError(meta.errors.noSuchFile);
await this.customEmojiService.Request({
await this.customEmojiService.request({
driveFile: file,
name: ps.name,
category: ps.category ?? null,