unoffical wafrn mirror wafrn.net
atproto social-network activitypub
at angular21 21 lines 606 B view raw
1import { Mutes } from '../../models/index.js' 2import { redisCache } from '../redis.js' 3 4async function getMutedUsers(userId: string): Promise<Array<string>> { 5 let res: string[] = [] 6 const cacheResult = await redisCache.get('mutedUsers:' + userId) 7 if (cacheResult) { 8 res = JSON.parse(cacheResult) 9 } else { 10 const mutedUsersQuery = await Mutes.findAll({ 11 where: { 12 muterId: userId 13 } 14 }) 15 res = mutedUsersQuery.map((elem: any) => elem.mutedId) 16 await redisCache.set('mutedUsers:' + userId, JSON.stringify(res), 'EX', 600) 17 } 18 return res 19} 20 21export { getMutedUsers }