emoji request
This commit is contained in:
parent
d439dd66f9
commit
66bb2e15c8
|
@ -6,6 +6,7 @@ import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { ApiError } from '../../../error.js';
|
import { ApiError } from '../../../error.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
import {DriveService} from "@/core/DriveService.js";
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
|
@ -53,11 +54,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private customEmojiService: CustomEmojiService,
|
private customEmojiService: CustomEmojiService,
|
||||||
private moderationLogService: ModerationLogService,
|
private moderationLogService: ModerationLogService,
|
||||||
|
private driveService: DriveService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
|
let driveFile;
|
||||||
|
let tmp = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
|
||||||
|
if (tmp == null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
|
|
||||||
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
try {
|
||||||
|
driveFile = await this.driveService.uploadFromUrl({ url: tmp.url , user: null, force: true });
|
||||||
|
} catch (e) {
|
||||||
|
throw new ApiError();
|
||||||
|
}
|
||||||
|
|
||||||
const emoji = await this.customEmojiService.add({
|
const emoji = await this.customEmojiService.add({
|
||||||
driveFile,
|
driveFile,
|
||||||
|
@ -72,15 +80,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
|
roleIdsThatCanBeUsedThisEmojiAsReaction: [],
|
||||||
});
|
});
|
||||||
const {ApiBase,EmojiBotToken,DiscordWebhookUrl} = (await this.metaService.fetch())
|
const {ApiBase,EmojiBotToken,DiscordWebhookUrl} = (await this.metaService.fetch())
|
||||||
const data_disc = {"username": "絵文字追加通知ちゃん",
|
|
||||||
'content':
|
|
||||||
'絵文字名 : :'+ ps.name +':\n' +
|
|
||||||
'カテゴリ : ' + ps.category + '\n'+
|
|
||||||
'ライセンス : '+ ps.license + '\n'+
|
|
||||||
'タグ : '+ps.aliases+ '\n'+
|
|
||||||
'追加したユーザー : ' + '@'+me.username + '\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (EmojiBotToken){
|
||||||
const data_Miss = {
|
const data_Miss = {
|
||||||
'i': EmojiBotToken,
|
'i': EmojiBotToken,
|
||||||
'text':
|
'text':
|
||||||
|
@ -90,7 +91,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
'タグ : ' + ps.aliases + '\n' +
|
'タグ : ' + ps.aliases + '\n' +
|
||||||
'追加したユーザー : ' + '@' + me.username + '\n'
|
'追加したユーザー : ' + '@' + me.username + '\n'
|
||||||
};
|
};
|
||||||
|
|
||||||
await fetch(ApiBase+'/notes/create', {
|
await fetch(ApiBase+'/notes/create', {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -98,7 +98,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
},
|
},
|
||||||
body:JSON.stringify( data_Miss)
|
body:JSON.stringify( data_Miss)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DiscordWebhookUrl){
|
||||||
|
const data_disc = {"username": "絵文字追加通知ちゃん",
|
||||||
|
'content':
|
||||||
|
'絵文字名 : :'+ ps.name +':\n' +
|
||||||
|
'カテゴリ : ' + ps.category + '\n'+
|
||||||
|
'ライセンス : '+ ps.license + '\n'+
|
||||||
|
'タグ : '+ps.aliases+ '\n'+
|
||||||
|
'追加したユーザー : ' + '@'+me.username + '\n'
|
||||||
|
}
|
||||||
await fetch(DiscordWebhookUrl, {
|
await fetch(DiscordWebhookUrl, {
|
||||||
'method':'post',
|
'method':'post',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -106,6 +116,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data_disc),
|
body: JSON.stringify(data_disc),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: emoji.id,
|
id: emoji.id,
|
||||||
|
|
Loading…
Reference in New Issue