iceshrimp/packages/backend/src/services/following/requests/accept-all.ts
PK 52cc014e4d Translate portions of backend/src/remote/activitypub, the suspend-user service, and the boot process.
Some of these weren't translated so I thought I'd do 'em cause why not ¯\_(ツ)_/¯
2022-12-15 12:44:03 -06:00

18 lines
600 B
TypeScript

import accept from './accept.js';
import { User } from '@/models/entities/user.js';
import { FollowRequests, Users } from '@/models/index.js';
/**
* Approve all follow requests for the specified user
* @param user User.
*/
export default async function(user: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }) {
const requests = await FollowRequests.findBy({
followeeId: user.id,
});
for (const request of requests) {
const follower = await Users.findOneByOrFail({ id: request.followerId });
accept(user, follower);
}
}