This commit is contained in:
parent
9e1d276bbd
commit
9c905f84e8
|
@ -265,17 +265,43 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
}
|
||||
|
||||
if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) {
|
||||
const { DiscordWebhookUrl } = (await this.metaService.fetch());
|
||||
const { DiscordWebhookUrlWordBlock } = (await this.metaService.fetch());
|
||||
const regexpregexp = /^\/(.+)\/(.*)$/;
|
||||
let matchedString = '';
|
||||
for (const filter of meta.prohibitedWords) {
|
||||
// represents RegExp
|
||||
const regexp = filter.match(regexpregexp);
|
||||
// This should never happen due to input sanitisation.
|
||||
if (!regexp) {
|
||||
const words = filter.split(' ');
|
||||
const foundWord = words.find(keyword => (data.cw ?? data.text ?? '').includes(keyword));
|
||||
if (foundWord) {
|
||||
matchedString = foundWord;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
const match = new RE2(regexp[1], regexp[2]).exec(data.cw ?? data.text ?? '');
|
||||
if (match) {
|
||||
matchedString = match[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DiscordWebhookUrl) {
|
||||
console.log('matched', matchedString);
|
||||
if (DiscordWebhookUrlWordBlock) {
|
||||
const data_disc = { 'username': 'ノートブロックお知らせ',
|
||||
'content':
|
||||
'ユーザー名 :' + user.username + '\n' +
|
||||
'url : ' + user.host + '\n' +
|
||||
'contents : ' + data.text,
|
||||
'contents : ' + data.text + '\n' +
|
||||
'引っかかったワード :' + matchedString,
|
||||
'allowed_mentions': {
|
||||
'parse': [],
|
||||
},
|
||||
};
|
||||
|
||||
await fetch(DiscordWebhookUrl, {
|
||||
await fetch(DiscordWebhookUrlWordBlock, {
|
||||
'method': 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -229,6 +229,13 @@ export class MiMeta {
|
|||
nullable: true,
|
||||
})
|
||||
public DiscordWebhookUrl: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
nullable: true,
|
||||
})
|
||||
public DiscordWebhookUrlWordBlock: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
nullable: true,
|
||||
|
|
|
@ -458,6 +458,9 @@ export const meta = {
|
|||
DiscordWebhookUrl: {
|
||||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
}, DiscordWebhookUrlWordBlock: {
|
||||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
},
|
||||
enableProxyCheckio: {
|
||||
type: 'boolean',
|
||||
|
@ -595,6 +598,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
|
||||
notesPerOneAd: instance.notesPerOneAd,
|
||||
DiscordWebhookUrl: instance.DiscordWebhookUrl,
|
||||
DiscordWebhookUrlWordBlock: instance.DiscordWebhookUrlWordBlock,
|
||||
EmojiBotToken: instance.EmojiBotToken,
|
||||
ApiBase: instance.ApiBase,
|
||||
enableGDPRMode: instance.enableGDPRMode,
|
||||
|
|
|
@ -92,6 +92,7 @@ export const paramDef = {
|
|||
},
|
||||
summalyProxy: { type: 'string', nullable: true },
|
||||
DiscordWebhookUrl: { type: 'string', nullable: true },
|
||||
DiscordWebhookUrlWordBlock: { type: 'string', nullable: true },
|
||||
deeplAuthKey: { type: 'string', nullable: true },
|
||||
deeplIsPro: { type: 'boolean' },
|
||||
enableEmail: { type: 'boolean' },
|
||||
|
@ -210,6 +211,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (ps.DiscordWebhookUrl !== undefined) {
|
||||
set.DiscordWebhookUrl = ps.DiscordWebhookUrl;
|
||||
}
|
||||
if (ps.DiscordWebhookUrlWordBlock !== undefined) {
|
||||
set.DiscordWebhookUrlWordBlock = ps.DiscordWebhookUrlWordBlock;
|
||||
}
|
||||
if (ps.EmojiBotToken !== undefined) {
|
||||
set.EmojiBotToken = ps.EmojiBotToken;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ const clientAssets = `${_dirname}/../../../../frontend/assets/`;
|
|||
const assets = `${_dirname}/../../../../../built/_frontend_dist_/`;
|
||||
const swAssets = `${_dirname}/../../../../../built/_sw_dist_/`;
|
||||
const viteOut = `${_dirname}/../../../../../built/_vite_/`;
|
||||
const tarball = `${_dirname}/../../../../../built/tarball/`;
|
||||
|
||||
@Injectable()
|
||||
export class ClientServerService {
|
||||
|
@ -309,18 +308,6 @@ export class ClientServerService {
|
|||
decorateReply: false,
|
||||
});
|
||||
|
||||
fastify.register((fastify, options, done) => {
|
||||
fastify.register(fastifyStatic, {
|
||||
root: tarball,
|
||||
prefix: '/tarball/',
|
||||
maxAge: ms('30 days'),
|
||||
immutable: true,
|
||||
decorateReply: false,
|
||||
});
|
||||
fastify.addHook('onRequest', handleRequestRedirectToOmitSearch);
|
||||
done();
|
||||
});
|
||||
|
||||
fastify.get('/favicon.ico', async (request, reply) => {
|
||||
return reply.sendFile('/favicon.ico', staticAssets);
|
||||
});
|
||||
|
|
|
@ -87,7 +87,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<FormLink :to="`/.well-known/nodeinfo`" external>nodeinfo</FormLink>
|
||||
<FormLink :to="`/robots.txt`" external>robots.txt</FormLink>
|
||||
<FormLink :to="`/manifest.json`" external>manifest.json</FormLink>
|
||||
<FormLink :to="`/tarball/misskey-${version}.tar.gz`" external>source code</FormLink>
|
||||
</div>
|
||||
</FormSection>
|
||||
</div>
|
||||
|
|
|
@ -36,21 +36,25 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template>
|
||||
</MkSwitch>
|
||||
</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>
|
||||
<MkSwitch v-model="requestEmojiAllOk">
|
||||
絵文字の申請全部許可
|
||||
</MkSwitch>
|
||||
<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="DiscordWebhookUrlWordBlock" type="password">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>Discord Webhook Url WordBlock</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>
|
||||
<MkSwitch v-model="requestEmojiAllOk">
|
||||
絵文字の申請全部許可
|
||||
</MkSwitch>
|
||||
</div>
|
||||
</FormSuspense>
|
||||
</MkSpacer>
|
||||
|
@ -67,26 +71,29 @@ import { fetchInstance } from '@/instance.js';
|
|||
import { i18n } from '@/i18n.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import MkSwitch from '@/components/MkSwitch.vue';
|
||||
import MkInput from "@/components/MkInput.vue";
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
|
||||
const enableServerMachineStats = ref<boolean>(false);
|
||||
const enableIdenticonGeneration = ref<boolean>(false);
|
||||
const enableChartsForRemoteUser = ref<boolean>(false);
|
||||
const enableChartsForFederatedInstances = ref<boolean>(false);
|
||||
const requestEmojiAllOk = ref(false)
|
||||
const requestEmojiAllOk = ref(false);
|
||||
let DiscordWebhookUrl = ref(null);
|
||||
let EmojiBotToken= ref(null);
|
||||
let ApiBase= ref(null)
|
||||
let DiscordWebhookUrlWordBlock = ref(null);
|
||||
let EmojiBotToken = ref(null);
|
||||
let ApiBase = ref(null);
|
||||
|
||||
async function init() {
|
||||
const meta = await misskeyApi('admin/meta');
|
||||
enableServerMachineStats.value = meta.enableServerMachineStats;
|
||||
enableIdenticonGeneration.value = meta.enableIdenticonGeneration;
|
||||
enableChartsForRemoteUser.value = meta.enableChartsForRemoteUser;
|
||||
enableChartsForFederatedInstances.value = meta.enableChartsForFederatedInstances;
|
||||
requestEmojiAllOk.value = meta.requestEmojiAllOk;
|
||||
DiscordWebhookUrl.value = meta.DiscordWebhookUrl;
|
||||
EmojiBotToken.value = meta.EmojiBotToken;
|
||||
ApiBase.value = meta.ApiBase;
|
||||
requestEmojiAllOk.value = meta.requestEmojiAllOk;
|
||||
DiscordWebhookUrl.value = meta.DiscordWebhookUrl;
|
||||
DiscordWebhookUrlWordBlock.value = meta.DiscordWebhookUrlWordBlock;
|
||||
EmojiBotToken.value = meta.EmojiBotToken;
|
||||
ApiBase.value = meta.ApiBase;
|
||||
}
|
||||
|
||||
function save() {
|
||||
|
@ -94,11 +101,12 @@ function save() {
|
|||
enableServerMachineStats: enableServerMachineStats.value,
|
||||
enableIdenticonGeneration: enableIdenticonGeneration.value,
|
||||
enableChartsForRemoteUser: enableChartsForRemoteUser.value,
|
||||
requestEmojiAllOk: requestEmojiAllOk.value,
|
||||
requestEmojiAllOk: requestEmojiAllOk.value,
|
||||
enableChartsForFederatedInstances: enableChartsForFederatedInstances.value,
|
||||
DiscordWebhookUrl:DiscordWebhookUrl.value,
|
||||
EmojiBotToken:EmojiBotToken.value,
|
||||
ApiBase:ApiBase.value
|
||||
DiscordWebhookUrl: DiscordWebhookUrl.value,
|
||||
EmojiBotToken: EmojiBotToken.value,
|
||||
ApiBase: ApiBase.value,
|
||||
DiscordWebhookUrlWordBlock: DiscordWebhookUrlWordBlock.value,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue