소스 검색

Remove duplicate mentions

sbkwgh 8 년 전
부모
커밋
fc16b8257a
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      routes/post.js

+ 6 - 2
routes/post.js

@@ -170,8 +170,12 @@ router.post('/', async (req, res) => {
 		await thread.increment('postsCount')
 
 		if(req.body.mentions) {
-			for(var i = 0; i < req.body.mentions.length; i++) {
-				let mention = req.body.mentions[i]
+			let uniqueMentions = req.body.mentions.filter((mention, pos, self) => {
+				return self.indexOf(mention) === pos
+			})
+
+			for(var i = 0; i < uniqueMentions.length; i++) {
+				let mention = uniqueMentions[i]
 				let ioUsers = req.app.get('io-users')
 
 				let mentionNotification = await Notification.createPostNotification({