summaryrefslogtreecommitdiff
path: root/src/services/note
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-07-27 13:34:20 +0900
committerGitHub <noreply@github.com>2020-07-27 13:34:20 +0900
commitcf43dd6ec530ba4a3f589ae917e89533b352f6a3 (patch)
tree76f35d06299b40370ec061ee5ed58182847d2e6e /src/services/note
parentrefactor(client): Do not mutate prop directly (diff)
downloadsharkey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.tar.gz
sharkey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.tar.bz2
sharkey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.zip
ワードミュート (#6594)
* wip * wip * wip * wip * wip * wip * wip * wip * wip
Diffstat (limited to 'src/services/note')
-rw-r--r--src/services/note/create.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 7b5e6a92ba..44ec5fda6f 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -17,7 +17,7 @@ import extractMentions from '../../misc/extract-mentions';
import extractEmojis from '../../misc/extract-emojis';
import extractHashtags from '../../misc/extract-hashtags';
import { Note, IMentionedRemoteUsers } from '../../models/entities/note';
-import { Mutings, Users, NoteWatchings, Notes, Instances, UserProfiles, Antennas, Followings } from '../../models';
+import { Mutings, Users, NoteWatchings, Notes, Instances, UserProfiles, Antennas, Followings, MutedNotes } from '../../models';
import { DriveFile } from '../../models/entities/drive-file';
import { App } from '../../models/entities/app';
import { Not, getConnection, In } from 'typeorm';
@@ -29,6 +29,7 @@ import { createNotification } from '../create-notification';
import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-error';
import { ensure } from '../../prelude/ensure';
import { checkHitAntenna } from '../../misc/check-hit-antenna';
+import { checkWordMute } from '../../misc/check-word-mute';
import { addNoteToAntenna } from '../add-note-to-antenna';
import { countSameRenotes } from '../../misc/count-same-renotes';
import { deliverToRelays } from '../relay';
@@ -219,6 +220,24 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
// Increment notes count (user)
incNotesCountOfUser(user);
+ // Word mute
+ UserProfiles.find({
+ enableWordMute: true
+ }).then(us => {
+ for (const u of us) {
+ checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
+ if (shouldMute) {
+ MutedNotes.save({
+ id: genId(),
+ userId: u.userId,
+ noteId: note.id,
+ reason: 'word',
+ });
+ }
+ });
+ }
+ });
+
// Antenna
Antennas.find().then(async antennas => {
const followings = await Followings.createQueryBuilder('following')