mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: remove var
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const async = require('async');
|
||||||
|
|
||||||
var db = require('../database');
|
const db = require('../database');
|
||||||
var posts = require('../posts');
|
const posts = require('../posts');
|
||||||
var privileges = require('../privileges');
|
const privileges = require('../privileges');
|
||||||
var plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
var meta = require('../meta');
|
const meta = require('../meta');
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
|
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
|
||||||
@@ -27,8 +27,8 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
pids.sort((a, b) => a - b);
|
pids.sort((a, b) => a - b);
|
||||||
|
|
||||||
var mainPid = pids[0];
|
const mainPid = pids[0];
|
||||||
var cid = await posts.getCidByPid(mainPid);
|
const cid = await posts.getCidByPid(mainPid);
|
||||||
|
|
||||||
const [postData, isAdminOrMod] = await Promise.all([
|
const [postData, isAdminOrMod] = await Promise.all([
|
||||||
posts.getPostData(mainPid),
|
posts.getPostData(mainPid),
|
||||||
@@ -57,22 +57,20 @@ module.exports = function (Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.movePostToTopic = async function (callerUid, pid, tid) {
|
Topics.movePostToTopic = async function (callerUid, pid, tid) {
|
||||||
var postData;
|
|
||||||
tid = parseInt(tid, 10);
|
tid = parseInt(tid, 10);
|
||||||
const exists = await Topics.exists(tid);
|
const exists = await Topics.exists(tid);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
throw new Error('[[error:no-topic]]');
|
throw new Error('[[error:no-topic]]');
|
||||||
}
|
}
|
||||||
const post = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
|
const postData = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
|
||||||
if (!post || !post.tid) {
|
if (!postData || !postData.tid) {
|
||||||
throw new Error('[[error:no-post]]');
|
throw new Error('[[error:no-post]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.tid === tid) {
|
if (postData.tid === tid) {
|
||||||
throw new Error('[[error:cant-move-to-same-topic]]');
|
throw new Error('[[error:cant-move-to-same-topic]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
postData = post;
|
|
||||||
postData.pid = pid;
|
postData.pid = pid;
|
||||||
|
|
||||||
await Topics.removePostFromTopic(postData.tid, postData);
|
await Topics.removePostFromTopic(postData.tid, postData);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var db = require('../database');
|
const db = require('../database');
|
||||||
var plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
var posts = require('../posts');
|
const posts = require('../posts');
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
var terms = {
|
const terms = {
|
||||||
day: 86400000,
|
day: 86400000,
|
||||||
week: 604800000,
|
week: 604800000,
|
||||||
month: 2592000000,
|
month: 2592000000,
|
||||||
@@ -33,12 +33,12 @@ module.exports = function (Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.getLatestTidsFromSet = async function (set, start, stop, term) {
|
Topics.getLatestTidsFromSet = async function (set, start, stop, term) {
|
||||||
var since = terms.day;
|
let since = terms.day;
|
||||||
if (terms[term]) {
|
if (terms[term]) {
|
||||||
since = terms[term];
|
since = terms[term];
|
||||||
}
|
}
|
||||||
|
|
||||||
var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
|
const count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
|
||||||
return await db.getSortedSetRevRangeByScore(set, start, count, '+inf', Date.now() - since);
|
return await db.getSortedSetRevRangeByScore(set, start, count, '+inf', Date.now() - since);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user