|
|
|
@ -26,6 +26,11 @@ Scheduled.handleExpired = async function () {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await postTids(tids);
|
|
|
|
|
await db.sortedSetsRemoveRangeByScore([`topics:scheduled`], '-inf', now);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function postTids(tids) {
|
|
|
|
|
let topicsData = await topics.getTopicsData(tids);
|
|
|
|
|
// Filter deleted
|
|
|
|
|
topicsData = topicsData.filter(topicData => Boolean(topicData));
|
|
|
|
@ -43,9 +48,8 @@ Scheduled.handleExpired = async function () {
|
|
|
|
|
updateUserLastposttimes(uids, topicsData),
|
|
|
|
|
updateGroupPosts(uids, topicsData),
|
|
|
|
|
...topicsData.map(topicData => unpin(topicData.tid, topicData)),
|
|
|
|
|
db.sortedSetsRemoveRangeByScore([`topics:scheduled`], '-inf', now)
|
|
|
|
|
));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// topics/tools.js#pin/unpin would block non-admins/mods, thus the local versions
|
|
|
|
|
Scheduled.pin = async function (tid, topicData) {
|
|
|
|
@ -62,6 +66,9 @@ Scheduled.pin = async function (tid, topicData) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Scheduled.reschedule = async function ({ cid, tid, timestamp, uid }) {
|
|
|
|
|
if (timestamp < Date.now()) {
|
|
|
|
|
await postTids([tid]);
|
|
|
|
|
} else {
|
|
|
|
|
const mainPid = await topics.getTopicField(tid, 'mainPid');
|
|
|
|
|
await Promise.all([
|
|
|
|
|
db.sortedSetsAdd([
|
|
|
|
@ -78,7 +85,8 @@ Scheduled.reschedule = async function ({ cid, tid, timestamp, uid }) {
|
|
|
|
|
], timestamp, mainPid),
|
|
|
|
|
shiftPostTimes(tid, timestamp),
|
|
|
|
|
]);
|
|
|
|
|
return topics.updateLastPostTimeFromLastPid(tid);
|
|
|
|
|
await topics.updateLastPostTimeFromLastPid(tid);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function unpin(tid, topicData) {
|
|
|
|
|