summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:43:56 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:43:56 +0900
commitf93bc3a8ec7eae63330193bc87c5b1437bf874ed (patch)
treea494c49dc30547681160becdc55447372e3ec43a /src
parentwip (diff)
downloadsharkey-f93bc3a8ec7eae63330193bc87c5b1437bf874ed.tar.gz
sharkey-f93bc3a8ec7eae63330193bc87c5b1437bf874ed.tar.bz2
sharkey-f93bc3a8ec7eae63330193bc87c5b1437bf874ed.zip
wip
Diffstat (limited to 'src')
-rw-r--r--src/api/common/notify.ts2
-rw-r--r--src/api/endpoints/posts/create.ts14
2 files changed, 12 insertions, 4 deletions
diff --git a/src/api/common/notify.ts b/src/api/common/notify.ts
index f06622f912..2b79416a30 100644
--- a/src/api/common/notify.ts
+++ b/src/api/common/notify.ts
@@ -39,7 +39,7 @@ export default (
deleted_at: { $exists: false }
});
const mutedUserIds = mute.map(m => m.mutee_id.toString());
- if (mutedUserIds.indexOf(notifier.toHexString()) != -1) {
+ if (mutedUserIds.indexOf(notifier.toString()) != -1) {
return;
}
//#endregion
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index 9d791538fe..a1d05c67c6 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -8,6 +8,7 @@ import { default as Post, IPost, isValidText } from '../../models/post';
import { default as User, IUser } from '../../models/user';
import { default as Channel, IChannel } from '../../models/channel';
import Following from '../../models/following';
+import Mute from '../../models/mute';
import DriveFile from '../../models/drive-file';
import Watching from '../../models/post-watching';
import ChannelWatching from '../../models/channel-watching';
@@ -240,7 +241,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
const mentions = [];
- function addMention(mentionee, reason) {
+ async function addMention(mentionee, reason) {
// Reject if already added
if (mentions.some(x => x.equals(mentionee))) return;
@@ -249,8 +250,15 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
// Publish event
if (!user._id.equals(mentionee)) {
- event(mentionee, reason, postObj);
- pushSw(mentionee, reason, postObj);
+ const mentioneeMutes = await Mute.find({
+ muter_id: mentionee,
+ deleted_at: { $exists: false }
+ });
+ const mentioneesMutedUserIds = mentioneeMutes.map(m => m.mutee_id.toString());
+ if (mentioneesMutedUserIds.indexOf(user._id.toString()) == -1) {
+ event(mentionee, reason, postObj);
+ pushSw(mentionee, reason, postObj);
+ }
}
}