feat: exposed method to find topic events based on a subset of saved info, returns topic event ids

This commit is contained in:
Julian Lam
2024-02-06 14:56:34 -05:00
parent f7259ccb8b
commit b9821c5206

View File

@@ -129,6 +129,16 @@ Events.get = async (tid, uid, reverse = false) => {
return events;
};
Events.find = async (tid, match) => {
let eventIds = await db.getSortedSetRangeWithScores(`topic:${tid}:events`, 0, -1);
const keys = eventIds.map(obj => `topicEvent:${obj.value}`);
eventIds = eventIds.map(obj => obj.value);
const events = await db.getObjects(keys);
eventIds = eventIds.filter((id, idx) => _.isMatch(events[idx], match));
return eventIds;
};
async function getUserInfo(uids) {
uids = new Set(uids); // eliminate dupes
const userData = await user.getUsersFields(Array.from(uids), ['picture', 'username', 'userslug']);