Node.js based forum software built for the modern web
markRead fixes
barisusakli832a20e59e46
diff --git a/public/src/client/chats.js b/public/src/client/chats.jsindex 7f0f319f9f..984c3b4f55 100644--- a/public/src/client/chats.js+++ b/public/src/client/chats.js@@ -209,6 +209,10 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',});});+ tagEl.on('beforeItemRemove', function(event) {+ event.cancel = !ajaxify.data.owner;+ });+tagEl.on('itemRemoved', function(event) {socket.emit('modules.chats.removeUserFromRoom', {roomId: roomId, username: event.item});});diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.jsindex 63e324d1f5..5399d04d66 100644--- a/src/controllers/accounts/chats.js+++ b/src/controllers/accounts/chats.js@@ -46,7 +46,8 @@ chatsController.get = function(req, res, callback) {since: 'recent',isNew: false}),- allowed: async.apply(messaging.canMessageRoom, req.uid, req.params.roomid)+ allowed: async.apply(messaging.canMessageRoom, req.uid, req.params.roomid),+ owner: async.apply(messaging.isRoomOwner, req.uid, req.params.roomid)}, next);}], function(err, data) {@@ -58,21 +59,18 @@ chatsController.get = function(req, res, callback) {return user && parseInt(user.uid, 10) !== req.uid;});- var usernames = data.users.map(function(user) {+ data.usernames = data.users.map(function(user) {return user && user.username;}).join(', ');- res.render('chats', {- roomId: req.params.roomid,- rooms: recentChats.rooms,- nextStart: recentChats.nextStart,- users: data.users,- usernames: usernames,- messages: data.messages,- allowed: data.allowed,- title: '[[pages:chat, ' + usernames + ']]',- breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: usernames}])- });++ data.roomId = req.params.roomid;+ data.rooms = recentChats.rooms;+ data.nextStart = recentChats.nextStart;+ data.title = '[[pages:chat, ' + data.usernames + ']]';+ data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: data.usernames}]);++ res.render('chats', data);});});};diff --git a/src/messaging/create.js b/src/messaging/create.jsindex f9ccae958b..0309cab4b9 100644--- a/src/messaging/create.js+++ b/src/messaging/create.js@@ -69,12 +69,12 @@ module.exports = function(Messaging) {async.parallel([async.apply(Messaging.addRoomToUsers, roomId, uids, timestamp),async.apply(Messaging.addMessageToUsers, roomId, uids, mid, timestamp),- async.apply(Messaging.markRead, fromuid, roomId),async.apply(Messaging.markUnread, uids, roomId)], next);},function (results, next) {async.parallel({+ markRead: async.apply(Messaging.markRead, fromuid, roomId),messages: async.apply(Messaging.getMessagesData, [mid], fromuid, roomId, true),isNewSet: async.apply(Messaging.isNewSet, fromuid, roomId, mid)}, next);diff --git a/src/messaging/rooms.js b/src/messaging/rooms.jsindex 434a789508..092b5c85f2 100644--- a/src/messaging/rooms.js+++ b/src/messaging/rooms.js@@ -53,10 +53,10 @@ module.exports = function(Messaging) {Messaging.addUsersToRoom = function(uid, uids, roomId, callback) {async.waterfall([function (next) {- Messaging.isRoomOwner(uid, roomId, next);+ Messaging.isUserInRoom(uid, roomId, next);},- function (isOwner, next) {- if (!isOwner) {+ function (inRoom, next) {+ if (!inRoom) {return next(new Error('[[error:cant-add-users-to-chat-room]]'));}var now = Date.now();diff --git a/src/user/notifications.js b/src/user/notifications.jsindex 477a9cf53f..b670b42169 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -129,9 +129,7 @@ var async = require('async'),notification.path = pidToPaths[notification.pid] || notification.path || '';- if (notification.nid.startsWith('chat')) {- notification.path = '/chats/' + notification.user.userslug;- } else if (notification.nid.startsWith('follow')) {+ if (notification.nid.startsWith('follow')) {notification.path = '/user/' + notification.user.userslug;}