refactor: remove var

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 94810fd637
commit 05e753c73b

@ -1,13 +1,13 @@
'use strict';
var async = require('async');
const async = require('async');
var db = require('../database');
var posts = require('../posts');
var privileges = require('../privileges');
var plugins = require('../plugins');
var meta = require('../meta');
const db = require('../database');
const posts = require('../posts');
const privileges = require('../privileges');
const plugins = require('../plugins');
const meta = require('../meta');
module.exports = function (Topics) {
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
@ -27,8 +27,8 @@ module.exports = function (Topics) {
pids.sort((a, b) => a - b);
var mainPid = pids[0];
var cid = await posts.getCidByPid(mainPid);
const mainPid = pids[0];
const cid = await posts.getCidByPid(mainPid);
const [postData, isAdminOrMod] = await Promise.all([
posts.getPostData(mainPid),
@ -57,22 +57,20 @@ module.exports = function (Topics) {
};
Topics.movePostToTopic = async function (callerUid, pid, tid) {
var postData;
tid = parseInt(tid, 10);
const exists = await Topics.exists(tid);
if (!exists) {
throw new Error('[[error:no-topic]]');
}
const post = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
if (!post || !post.tid) {
const postData = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
if (!postData || !postData.tid) {
throw new Error('[[error:no-post]]');
}
if (post.tid === tid) {
if (postData.tid === tid) {
throw new Error('[[error:cant-move-to-same-topic]]');
}
postData = post;
postData.pid = pid;
await Topics.removePostFromTopic(postData.tid, postData);

@ -1,12 +1,12 @@
'use strict';
var db = require('../database');
var plugins = require('../plugins');
var posts = require('../posts');
const db = require('../database');
const plugins = require('../plugins');
const posts = require('../posts');
module.exports = function (Topics) {
var terms = {
const terms = {
day: 86400000,
week: 604800000,
month: 2592000000,
@ -33,12 +33,12 @@ module.exports = function (Topics) {
};
Topics.getLatestTidsFromSet = async function (set, start, stop, term) {
var since = terms.day;
let since = terms.day;
if (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);
};

Loading…
Cancel
Save