Merge remote-tracking branch 'origin/master' into develop

v1.18.x
Julian Lam 7 years ago
commit 6a93bc140b

@ -4,6 +4,7 @@ var async = require('async');
var _ = require('lodash'); var _ = require('lodash');
var S = require('string'); var S = require('string');
var winston = require('winston'); var winston = require('winston');
var validator = require('validator');
var db = require('./database'); var db = require('./database');
var user = require('./user'); var user = require('./user');
@ -92,6 +93,7 @@ Flags.get = function (flagId, callback) {
}, function (err, payload) { }, function (err, payload) {
// Final object return construction // Final object return construction
next(err, Object.assign(data.base, { next(err, Object.assign(data.base, {
description: validator.escape(data.base.description),
datetimeISO: new Date(parseInt(data.base.datetime, 10)).toISOString(), datetimeISO: new Date(parseInt(data.base.datetime, 10)).toISOString(),
target_readable: data.base.type.charAt(0).toUpperCase() + data.base.type.slice(1) + ' ' + data.base.targetId, target_readable: data.base.type.charAt(0).toUpperCase() + data.base.type.slice(1) + ' ' + data.base.targetId,
target: payload.targetObj, target: payload.targetObj,
@ -200,6 +202,7 @@ Flags.list = function (filters, uid, callback) {
} }
next(null, Object.assign(flagObj, { next(null, Object.assign(flagObj, {
description: validator.escape(flagObj.description),
target_readable: flagObj.type.charAt(0).toUpperCase() + flagObj.type.slice(1) + ' ' + flagObj.targetId, target_readable: flagObj.type.charAt(0).toUpperCase() + flagObj.type.slice(1) + ' ' + flagObj.targetId,
datetimeISO: new Date(parseInt(flagObj.datetime, 10)).toISOString(), datetimeISO: new Date(parseInt(flagObj.datetime, 10)).toISOString(),
})); }));

@ -153,6 +153,7 @@ Messaging.getRecentChats = function (callerUid, uid, start, stop, callback) {
}, },
function (results, next) { function (results, next) {
results.roomData.forEach(function (room, index) { results.roomData.forEach(function (room, index) {
if (room) {
room.users = results.users[index]; room.users = results.users[index];
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : room.users.length > 2; room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : room.users.length > 2;
room.unread = results.unread[index]; room.unread = results.unread[index];
@ -169,8 +170,11 @@ Messaging.getRecentChats = function (callerUid, uid, start, stop, callback) {
room.lastUser = room.users[0]; room.lastUser = room.users[0];
room.usernames = Messaging.generateUsernames(room.users, uid); room.usernames = Messaging.generateUsernames(room.users, uid);
}
}); });
results.roomData = results.roomData.filter(Boolean);
next(null, { rooms: results.roomData, nextStart: stop + 1 }); next(null, { rooms: results.roomData, nextStart: stop + 1 });
}, },
function (ref, next) { function (ref, next) {

@ -40,13 +40,6 @@ module.exports = function (Plugins) {
'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' : 'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' :
'there is no alternative.' 'there is no alternative.'
)); ));
} else {
// handle hook's startsWith, i.e. action:homepage.get
var parts = data.hook.split(':');
if (parts.length > 2) {
parts.pop();
}
parts.join(':');
} }
if (data.hook && data.method) { if (data.hook && data.method) {

Loading…
Cancel
Save