Files
NodeBB/src/messaging.js

430 lines
12 KiB
JavaScript
Raw Normal View History

2014-03-08 15:45:42 -05:00
'use strict';
2015-12-15 17:50:30 +02:00
var async = require('async'),
2014-07-25 16:46:04 -04:00
winston = require('winston'),
2015-09-16 15:44:10 -04:00
S = require('string'),
2015-12-15 17:50:30 +02:00
nconf = require('nconf'),
2015-09-16 15:44:10 -04:00
2015-12-15 17:50:30 +02:00
db = require('./database'),
2013-12-27 14:09:22 -05:00
user = require('./user'),
plugins = require('./plugins'),
2014-07-25 16:46:04 -04:00
meta = require('./meta'),
2015-12-15 17:50:30 +02:00
emailer = require('./emailer'),
2014-08-08 15:28:39 -04:00
utils = require('../public/src/utils'),
2014-07-25 16:46:04 -04:00
notifications = require('./notifications'),
userNotifications = require('./user/notifications'),
sockets = require('./socket.io');
2013-08-26 13:18:20 -04:00
(function(Messaging) {
2015-12-15 14:10:32 +02:00
2015-12-15 17:50:30 +02:00
require('./messaging/create')(Messaging);
require('./messaging/delete')(Messaging);
require('./messaging/edit')(Messaging);
require('./messaging/rooms')(Messaging);
require('./messaging/unread')(Messaging);
2015-12-15 14:10:32 +02:00
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
2013-08-26 13:18:20 -04:00
var terms = {
day: 86400000,
week: 604800000,
month: 2592000000,
threemonths: 7776000000
};
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
Messaging.getMessageField = function(mid, field, callback) {
Messaging.getMessageFields(mid, [field], function(err, fields) {
2015-12-15 17:50:30 +02:00
callback(err, fields ? fields[field] : null);
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
});
};
Messaging.getMessageFields = function(mid, fields, callback) {
db.getObjectFields('message:' + mid, fields, callback);
};
Messaging.setMessageField = function(mid, field, content, callback) {
db.setObjectField('message:' + mid, field, content, callback);
};
Messaging.setMessageFields = function(mid, data, callback) {
db.setObject('message:' + mid, data, callback);
};
Messaging.getMessages = function(params, callback) {
2015-12-15 17:50:30 +02:00
var uid = params.uid,
roomId = params.roomId,
since = params.since,
isNew = params.isNew,
count = params.count || parseInt(meta.config.chatMessageInboxSize, 10) || 250,
markRead = params.markRead || true;
2015-12-15 17:50:30 +02:00
var min = params.count ? 0 : Date.now() - (terms[since] || terms.day);
2013-08-26 13:18:20 -04:00
if (since === 'recent') {
count = 49;
min = 0;
}
2015-12-15 17:50:30 +02:00
db.getSortedSetRevRangeByScore('uid:' + uid + ':chat:room:' + roomId + ':mids', 0, count, '+inf', min, function(err, mids) {
2013-12-02 21:20:55 -05:00
if (err) {
2014-03-28 12:13:01 -04:00
return callback(err);
2013-12-02 21:20:55 -05:00
}
2013-08-26 13:18:20 -04:00
if (!Array.isArray(mids) || !mids.length) {
2013-08-26 13:18:20 -04:00
return callback(null, []);
}
2014-07-29 17:12:02 -04:00
mids.reverse();
2015-12-15 17:50:30 +02:00
Messaging.getMessagesData(mids, uid, roomId, isNew, callback);
2014-03-28 12:13:01 -04:00
});
2014-07-25 16:46:04 -04:00
if (markRead) {
2015-12-15 17:50:30 +02:00
notifications.markRead('chat_' + roomId + '_' + uid, uid, function(err) {
if (err) {
winston.error('[messaging] Could not mark notifications related to this chat as read: ' + err.message);
}
2014-07-25 16:46:04 -04:00
2015-12-15 17:50:30 +02:00
userNotifications.pushCount(uid);
});
}
2014-03-28 12:13:01 -04:00
};
2013-08-26 13:18:20 -04:00
2015-12-15 17:50:30 +02:00
Messaging.getMessagesData = function(mids, uid, roomId, isNew, callback) {
2015-12-15 17:50:30 +02:00
var keys = mids.map(function(mid) {
return 'message:' + mid;
});
2013-08-26 13:18:20 -04:00
2015-12-15 17:50:30 +02:00
var messages;
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
2015-12-15 17:50:30 +02:00
async.waterfall([
function (next) {
db.getObjects(keys, next);
},
function (_messages, next) {
messages = _messages.map(function(msg, idx) {
if (msg) {
msg.messageId = parseInt(mids[idx], 10);
}
return msg;
}).filter(Boolean);
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
2015-12-15 17:50:30 +02:00
var uids = messages.map(function(msg) {
return msg && msg.fromuid;
});
2014-07-24 22:04:33 -04:00
2015-12-15 17:50:30 +02:00
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], next);
},
function (users, next) {
messages.forEach(function(message, index) {
message.fromUser = users[index];
var self = parseInt(message.fromuid, 10) === parseInt(uid, 10);
message.self = self ? 1 : 0;
message.timestampISO = utils.toISOString(message.timestamp);
message.newSet = false;
if (message.hasOwnProperty('edited')) {
message.editedISO = new Date(parseInt(message.edited, 10)).toISOString();
}
});
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
2015-12-15 17:50:30 +02:00
async.map(messages, function(message, next) {
Messaging.parse(message.content, message.fromuid, uid, roomId, isNew, function(result) {
message.content = result;
message.cleanedContent = S(result).stripTags().decodeHTMLEntities().s;
next(null, message);
});
}, next);
},
function(messages, next) {
if (messages.length > 1) {
// Add a spacer in between messages with time gaps between them
messages = messages.map(function(message, index) {
// Compare timestamps with the previous message, and check if a spacer needs to be added
if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index-1].timestamp, 10) + (1000*60*5)) {
// If it's been 5 minutes, this is a new set of messages
message.newSet = true;
} else if (index > 0 && message.fromuid !== messages[index-1].fromuid) {
// If the previous message was from the other person, this is also a new set
message.newSet = true;
}
return message;
});
next(undefined, messages);
} else {
// For single messages, we don't know the context, so look up the previous message and compare
var key = 'uid:' + uid + ':chat:room:' + roomId + ':mids';
async.waterfall([
async.apply(db.sortedSetRank, key, messages[0].messageId),
function(index, next) {
// Continue only if this isn't the first message in sorted set
if (index > 0) {
db.getSortedSetRange(key, index-1, index-1, next);
} else {
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
messages[0].newSet = true;
2015-12-15 17:50:30 +02:00
return next(undefined, messages);
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
}
2015-12-15 17:50:30 +02:00
},
function(mid, next) {
Messaging.getMessageFields(mid, ['fromuid', 'timestamp'], next);
}
], function(err, fields) {
if (err) {
return next(err);
}
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
2015-12-15 17:50:30 +02:00
if (
(parseInt(messages[0].timestamp, 10) > parseInt(fields.timestamp, 10) + (1000*60*5)) ||
(parseInt(messages[0].fromuid, 10) !== parseInt(fields.fromuid, 10))
) {
// If it's been 5 minutes, this is a new set of messages
messages[0].newSet = true;
}
next(undefined, messages);
});
2014-07-24 22:04:33 -04:00
}
2015-12-15 17:50:30 +02:00
}
], callback);
2015-12-15 14:10:32 +02:00
};
2013-08-26 13:18:20 -04:00
2015-12-15 17:50:30 +02:00
Messaging.parse = function (message, fromuid, uid, roomId, isNew, callback) {
plugins.fireHook('filter:parse.raw', message, function(err, parsed) {
2014-01-18 15:35:51 -05:00
if (err) {
return callback(message);
}
2014-01-26 16:50:59 -05:00
var messageData = {
message: message,
parsed: parsed,
fromuid: fromuid,
2015-12-15 17:50:30 +02:00
uid: uid,
roomId: roomId,
isNew: isNew,
2014-03-28 12:13:01 -04:00
parsedMessage: parsed
2014-01-26 16:50:59 -05:00
};
plugins.fireHook('filter:messaging.parse', messageData, function(err, messageData) {
callback(messageData.parsedMessage);
});
2014-01-18 15:35:51 -05:00
});
};
2014-01-15 18:20:05 +01:00
2015-12-15 17:50:30 +02:00
Messaging.isNewSet = function(uid, roomId, mid, callback) {
var setKey = 'uid:' + uid + ':chat:room:' + roomId + ':mids';
2014-07-25 15:37:46 -04:00
async.waterfall([
async.apply(db.sortedSetRank, setKey, mid),
function(index, next) {
if (index > 0) {
2015-12-15 17:50:30 +02:00
db.getSortedSetRange(setKey, index - 1, index, next);
2014-07-25 15:37:46 -04:00
} else {
next(null, true);
}
},
function(mids, next) {
if (typeof mids !== 'boolean' && mids && mids.length) {
2014-08-12 09:17:41 -04:00
db.getObjects(['message:' + mids[0], 'message:' + mids[1]], next);
} else {
next(null, mids);
}
2014-07-25 15:37:46 -04:00
},
function(messages, next) {
if (typeof messages !== 'boolean' && messages && messages.length) {
2014-07-25 15:37:46 -04:00
next(null, parseInt(messages[1].timestamp, 10) > parseInt(messages[0].timestamp, 10) + (1000*60*5));
} else {
next(null, messages);
}
}
], callback);
};
Messaging.getRecentChats = function(uid, start, stop, callback) {
2015-12-15 17:50:30 +02:00
db.getSortedSetRevRange('uid:' + uid + ':chat:rooms', start, stop, function(err, roomIds) {
if (err) {
2013-12-27 14:09:22 -05:00
return callback(err);
}
2013-12-27 14:09:22 -05:00
2014-09-15 16:26:25 -04:00
async.parallel({
unread: function(next) {
2015-12-15 17:50:30 +02:00
db.isSortedSetMembers('uid:' + uid + ':chat:rooms:unread', roomIds, next);
2014-09-15 16:26:25 -04:00
},
users: function(next) {
2015-12-15 17:50:30 +02:00
async.map(roomIds, function(roomId, next) {
db.getSortedSetRevRange('chat:room:' + roomId + ':uids', 0, 3, function(err, uids) {
if (err) {
return next(err);
}
uids = uids.filter(function(value, index, array) {
return value && parseInt(value, 10) !== parseInt(uid, 10);
});
user.getUsersFields(uids, ['uid', 'username', 'picture', 'status', 'lastonline'] , next);
});
}, next);
2015-08-27 17:58:29 -04:00
},
2015-08-28 17:36:44 -04:00
teasers: function(next) {
2015-12-15 17:50:30 +02:00
async.map(roomIds, function(roomId, next) {
2015-08-27 17:58:29 -04:00
Messaging.getMessages({
2015-12-15 17:50:30 +02:00
uid: uid,
roomId: roomId,
2015-08-27 17:58:29 -04:00
isNew: false,
count: 1,
markRead: false
2015-08-27 17:58:29 -04:00
}, function(err, teaser) {
2015-12-11 20:04:27 -05:00
teaser = teaser[0];
2015-09-16 15:44:10 -04:00
teaser.content = S(teaser.content).stripTags().decodeHTMLEntities().s;
next(err, teaser);
2015-08-27 17:58:29 -04:00
});
2015-09-14 15:01:35 -04:00
}, next);
2014-09-15 16:26:25 -04:00
}
}, function(err, results) {
2014-03-14 19:34:05 -04:00
if (err) {
2014-03-14 20:06:46 -04:00
return callback(err);
2014-03-14 19:34:05 -04:00
}
2015-12-15 17:50:30 +02:00
var rooms = results.users.map(function(users, index) {
var data = {
users: users,
unread: results.unread[index],
roomId: roomIds[index],
teaser: results.teasers[index]
};
data.users.forEach(function(userData) {
if (userData && parseInt(userData.uid, 10)) {
userData.status = user.getStatus(userData);
}
});
data.users = data.users.filter(function(user) {
return user && parseInt(user.uid, 10);
});
return data;
2014-09-15 16:26:25 -04:00
});
2015-12-15 17:50:30 +02:00
callback(null, {rooms: rooms, nextStart: stop + 1});
2014-03-14 19:34:05 -04:00
});
});
};
2014-07-19 10:33:27 -04:00
Messaging.notifyUser = function(fromuid, touid, messageObj) {
// Immediate notifications
// Recipient
Messaging.pushUnreadCount(touid);
sockets.in('uid_' + touid).emit('event:chats.receive', {
withUid: fromuid,
message: messageObj,
self: 0
});
// Sender
Messaging.pushUnreadCount(fromuid);
sockets.in('uid_' + fromuid).emit('event:chats.receive', {
withUid: touid,
message: messageObj,
self: 1
});
// Delayed notifications
var queueObj = Messaging.notifyQueue[fromuid + ':' + touid];
if (queueObj) {
queueObj.message.content += '\n' + messageObj.content;
clearTimeout(queueObj.timeout);
} else {
queueObj = Messaging.notifyQueue[fromuid + ':' + touid] = {
message: messageObj
};
}
queueObj.timeout = setTimeout(function() {
sendNotifications(fromuid, touid, queueObj.message, function(err) {
if (!err) {
delete Messaging.notifyQueue[fromuid + ':' + touid];
}
});
}, 1000*60); // wait 60s before sending
};
2014-10-30 17:50:07 -04:00
Messaging.canMessage = function(fromUid, toUid, callback) {
Squashed commit of the following: commit 56582bc9eee5d81a01f42a28808b617b9c96873a Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:21:11 2015 -0400 added missing template commit 6462a1626e7d8d77210b6e10eace5c9214335f33 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:19:07 2015 -0400 sitemap index commit 3cfd56f1fbc8e03405dc394375bf5ff6eef21322 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:47:52 2015 -0400 sitemap routes, controllers, and library methods for pages, categories, and topics commit e58e07c0881bdbe16d503b4679b85f761b02163c Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:07:39 2015 -0400 added groups to sitemap commit 7ee584b6327ea79f4b1f465c32da28d01c75908f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 01:43:06 2015 -0400 If notification dropdown is double-clicked, all notifications are marked read commit 488f147bef395233edb697a3895df0da7ee5ed0d Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:39:19 2015 -0400 closes #3781 commit 5e1bd58a022b1aaeedd7ab83c3655b3c16c611a0 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:28:30 2015 -0400 closes #3782 commit 57d39802671612185e86977b5c237f850fe80206 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:16:08 2015 -0400 closes #3790 commit 555c5b82da3ee30eab3fb21b2474eba834556741 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 21:19:20 2015 -0400 check user settings commit 5454862c1c81525bb096466a547557cfb0f9a2b7 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 20:26:02 2015 -0400 wait for all callbacks when creating tags commit 051c5077eb49937a8cac33b6b689c0902acfca51 Merge: 839fd93 e0e04ef Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Oct 26 09:54:12 2015 -0400 Merge pull request #3792 from drlogout/master Fixed wrong method name in socket.io/groups.js from isAdmin to isAdmi… commit e0e04ef8920e61f3bf411903b5a5c1f5198e1698 Author: Christian Nolte <hello@noltech.net> Date: Mon Oct 26 14:50:32 2015 +0100 Fixed wrong method name in socket.io/groups.js from isAdmin to isAdministrator commit 839fd935ada8d6c88eb38adbd7435679a9103875 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 21:54:35 2015 -0400 add back thread tools filter commit 37060bf1a3b75f6d74af9501344c4bd06d343db2 Merge: 5820a19 bf918bd Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Oct 25 18:13:06 2015 -0400 Merge pull request #3787 from cubehouse/patch-1 Upgrade script fails on some consoles commit 5820a193f60bcf0398ab1f981192cc1908f277cc Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:04:46 2015 -0400 closes #3789 commit 0d88d52557bf187c3b4d2b78f6da49d52952e9d1 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:03:33 2015 -0400 up theme commit 9bc43ba5e1e8ca145615bd07fff1560bc7f3eb6e Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 16:57:42 2015 -0400 closes #3788 commit aafd4b698456864fb41c365d3202a7890643fd72 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 15:56:17 2015 -0400 closes #3786 commit bf918bd016f645b9d307e4314943f787082b8627 Author: James Holding <cubehouse@users.noreply.github.com> Date: Sun Oct 25 10:14:00 2015 +0000 Upgrade script fails on some consoles The upgrade script errors/fails on some consoles if the stdout.columns isn't set (my console did this when upgrading a Docker instance of NodeBB). Checking for stdout.columns before using, falling back to a couple of spaces for slightly prettiness if we can't work out the console width.
2015-10-27 05:25:14 -04:00
if (parseInt(meta.config.disableChat) === 1 || !fromUid || toUid === fromUid) {
return callback(null, false);
}
2014-10-30 17:50:07 -04:00
async.waterfall([
2015-10-02 17:26:12 -04:00
function (next) {
user.exists(toUid, next);
},
function (exists, next) {
if (!exists) {
Squashed commit of the following: commit 56582bc9eee5d81a01f42a28808b617b9c96873a Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:21:11 2015 -0400 added missing template commit 6462a1626e7d8d77210b6e10eace5c9214335f33 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:19:07 2015 -0400 sitemap index commit 3cfd56f1fbc8e03405dc394375bf5ff6eef21322 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:47:52 2015 -0400 sitemap routes, controllers, and library methods for pages, categories, and topics commit e58e07c0881bdbe16d503b4679b85f761b02163c Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:07:39 2015 -0400 added groups to sitemap commit 7ee584b6327ea79f4b1f465c32da28d01c75908f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 01:43:06 2015 -0400 If notification dropdown is double-clicked, all notifications are marked read commit 488f147bef395233edb697a3895df0da7ee5ed0d Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:39:19 2015 -0400 closes #3781 commit 5e1bd58a022b1aaeedd7ab83c3655b3c16c611a0 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:28:30 2015 -0400 closes #3782 commit 57d39802671612185e86977b5c237f850fe80206 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:16:08 2015 -0400 closes #3790 commit 555c5b82da3ee30eab3fb21b2474eba834556741 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 21:19:20 2015 -0400 check user settings commit 5454862c1c81525bb096466a547557cfb0f9a2b7 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 20:26:02 2015 -0400 wait for all callbacks when creating tags commit 051c5077eb49937a8cac33b6b689c0902acfca51 Merge: 839fd93 e0e04ef Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Oct 26 09:54:12 2015 -0400 Merge pull request #3792 from drlogout/master Fixed wrong method name in socket.io/groups.js from isAdmin to isAdmi… commit e0e04ef8920e61f3bf411903b5a5c1f5198e1698 Author: Christian Nolte <hello@noltech.net> Date: Mon Oct 26 14:50:32 2015 +0100 Fixed wrong method name in socket.io/groups.js from isAdmin to isAdministrator commit 839fd935ada8d6c88eb38adbd7435679a9103875 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 21:54:35 2015 -0400 add back thread tools filter commit 37060bf1a3b75f6d74af9501344c4bd06d343db2 Merge: 5820a19 bf918bd Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Oct 25 18:13:06 2015 -0400 Merge pull request #3787 from cubehouse/patch-1 Upgrade script fails on some consoles commit 5820a193f60bcf0398ab1f981192cc1908f277cc Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:04:46 2015 -0400 closes #3789 commit 0d88d52557bf187c3b4d2b78f6da49d52952e9d1 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:03:33 2015 -0400 up theme commit 9bc43ba5e1e8ca145615bd07fff1560bc7f3eb6e Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 16:57:42 2015 -0400 closes #3788 commit aafd4b698456864fb41c365d3202a7890643fd72 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 15:56:17 2015 -0400 closes #3786 commit bf918bd016f645b9d307e4314943f787082b8627 Author: James Holding <cubehouse@users.noreply.github.com> Date: Sun Oct 25 10:14:00 2015 +0000 Upgrade script fails on some consoles The upgrade script errors/fails on some consoles if the stdout.columns isn't set (my console did this when upgrading a Docker instance of NodeBB). Checking for stdout.columns before using, falling back to a couple of spaces for slightly prettiness if we can't work out the console width.
2015-10-27 05:25:14 -04:00
return callback(null, false);
2015-10-02 17:26:12 -04:00
}
user.getUserFields(fromUid, ['banned', 'email:confirmed'], next);
},
function (userData, next) {
if (parseInt(userData.banned, 10) === 1) {
Squashed commit of the following: commit 56582bc9eee5d81a01f42a28808b617b9c96873a Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:21:11 2015 -0400 added missing template commit 6462a1626e7d8d77210b6e10eace5c9214335f33 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:19:07 2015 -0400 sitemap index commit 3cfd56f1fbc8e03405dc394375bf5ff6eef21322 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:47:52 2015 -0400 sitemap routes, controllers, and library methods for pages, categories, and topics commit e58e07c0881bdbe16d503b4679b85f761b02163c Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:07:39 2015 -0400 added groups to sitemap commit 7ee584b6327ea79f4b1f465c32da28d01c75908f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 01:43:06 2015 -0400 If notification dropdown is double-clicked, all notifications are marked read commit 488f147bef395233edb697a3895df0da7ee5ed0d Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:39:19 2015 -0400 closes #3781 commit 5e1bd58a022b1aaeedd7ab83c3655b3c16c611a0 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:28:30 2015 -0400 closes #3782 commit 57d39802671612185e86977b5c237f850fe80206 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:16:08 2015 -0400 closes #3790 commit 555c5b82da3ee30eab3fb21b2474eba834556741 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 21:19:20 2015 -0400 check user settings commit 5454862c1c81525bb096466a547557cfb0f9a2b7 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 20:26:02 2015 -0400 wait for all callbacks when creating tags commit 051c5077eb49937a8cac33b6b689c0902acfca51 Merge: 839fd93 e0e04ef Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Oct 26 09:54:12 2015 -0400 Merge pull request #3792 from drlogout/master Fixed wrong method name in socket.io/groups.js from isAdmin to isAdmi… commit e0e04ef8920e61f3bf411903b5a5c1f5198e1698 Author: Christian Nolte <hello@noltech.net> Date: Mon Oct 26 14:50:32 2015 +0100 Fixed wrong method name in socket.io/groups.js from isAdmin to isAdministrator commit 839fd935ada8d6c88eb38adbd7435679a9103875 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 21:54:35 2015 -0400 add back thread tools filter commit 37060bf1a3b75f6d74af9501344c4bd06d343db2 Merge: 5820a19 bf918bd Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Oct 25 18:13:06 2015 -0400 Merge pull request #3787 from cubehouse/patch-1 Upgrade script fails on some consoles commit 5820a193f60bcf0398ab1f981192cc1908f277cc Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:04:46 2015 -0400 closes #3789 commit 0d88d52557bf187c3b4d2b78f6da49d52952e9d1 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:03:33 2015 -0400 up theme commit 9bc43ba5e1e8ca145615bd07fff1560bc7f3eb6e Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 16:57:42 2015 -0400 closes #3788 commit aafd4b698456864fb41c365d3202a7890643fd72 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 15:56:17 2015 -0400 closes #3786 commit bf918bd016f645b9d307e4314943f787082b8627 Author: James Holding <cubehouse@users.noreply.github.com> Date: Sun Oct 25 10:14:00 2015 +0000 Upgrade script fails on some consoles The upgrade script errors/fails on some consoles if the stdout.columns isn't set (my console did this when upgrading a Docker instance of NodeBB). Checking for stdout.columns before using, falling back to a couple of spaces for slightly prettiness if we can't work out the console width.
2015-10-27 05:25:14 -04:00
return callback(null, false);
2015-10-02 17:26:12 -04:00
}
2015-10-02 17:26:12 -04:00
if (parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {
Squashed commit of the following: commit 56582bc9eee5d81a01f42a28808b617b9c96873a Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:21:11 2015 -0400 added missing template commit 6462a1626e7d8d77210b6e10eace5c9214335f33 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:19:07 2015 -0400 sitemap index commit 3cfd56f1fbc8e03405dc394375bf5ff6eef21322 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:47:52 2015 -0400 sitemap routes, controllers, and library methods for pages, categories, and topics commit e58e07c0881bdbe16d503b4679b85f761b02163c Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:07:39 2015 -0400 added groups to sitemap commit 7ee584b6327ea79f4b1f465c32da28d01c75908f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 01:43:06 2015 -0400 If notification dropdown is double-clicked, all notifications are marked read commit 488f147bef395233edb697a3895df0da7ee5ed0d Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:39:19 2015 -0400 closes #3781 commit 5e1bd58a022b1aaeedd7ab83c3655b3c16c611a0 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:28:30 2015 -0400 closes #3782 commit 57d39802671612185e86977b5c237f850fe80206 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:16:08 2015 -0400 closes #3790 commit 555c5b82da3ee30eab3fb21b2474eba834556741 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 21:19:20 2015 -0400 check user settings commit 5454862c1c81525bb096466a547557cfb0f9a2b7 Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 20:26:02 2015 -0400 wait for all callbacks when creating tags commit 051c5077eb49937a8cac33b6b689c0902acfca51 Merge: 839fd93 e0e04ef Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Oct 26 09:54:12 2015 -0400 Merge pull request #3792 from drlogout/master Fixed wrong method name in socket.io/groups.js from isAdmin to isAdmi… commit e0e04ef8920e61f3bf411903b5a5c1f5198e1698 Author: Christian Nolte <hello@noltech.net> Date: Mon Oct 26 14:50:32 2015 +0100 Fixed wrong method name in socket.io/groups.js from isAdmin to isAdministrator commit 839fd935ada8d6c88eb38adbd7435679a9103875 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 21:54:35 2015 -0400 add back thread tools filter commit 37060bf1a3b75f6d74af9501344c4bd06d343db2 Merge: 5820a19 bf918bd Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Oct 25 18:13:06 2015 -0400 Merge pull request #3787 from cubehouse/patch-1 Upgrade script fails on some consoles commit 5820a193f60bcf0398ab1f981192cc1908f277cc Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:04:46 2015 -0400 closes #3789 commit 0d88d52557bf187c3b4d2b78f6da49d52952e9d1 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:03:33 2015 -0400 up theme commit 9bc43ba5e1e8ca145615bd07fff1560bc7f3eb6e Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 16:57:42 2015 -0400 closes #3788 commit aafd4b698456864fb41c365d3202a7890643fd72 Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 15:56:17 2015 -0400 closes #3786 commit bf918bd016f645b9d307e4314943f787082b8627 Author: James Holding <cubehouse@users.noreply.github.com> Date: Sun Oct 25 10:14:00 2015 +0000 Upgrade script fails on some consoles The upgrade script errors/fails on some consoles if the stdout.columns isn't set (my console did this when upgrading a Docker instance of NodeBB). Checking for stdout.columns before using, falling back to a couple of spaces for slightly prettiness if we can't work out the console width.
2015-10-27 05:25:14 -04:00
return callback(null, false);
2015-10-02 17:26:12 -04:00
}
2014-11-06 12:57:55 -05:00
user.getSettings(toUid, next);
2014-10-30 17:50:07 -04:00
},
2014-11-06 12:57:55 -05:00
function(settings, next) {
if (!settings.restrictChat) {
return callback(null, true);
}
user.isAdministrator(fromUid, next);
2014-10-30 17:50:07 -04:00
},
2014-11-06 12:57:55 -05:00
function(isAdmin, next) {
if (isAdmin) {
return callback(null, true);
}
2014-10-30 17:50:07 -04:00
user.isFollowing(toUid, fromUid, next);
}
2014-11-06 12:57:55 -05:00
], callback);
};
2014-10-30 17:50:07 -04:00
Squashed commit of the following: Closes #2668 commit 3d4f494ed3257bceda8f6f82057cab83f0f252b3 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:06:42 2015 -0500 theme minvers for #2668 commit b608ce61854f8195143685bb9753b80d32b26e95 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 12:01:03 2015 -0500 Allowing chat modal to edit and delete messages re: #2668 commit 0104db90a4070582f3938b6929dae35f985bac35 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:51:23 2015 -0500 Fixed issue where newSet calculations were off ... sometimes. Also, rendering of edited messages now parses a template partial, instead of just replacing the content. commit 5cb6ca600425ca9320c599b32306e93dcc5aa4ce Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:07:12 2015 -0500 If edited content matches existing content... ... then edit is aborted. commit 6e7495247b1895589c716db29f919a934087b924 Author: Julian Lam <julian@designcreateplay.com> Date: Fri Dec 11 11:05:08 2015 -0500 some linting and fixed issue where new msgs when deleted would crash server commit db4a9e40d6dff44569c2437378121db8fdf75cf8 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 17:25:56 2015 -0500 Message deletion for #2668, and fixed bug Fixed bug where chat modal would spawn even though user was sitting on the /chats page. commit a5aa2498ab4a8bba02a6daa43a9dbed7b3e37976 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:55:23 2015 -0500 wiring up the edit button, #2668 commit 5f2afdcf6f2b9eae6b5873ca100149e65e3d385d Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:20:39 2015 -0500 added indicator to show if and when a message had been edited commit e8301132d525c1b9fd46c98cdb282ac7ea7a0d7f Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 14:06:39 2015 -0500 Allowing editing of chat messages commit bfd991be1cb1769599f7d5d2b1638e313c3c2dcb Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 10:33:49 2015 -0500 Added messageId to messages object return commit 0306ee6657b3288dd4547c66869d7d4ece0b31ad Author: Julian Lam <julian@designcreateplay.com> Date: Tue Dec 8 08:20:17 2015 -0500 WIP #2668
2015-12-11 12:07:02 -05:00
function sendNotifications(fromuid, touid, messageObj, callback) {
user.isOnline(touid, function(err, isOnline) {
if (err || isOnline) {
return callback(err);
}
notifications.create({
bodyShort: '[[notifications:new_message_from, ' + messageObj.fromUser.username + ']]',
bodyLong: messageObj.content,
nid: 'chat_' + fromuid + '_' + touid,
from: fromuid,
path: '/chats/' + messageObj.fromUser.username
}, function(err, notification) {
if (!err && notification) {
notifications.push(notification, [touid], callback);
}
});
user.getSettings(messageObj.toUser.uid, function(err, settings) {
if (settings.sendChatNotifications && !parseInt(meta.config.disableEmailSubscriptions, 10)) {
emailer.send('notif_chat', touid, {
subject: '[[email:notif.chat.subject, ' + messageObj.fromUser.username + ']]',
username: messageObj.toUser.username,
userslug: utils.slugify(messageObj.toUser.username),
summary: '[[notifications:new_message_from, ' + messageObj.fromUser.username + ']]',
message: messageObj,
site_title: meta.config.title || 'NodeBB',
url: nconf.get('url'),
fromUserslug: utils.slugify(messageObj.fromUser.username)
});
}
});
});
}
2014-04-10 20:31:57 +01:00
}(exports));