unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import { Op } from 'sequelize'
2import { Follows, User } from '../../models/index.js'
3import { redisCache } from '../redis.js'
4import { completeEnvironment } from '../backendOptions.js'
5
6async function getFollowerRemoteIds(id: string) {
7 const cacheResult = await redisCache.get('remoteFollower:' + id)
8 if (cacheResult) {
9 return JSON.parse(cacheResult)
10 } else {
11 const follows = await Follows.findAll({
12 order: [['createdAt', 'DESC']],
13 include: [
14 {
15 model: User,
16 as: 'followed'
17 }
18 ],
19 where: {
20 followedId: id,
21 accepted: true
22 }
23 })
24 const res = follows.map((follow) => follow.followed.fullFediverseUrl)
25 await redisCache.set('remoteFollower:' + id, JSON.stringify(res), 'EX', 300)
26 return res
27 }
28}
29
30export { getFollowerRemoteIds }