mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
feat: allow pins to expire (if set) (#8908)
* fix: add back topic assert middleware for pin route * feat: server-side handling of pin expiries * refactor: togglePin to not require uid parameter [breaking] * feat: automatic unpinning if pin has expiration set * feat: client-side modal for setting pin expiration * refactor: categories.getPinnedTids to accept multiple cids ... in preparation for pin expiry logic, direct access to *:pinned zsets is discouraged * fix: remove references to since-removed jobs file for topics * feat: expire pins when getPinnedTids is called * refactor: make the togglePin change non-breaking The 'action:topic.pin' hook now sends uid again, as before. However, if it is a system action (that is, a pin that expired), 'system' will be sent in instead of a valid uid
This commit is contained in:
@@ -57,18 +57,20 @@ module.exports = function (Topics) {
|
||||
|
||||
async function getCidTids(params) {
|
||||
const sets = [];
|
||||
const pinnedSets = [];
|
||||
params.cids.forEach(function (cid) {
|
||||
if (params.sort === 'recent') {
|
||||
sets.push('cid:' + cid + ':tids');
|
||||
} else {
|
||||
sets.push('cid:' + cid + ':tids' + (params.sort ? ':' + params.sort : ''));
|
||||
}
|
||||
pinnedSets.push('cid:' + cid + ':tids:pinned');
|
||||
});
|
||||
const [tids, pinnedTids] = await Promise.all([
|
||||
db.getSortedSetRevRange(sets, 0, meta.config.recentMaxTopics - 1),
|
||||
db.getSortedSetRevRange(pinnedSets, 0, -1),
|
||||
categories.getPinnedTids({
|
||||
cid: params.cids,
|
||||
start: 0,
|
||||
stop: -1,
|
||||
}),
|
||||
]);
|
||||
return pinnedTids.concat(tids);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user