unoffical wafrn mirror wafrn.net
atproto social-network activitypub
at angular21 27 lines 604 B view raw
1import { Op } from 'sequelize' 2import { getAllLocalUserIds } from '../cacheGetters/getAllLocalUserIds.js' 3import { Post, User } from '../../models/index.js' 4 5const localUserIds = await getAllLocalUserIds() 6 7const localUsers = await User.findAll({ 8 where: { 9 id: { 10 [Op.in]: localUserIds 11 } 12 } 13}) 14 15for await (const user of localUsers) { 16 console.log('updating ' + user.url) 17 const latestPost = await Post.findOne({ 18 where: { 19 userId: user.id 20 }, 21 order: [['createdAt', 'DESC']] 22 }) 23 if (latestPost) { 24 user.lastActiveAt = latestPost.createdAt 25 await user.save() 26 } 27}