Files
NodeBB/src/socket.io/posts/diffs.js

35 lines
963 B
JavaScript
Raw Normal View History

2018-02-16 16:41:06 -05:00
'use strict';
2018-06-06 16:21:48 -04:00
var async = require('async');
2018-02-16 16:41:06 -05:00
var posts = require('../../posts');
var privileges = require('../../privileges');
2018-02-16 16:41:06 -05:00
module.exports = function (SocketPosts) {
SocketPosts.getDiffs = function (socket, data, callback) {
2018-06-06 16:21:48 -04:00
async.waterfall([
function (next) {
privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) {
next(err || allowed ? null : new Error('[[error:no-privileges]]'));
});
},
2018-06-06 16:21:48 -04:00
function (next) {
posts.diffs.list(data.pid, next);
},
function (timestamps, next) {
timestamps.unshift(Date.now());
next(null, timestamps);
},
], callback);
2018-02-16 16:41:06 -05:00
};
SocketPosts.showPostAt = function (socket, data, callback) {
privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) {
if (err || !allowed) {
return callback(err || new Error('[[error:no-privileges]]'));
}
posts.diffs.load(data.pid, data.since, socket.uid, callback);
});
2018-02-16 16:41:06 -05:00
};
};