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:
parent
1a6f0026e6
commit
1ed0e7e8a3
|
@ -60,7 +60,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async Request(data: {
|
public async request(data: {
|
||||||
driveFile: MiDriveFile;
|
driveFile: MiDriveFile;
|
||||||
name: string;
|
name: string;
|
||||||
category: string | null;
|
category: string | null;
|
||||||
|
@ -196,7 +196,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@bindThis
|
@bindThis
|
||||||
public async RequestUpdate(id: MiEmoji['id'], data: {
|
public async updateRequest(id: MiEmoji['id'], data: {
|
||||||
driveFile?: MiDriveFile;
|
driveFile?: MiDriveFile;
|
||||||
name?: string;
|
name?: string;
|
||||||
category?: string | null;
|
category?: string | null;
|
||||||
|
@ -332,7 +332,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@bindThis
|
@bindThis
|
||||||
public async RequestDelete(id: MiEmojiRequest['id']) {
|
public async deleteRequest(id: MiEmojiRequest['id']) {
|
||||||
const emoji = await this.emojiRequestsRepository.findOneByOrFail({ id: id });
|
const emoji = await this.emojiRequestsRepository.findOneByOrFail({ id: id });
|
||||||
|
|
||||||
await this.emojiRequestsRepository.delete(emoji.id);
|
await this.emojiRequestsRepository.delete(emoji.id);
|
||||||
|
|
|
@ -135,10 +135,7 @@ export class DriveFileEntityService {
|
||||||
}
|
}
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getFromUrl(url: string): Promise<MiDriveFile | null> {
|
public async getFromUrl(url: string): Promise<MiDriveFile | null> {
|
||||||
const file = await this.driveFilesRepository.findOneBy({ url: url });
|
return this.driveFilesRepository.findOneBy({ url: url });
|
||||||
if (file === null ) return null;
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
@bindThis
|
@bindThis
|
||||||
public async calcDriveUsageOf(user: MiUser['id'] | { id: MiUser['id'] }): Promise<number> {
|
public async calcDriveUsageOf(user: MiUser['id'] | { id: MiUser['id'] }): Promise<number> {
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
|
|
||||||
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
|
|
||||||
const emoji = await this.customEmojiService.Request({
|
const emoji = await this.customEmojiService.request({
|
||||||
driveFile,
|
driveFile,
|
||||||
name: ps.name,
|
name: ps.name,
|
||||||
category: ps.category ?? null,
|
category: ps.category ?? null,
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
await this.customEmojiService.delete(ps.id, me);
|
await this.customEmojiService.delete(ps.id, me);
|
||||||
}
|
}
|
||||||
if (RequestEmoji != null) {
|
if (RequestEmoji != null) {
|
||||||
await this.customEmojiService.RequestDelete(ps.id);
|
await this.customEmojiService.deleteRequest(ps.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,9 +101,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
localOnly: ps.localOnly ?? false,
|
localOnly: ps.localOnly ?? false,
|
||||||
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
|
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
|
||||||
}, me);
|
}, me);
|
||||||
await this.customEmojiService.RequestDelete(ps.id);
|
await this.customEmojiService.deleteRequest(ps.id);
|
||||||
} else {
|
} else {
|
||||||
await this.customEmojiService.RequestUpdate(ps.id, {
|
await this.customEmojiService.updateRequest(ps.id, {
|
||||||
name: ps.name,
|
name: ps.name,
|
||||||
category: ps.category ?? null,
|
category: ps.category ?? null,
|
||||||
aliases: ps.aliases ?? [],
|
aliases: ps.aliases ?? [],
|
||||||
|
|
|
@ -101,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
} else {
|
} else {
|
||||||
const file = await this.driveFileEntityService.getFromUrl(emoji.originalUrl);
|
const file = await this.driveFileEntityService.getFromUrl(emoji.originalUrl);
|
||||||
if (file === null) throw new ApiError(meta.errors.noSuchFile);
|
if (file === null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
await this.customEmojiService.Request({
|
await this.customEmojiService.request({
|
||||||
driveFile: file,
|
driveFile: file,
|
||||||
name: ps.name,
|
name: ps.name,
|
||||||
category: ps.category ?? null,
|
category: ps.category ?? null,
|
||||||
|
|
Loading…
Reference in New Issue