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:
Julian Lam
2020-11-20 11:31:14 -05:00
committed by GitHub
parent e5d94d9096
commit 046d0b1637
10 changed files with 125 additions and 24 deletions

View File

@@ -38,6 +38,12 @@ Topics.purge = async (req, res) => {
Topics.pin = async (req, res) => {
await api.topics.pin(req, { tids: [req.params.tid] });
// Pin expiry was not available w/ sockets hence not included in api lib method
if (req.body.expiry) {
topics.tools.setPinExpiry(req.params.tid, req.body.expiry, req.uid);
}
helpers.formatApiResponse(200, res);
};