unoffical wafrn mirror wafrn.net
atproto social-network activitypub
at testPDSNotExplode 29 lines 759 B view raw
1import { Op } from 'sequelize' 2import { User, sequelize } from '../../models/index.js' 3import { redisCache } from '../redis.js' 4 5async function getAllLocalUserIds(): Promise<string[]> { 6 let res: string[] = [] 7 const cacheResult = await redisCache.get('allLocalUserIds') 8 if (cacheResult) { 9 res = JSON.parse(cacheResult) 10 } else { 11 const localUsers = await User.scope('full').findAll({ 12 attributes: ['id'], 13 where: { 14 email: { 15 [Op.ne]: null 16 }, 17 banned: false, 18 activated: true 19 } 20 }) 21 if (localUsers) { 22 res = localUsers.map((elem: any) => elem.id) 23 await redisCache.set('allLocalUserIds', JSON.stringify(res), 'EX', 600) 24 } 25 } 26 return res 27} 28 29export { getAllLocalUserIds }