mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 05:28:20 +02:00
allowing topic, post, and user creation to specify a timestamp for insertion into the past
This commit is contained in:
@@ -514,13 +514,13 @@ var async = require('async'),
|
||||
if (exists) {
|
||||
return callback(new Error('[[error:group-already-exists]]'));
|
||||
}
|
||||
var now = Date.now();
|
||||
var timestamp = data.timestamp || Date.now();
|
||||
|
||||
var slug = utils.slugify(data.name),
|
||||
groupData = {
|
||||
name: data.name,
|
||||
slug: slug,
|
||||
createtime: now,
|
||||
createtime: timestamp,
|
||||
userTitle: data.name,
|
||||
description: data.description || '',
|
||||
memberCount: 0,
|
||||
@@ -530,13 +530,13 @@ var async = require('async'),
|
||||
private: data.private || '1'
|
||||
},
|
||||
tasks = [
|
||||
async.apply(db.sortedSetAdd, 'groups:createtime', now, data.name),
|
||||
async.apply(db.sortedSetAdd, 'groups:createtime', timestamp, data.name),
|
||||
async.apply(db.setObject, 'group:' + data.name, groupData)
|
||||
];
|
||||
|
||||
if (data.hasOwnProperty('ownerUid')) {
|
||||
tasks.push(async.apply(db.setAdd, 'group:' + data.name + ':owners', data.ownerUid));
|
||||
tasks.push(async.apply(db.sortedSetAdd, 'group:' + data.name + ':members', now, data.ownerUid));
|
||||
tasks.push(async.apply(db.sortedSetAdd, 'group:' + data.name + ':members', timestamp, data.ownerUid));
|
||||
tasks.push(async.apply(db.setObjectField, 'group:' + data.name, 'memberCount', 1));
|
||||
|
||||
groupData.ownerUid = data.ownerUid;
|
||||
|
||||
@@ -12,6 +12,7 @@ var async = require('async'),
|
||||
|
||||
module.exports = function(Posts) {
|
||||
Posts.create = function(data, callback) {
|
||||
// This is an internal method, consider using Topics.reply instead
|
||||
var uid = data.uid,
|
||||
tid = data.tid,
|
||||
content = data.content.toString(),
|
||||
|
||||
@@ -15,6 +15,7 @@ var async = require('async'),
|
||||
module.exports = function(Topics) {
|
||||
|
||||
Topics.create = function(data, callback) {
|
||||
// This is an interal method, consider using Topics.post instead
|
||||
var uid = data.uid,
|
||||
title = data.title,
|
||||
cid = data.cid,
|
||||
@@ -26,7 +27,7 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
var slug = utils.slugify(title),
|
||||
timestamp = Date.now();
|
||||
timestamp = data.timestamp || Date.now();
|
||||
|
||||
if (!slug.length) {
|
||||
return callback(new Error('[[error:invalid-title]]'));
|
||||
@@ -136,10 +137,10 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(filteredData, next) {
|
||||
content = filteredData.content || data.content;
|
||||
Topics.create({uid: uid, title: title, cid: cid, thumb: data.thumb, tags: tags}, next);
|
||||
Topics.create({ uid: uid, title: title, cid: cid, thumb: data.thumb, tags: tags, timestamp: data.timestamp }, next);
|
||||
},
|
||||
function(tid, next) {
|
||||
Topics.reply({uid:uid, tid:tid, handle: data.handle, content:content, req: data.req}, next);
|
||||
Topics.reply({ uid:uid, tid:tid, handle: data.handle, content:content, timestamp: data.timestamp, req: data.req }, next);
|
||||
},
|
||||
function(postData, next) {
|
||||
async.parallel({
|
||||
@@ -230,7 +231,7 @@ module.exports = function(Topics) {
|
||||
checkContentLength(content, next);
|
||||
},
|
||||
function(next) {
|
||||
posts.create({uid: uid, tid: tid, handle: data.handle, content: content, toPid: data.toPid, ip: data.req ? data.req.ip : null}, next);
|
||||
posts.create({uid: uid, tid: tid, handle: data.handle, content: content, toPid: data.toPid, timestamp: data.timestamp, ip: data.req ? data.req.ip : null}, next);
|
||||
},
|
||||
function(data, next) {
|
||||
postData = data;
|
||||
@@ -278,7 +279,7 @@ module.exports = function(Topics) {
|
||||
postData.selfPost = false;
|
||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||
|
||||
if (parseInt(uid, 10)) {
|
||||
if (parseInt(uid, 10) && data.req) {
|
||||
Topics.notifyFollowers(postData, uid);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = function(User) {
|
||||
return callback(err);
|
||||
}
|
||||
var gravatar = User.createGravatarURLFromEmail(data.email);
|
||||
var timestamp = Date.now();
|
||||
var timestamp = data.timestamp || Date.now();
|
||||
|
||||
var userData = {
|
||||
'username': data.username,
|
||||
|
||||
Reference in New Issue
Block a user