refactor: get rid of cache for tid posters, was never cleared

This commit is contained in:
Barış Soner Uşaklı
2026-02-03 20:20:30 -05:00
parent 6f032fd301
commit 065abbf249
2 changed files with 2 additions and 11 deletions

View File

@@ -8,7 +8,6 @@ const request = require('../request');
const db = require('../database'); const db = require('../database');
const meta = require('../meta'); const meta = require('../meta');
const categories = require('../categories'); const categories = require('../categories');
const topics = require('../topics');
const posts = require('../posts'); const posts = require('../posts');
const messaging = require('../messaging'); const messaging = require('../messaging');
const user = require('../user'); const user = require('../user');
@@ -521,7 +520,7 @@ ActivityPub.buildRecipients = async function (object, options) {
// Topic posters, post announcers and their followers // Topic posters, post announcers and their followers
if (pid) { if (pid) {
const tid = await posts.getPostField(pid, 'tid'); const tid = await posts.getPostField(pid, 'tid');
const participants = (await topics.getUids(tid)) const participants = (await db.getSortedSetMembers(`tid:${tid}:posters`))
.filter(uid => !utils.isNumber(uid)); // remote users only .filter(uid => !utils.isNumber(uid)); // remote users only
const announcers = (await ActivityPub.notes.announce.list({ pid })).map(({ actor }) => actor); const announcers = (await ActivityPub.notes.announce.list({ pid })).map(({ actor }) => actor);
const auxiliaries = Array.from(new Set([...participants, ...announcers])); const auxiliaries = Array.from(new Set([...participants, ...announcers]));

View File

@@ -2,7 +2,6 @@
const db = require('../database'); const db = require('../database');
const utils = require('../utils'); const utils = require('../utils');
const cache = require('../cache');
module.exports = function (Topics) { module.exports = function (Topics) {
Topics.isOwner = async function (tid, uid) { Topics.isOwner = async function (tid, uid) {
@@ -14,13 +13,6 @@ module.exports = function (Topics) {
}; };
Topics.getUids = async function (tid) { Topics.getUids = async function (tid) {
const cacheKey = `tid:${tid}:uids`; return await db.getSortedSetRevRangeByScore(`tid:${tid}:posters`, 0, -1, '+inf', 1);
let posters = cache.get(cacheKey, tid);
if (!posters) {
posters = await db.getSortedSetRevRangeByScore(`tid:${tid}:posters`, 0, -1, '+inf', 1);
cache.set(cacheKey, posters);
}
return posters;
}; };
}; };