markRead fixes

v1.18.x
barisusakli 9 years ago
parent 1bd9b364e4
commit 832a20e59e

@ -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) { tagEl.on('itemRemoved', function(event) {
socket.emit('modules.chats.removeUserFromRoom', {roomId: roomId, username: event.item}); socket.emit('modules.chats.removeUserFromRoom', {roomId: roomId, username: event.item});
}); });

@ -46,7 +46,8 @@ chatsController.get = function(req, res, callback) {
since: 'recent', since: 'recent',
isNew: false 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); }, next);
} }
], function(err, data) { ], function(err, data) {
@ -58,21 +59,18 @@ chatsController.get = function(req, res, callback) {
return user && parseInt(user.uid, 10) !== req.uid; 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; return user && user.username;
}).join(', '); }).join(', ');
res.render('chats', {
roomId: req.params.roomid, data.roomId = req.params.roomid;
rooms: recentChats.rooms, data.rooms = recentChats.rooms;
nextStart: recentChats.nextStart, data.nextStart = recentChats.nextStart;
users: data.users, data.title = '[[pages:chat, ' + data.usernames + ']]';
usernames: usernames, data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: data.usernames}]);
messages: data.messages,
allowed: data.allowed, res.render('chats', data);
title: '[[pages:chat, ' + usernames + ']]',
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: usernames}])
});
}); });
}); });
}; };

@ -69,12 +69,12 @@ module.exports = function(Messaging) {
async.parallel([ async.parallel([
async.apply(Messaging.addRoomToUsers, roomId, uids, timestamp), async.apply(Messaging.addRoomToUsers, roomId, uids, timestamp),
async.apply(Messaging.addMessageToUsers, roomId, uids, mid, timestamp), async.apply(Messaging.addMessageToUsers, roomId, uids, mid, timestamp),
async.apply(Messaging.markRead, fromuid, roomId),
async.apply(Messaging.markUnread, uids, roomId) async.apply(Messaging.markUnread, uids, roomId)
], next); ], next);
}, },
function (results, next) { function (results, next) {
async.parallel({ async.parallel({
markRead: async.apply(Messaging.markRead, fromuid, roomId),
messages: async.apply(Messaging.getMessagesData, [mid], fromuid, roomId, true), messages: async.apply(Messaging.getMessagesData, [mid], fromuid, roomId, true),
isNewSet: async.apply(Messaging.isNewSet, fromuid, roomId, mid) isNewSet: async.apply(Messaging.isNewSet, fromuid, roomId, mid)
}, next); }, next);

@ -53,10 +53,10 @@ module.exports = function(Messaging) {
Messaging.addUsersToRoom = function(uid, uids, roomId, callback) { Messaging.addUsersToRoom = function(uid, uids, roomId, callback) {
async.waterfall([ async.waterfall([
function (next) { function (next) {
Messaging.isRoomOwner(uid, roomId, next); Messaging.isUserInRoom(uid, roomId, next);
}, },
function (isOwner, next) { function (inRoom, next) {
if (!isOwner) { if (!inRoom) {
return next(new Error('[[error:cant-add-users-to-chat-room]]')); return next(new Error('[[error:cant-add-users-to-chat-room]]'));
} }
var now = Date.now(); var now = Date.now();

@ -129,9 +129,7 @@ var async = require('async'),
notification.path = pidToPaths[notification.pid] || notification.path || ''; notification.path = pidToPaths[notification.pid] || notification.path || '';
if (notification.nid.startsWith('chat')) { if (notification.nid.startsWith('follow')) {
notification.path = '/chats/' + notification.user.userslug;
} else if (notification.nid.startsWith('follow')) {
notification.path = '/user/' + notification.user.userslug; notification.path = '/user/' + notification.user.userslug;
} }

Loading…
Cancel
Save