chore: make optional params of UserFollowingService.follow() object

This commit is contained in:
anatawa12 2023-10-16 16:19:39 +09:00
parent 3bccba571b
commit 8e3e5aef28
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
3 changed files with 13 additions and 3 deletions

View File

@ -91,7 +91,14 @@ export class UserFollowingService implements OnModuleInit {
} }
@bindThis @bindThis
public async follow(_follower: { id: MiUser['id'] }, _followee: { id: MiUser['id'] }, requestId?: string, silent = false): Promise<void> { public async follow(
_follower: { id: MiUser['id'] },
_followee: { id: MiUser['id'] },
{ requestId, silent = false }: {
requestId?: string,
silent?: boolean,
} = {},
): Promise<void> {
const [follower, followee] = await Promise.all([ const [follower, followee] = await Promise.all([
this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _follower.id }),
this.usersRepository.findOneByOrFail({ id: _followee.id }), this.usersRepository.findOneByOrFail({ id: _followee.id }),

View File

@ -164,7 +164,7 @@ export class ApInboxService {
} }
// don't queue because the sender may attempt again when timeout // don't queue because the sender may attempt again when timeout
await this.userFollowingService.follow(actor, followee, activity.id); await this.userFollowingService.follow(actor, followee, { requestId: activity.id });
return 'ok'; return 'ok';
} }

View File

@ -35,7 +35,10 @@ export class RelationshipProcessorService {
@bindThis @bindThis
public async processFollow(job: Bull.Job<RelationshipJobData>): Promise<string> { public async processFollow(job: Bull.Job<RelationshipJobData>): Promise<string> {
this.logger.info(`${job.data.from.id} is trying to follow ${job.data.to.id}`); this.logger.info(`${job.data.from.id} is trying to follow ${job.data.to.id}`);
await this.userFollowingService.follow(job.data.from, job.data.to, job.data.requestId, job.data.silent); await this.userFollowingService.follow(job.data.from, job.data.to, {
requestId: job.data.requestId,
silent: job.data.silent
});
return 'ok'; return 'ok';
} }