This commit is contained in:
mattyatea 2023-10-19 01:16:11 +09:00
parent a8c19c624a
commit 4f6b0ccf6b
9 changed files with 132 additions and 6 deletions

View File

@ -0,0 +1,11 @@
export class DiscordWebhookUrl1697641012204 {
name = 'DiscordWebhookUrl1697641012204'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "DiscordWebhookUrl" character varying(1024)`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "DiscordWebhookUrl"`);
}
}

View File

@ -0,0 +1,11 @@
export class EmojiBotToken1697642704514 {
name = 'EmojiBotToken1697642704514'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "EmojiBotToken" character varying(1024)`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "EmojiBotToken"`);
}
}

View File

@ -0,0 +1,15 @@
export class BaseUrl1697645425687 {
name = 'BaseUrl1697645425687'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "ApiBase" character varying(1024)`);
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "preservedUsernames" SET DEFAULT '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }'`);
await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" SET NOT NULL`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "preservedUsernames" SET DEFAULT '{admin,administrator,root,system,maintainer,host,mod,moderator,owner,superuser,staff,auth,i,me,everyone,all,mention,mentions,example,user,users,account,accounts,official,help,helps,support,supports,info,information,informations,announce,announces,announcement,announcements,notice,notification,notifications,dev,developer,developers,tech,misskey}'`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "ApiBase"`);
}
}

View File

@ -196,11 +196,26 @@ export class MiMeta {
}) })
public enableRecaptcha: boolean; public enableRecaptcha: boolean;
@Column('varchar', {
length: 1024,
nullable: true,
})
public DiscordWebhookUrl: string | null;
@Column('varchar', {
length: 1024,
nullable: true,
})
public EmojiBotToken: string | null;
@Column('varchar', { @Column('varchar', {
length: 1024, length: 1024,
nullable: true, nullable: true,
}) })
public recaptchaSiteKey: string | null; public recaptchaSiteKey: string | null;
@Column('varchar', {
length: 1024,
nullable: true,
})
public ApiBase: string | null;
@Column('varchar', { @Column('varchar', {
length: 1024, length: 1024,

View File

@ -5,7 +5,7 @@ import { DI } from '@/di-symbols.js';
import { CustomEmojiService } from '@/core/CustomEmojiService.js'; 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';
export const meta = { export const meta = {
tags: ['admin'], tags: ['admin'],
@ -46,12 +46,12 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
@Injectable() @Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor( constructor(
@Inject(DI.driveFilesRepository) @Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository, private driveFilesRepository: DriveFilesRepository,
private metaService: MetaService,
private customEmojiService: CustomEmojiService, private customEmojiService: CustomEmojiService,
private moderationLogService: ModerationLogService, private moderationLogService: ModerationLogService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
@ -71,6 +71,41 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
localOnly: ps.localOnly ?? false, localOnly: ps.localOnly ?? false,
roleIdsThatCanBeUsedThisEmojiAsReaction: [], roleIdsThatCanBeUsedThisEmojiAsReaction: [],
}); });
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'
}
const data_Miss = {
'i': EmojiBotToken,
'text':
'絵文字名 : :' + ps.name + ':\n' +
'カテゴリ : ' + ps.category + '\n' +
'ライセンス : ' + ps.license + '\n' +
'タグ : ' + ps.aliases + '\n' +
'追加したユーザー : ' + '@' + me.username + '\n'
};
await fetch(ApiBase+'/notes/create', {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body:JSON.stringify( data_Miss)
})
await fetch(DiscordWebhookUrl, {
'method':'post',
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data_disc),
})
return { return {
id: emoji.id, id: emoji.id,

View File

@ -311,6 +311,10 @@ export const meta = {
type: 'number', type: 'number',
optional: false, nullable: false, optional: false, nullable: false,
}, },
DiscordWebhookUrl: {
type: 'string',
optional: false, nullable: true,
},
}, },
}, },
} as const; } as const;
@ -424,6 +428,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax, perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax, perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
notesPerOneAd: instance.notesPerOneAd, notesPerOneAd: instance.notesPerOneAd,
DiscordWebhookUrl: instance.DiscordWebhookUrl,
EmojiBotToken: instance.EmojiBotToken,
ApiBase: instance.ApiBase
}; };
}); });
} }

View File

@ -81,6 +81,7 @@ export const paramDef = {
}, },
}, },
summalyProxy: { type: 'string', nullable: true }, summalyProxy: { type: 'string', nullable: true },
DiscordWebhookUrl:{ type: 'string', nullable: true},
deeplAuthKey: { type: 'string', nullable: true }, deeplAuthKey: { type: 'string', nullable: true },
deeplIsPro: { type: 'boolean' }, deeplIsPro: { type: 'boolean' },
enableEmail: { type: 'boolean' }, enableEmail: { type: 'boolean' },
@ -132,6 +133,8 @@ export const paramDef = {
type: 'string', type: 'string',
}, },
}, },
EmojiBotToken:{ type: 'string', nullable: true},
ApiBase:{ type: 'string',nullable:true}
}, },
required: [], required: [],
} as const; } as const;
@ -175,7 +178,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.themeColor !== undefined) { if (ps.themeColor !== undefined) {
set.themeColor = ps.themeColor; set.themeColor = ps.themeColor;
} }
if (ps.DiscordWebhookUrl !== undefined){
set.DiscordWebhookUrl = ps.DiscordWebhookUrl
}
if (ps.EmojiBotToken !== undefined){
set.EmojiBotToken = ps.EmojiBotToken
}
if (ps.ApiBase !== undefined){
set.ApiBase = ps.ApiBase
}
if (ps.mascotImageUrl !== undefined) { if (ps.mascotImageUrl !== undefined) {
set.mascotImageUrl = ps.mascotImageUrl; set.mascotImageUrl = ps.mascotImageUrl;
} }

View File

@ -181,7 +181,7 @@ watch(q, () => {
const searchCustom = () => { const searchCustom = () => {
const max = 100; const max = 100;
const emojis = customEmojis.value.filter(emoji => !emoji.draft);; const emojis = customEmojis.value.filter(emoji => !emoji.draft);
const matches = new Set<Misskey.entities.CustomEmoji>(); const matches = new Set<Misskey.entities.CustomEmoji>();
const exactMatch = emojis.find(emoji => emoji.name === newQ); const exactMatch = emojis.find(emoji => emoji.name === newQ);

View File

@ -36,6 +36,18 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template> <template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template>
</MkSwitch> </MkSwitch>
</div> </div>
<MkInput v-model="DiscordWebhookUrl" type="password">
<template #prefix><i class="ti ti-key"></i></template>
<template #label>Discord Webhook URL</template>
</MkInput>
<MkInput v-model="EmojiBotToken" type="password">
<template #prefix><i class="ti ti-key"></i></template>
<template #label>EmojiBotToken</template>
</MkInput>
<MkInput v-model="ApiBase">
<template #prefix><i class="ti ti-key"></i></template>
<template #label>ApiBase</template>
</MkInput>
</div> </div>
</FormSuspense> </FormSuspense>
</MkSpacer> </MkSpacer>
@ -51,18 +63,24 @@ import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js'; import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import MkInput from "@/components/MkInput.vue";
let enableServerMachineStats: boolean = $ref(false); let enableServerMachineStats: boolean = $ref(false);
let enableIdenticonGeneration: boolean = $ref(false); let enableIdenticonGeneration: boolean = $ref(false);
let enableChartsForRemoteUser: boolean = $ref(false); let enableChartsForRemoteUser: boolean = $ref(false);
let enableChartsForFederatedInstances: boolean = $ref(false); let enableChartsForFederatedInstances: boolean = $ref(false);
let DiscordWebhookUrl: string | null = $ref(null);
let EmojiBotToken: string | null = $ref(null);
let ApiBase:string | null = $ref(null)
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await os.api('admin/meta');
enableServerMachineStats = meta.enableServerMachineStats; enableServerMachineStats = meta.enableServerMachineStats;
enableIdenticonGeneration = meta.enableIdenticonGeneration; enableIdenticonGeneration = meta.enableIdenticonGeneration;
enableChartsForRemoteUser = meta.enableChartsForRemoteUser; enableChartsForRemoteUser = meta.enableChartsForRemoteUser;
enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances; enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances;
DiscordWebhookUrl = meta.DiscordWebhookUrl;
EmojiBotToken = meta.EmojiBotToken;
ApiBase = meta.ApiBase;
} }
function save() { function save() {
@ -71,6 +89,9 @@ function save() {
enableIdenticonGeneration, enableIdenticonGeneration,
enableChartsForRemoteUser, enableChartsForRemoteUser,
enableChartsForFederatedInstances, enableChartsForFederatedInstances,
DiscordWebhookUrl,
EmojiBotToken,
ApiBase
}).then(() => { }).then(() => {
fetchInstance(); fetchInstance();
}); });