feat: allow activitypub request cache to be ignored

This commit is contained in:
Julian Lam
2024-07-09 14:45:04 -04:00
parent 5e343a83f8
commit 485b775837
2 changed files with 7 additions and 3 deletions

View File

@@ -86,7 +86,7 @@ Actors.assert = async (ids, options = {}) => {
let actors = await Promise.all(ids.map(async (id) => { let actors = await Promise.all(ids.map(async (id) => {
try { try {
// winston.verbose(`[activitypub/actors] Processing ${id}`); // winston.verbose(`[activitypub/actors] Processing ${id}`);
const actor = (typeof id === 'object' && id.hasOwnProperty('id')) ? id : await activitypub.get('uid', 0, id); const actor = (typeof id === 'object' && id.hasOwnProperty('id')) ? id : await activitypub.get('uid', 0, id, { cache: false });
// Follow counts // Follow counts
try { try {

View File

@@ -251,10 +251,14 @@ ActivityPub.verify = async (req) => {
} }
}; };
ActivityPub.get = async (type, id, uri) => { ActivityPub.get = async (type, id, uri, options) => {
options = {
cache: true,
...options,
};
const cacheKey = [id, uri].join(';'); const cacheKey = [id, uri].join(';');
const cached = requestCache.get(cacheKey); const cached = requestCache.get(cacheKey);
if (cached !== undefined) { if (options.cache && cached !== undefined) {
return cached; return cached;
} }