mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
markRead fixes
This commit is contained in:
@@ -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});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user