This commit is contained in:
mattyatea 2024-02-17 19:01:04 +09:00
parent dfa62088a5
commit 6734c38d24
1 changed files with 33 additions and 1 deletions

View File

@ -288,7 +288,6 @@ export class NoteCreateService implements OnApplicationShutdown {
} }
} }
console.log('matched', matchedString);
if (DiscordWebhookUrlWordBlock) { if (DiscordWebhookUrlWordBlock) {
const data_disc = { 'username': 'ノートブロックお知らせ', const data_disc = { 'username': 'ノートブロックお知らせ',
'content': 'content':
@ -386,7 +385,40 @@ export class NoteCreateService implements OnApplicationShutdown {
let tags = data.apHashtags; let tags = data.apHashtags;
let emojis = data.apEmojis; let emojis = data.apEmojis;
let mentionedUsers = data.apMentions; let mentionedUsers = data.apMentions;
let tmp:string | null = null;
if (mentionedUsers !== null && mentionedUsers !== undefined && mentionedUsers.length > 0) {
await Promise.all(mentionedUsers.map(async (u) => {
if (data.text != null) {
const regex = new RegExp(`@${u.username}@${u.host ?? this.config.host}`, 'g');
tmp = data.text.replace(regex, '');
}
}));
if ( tmp !== null && tmp.trim() === '') {
const { DiscordWebhookUrlWordBlock } = (await this.metaService.fetch());
if (DiscordWebhookUrlWordBlock) {
await fetch(DiscordWebhookUrlWordBlock, {
'method': 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'username': 'ノートブロックお知らせ',
'content':
'ユーザー名 :' + user.username + '\n' +
'url : ' + user.host + '\n' +
'contents : ' + data.text + '\n' +
'引っかかった原因 メンションしかない',
'allowed_mentions': {
'parse': [],
},
}),
});
}
console.log('メンションしかない');
throw new NoteCreateService.ContainsProhibitedWordsError();
}
}
// Parse MFM if needed // Parse MFM if needed
if (!tags || !emojis || !mentionedUsers) { if (!tags || !emojis || !mentionedUsers) {
const tokens = (data.text ? mfm.parse(data.text)! : []); const tokens = (data.text ? mfm.parse(data.text)! : []);