enhance: リモートのフォロワーから再度Followが来た場合、acceptを返してあげる
This commit is contained in:
parent
b0030d148d
commit
4818461ee7
|
@ -94,6 +94,32 @@ export class UserFollowingService implements OnModuleInit {
|
||||||
this.userBlockingService = this.moduleRef.get('UserBlockingService');
|
this.userBlockingService = this.moduleRef.get('UserBlockingService');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async deliverAccept(follower: MiRemoteUser, followee: MiPartialLocalUser, requestId?: string) {
|
||||||
|
const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee, requestId), followee));
|
||||||
|
this.queueService.deliver(followee, content, follower.inbox, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async followFromRemote(
|
||||||
|
follower: MiRemoteUser,
|
||||||
|
followee: MiLocalUser,
|
||||||
|
options: { requestId?: string } = {},
|
||||||
|
) {
|
||||||
|
if (await this.followingsRepository.exists({
|
||||||
|
where: {
|
||||||
|
followerId: follower.id,
|
||||||
|
followeeId: followee.id,
|
||||||
|
},
|
||||||
|
})) {
|
||||||
|
// すでにフォロー関係が存在している場合、acceptを送り返しておしまい
|
||||||
|
this.deliverAccept(follower, followee, options.requestId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.follow(follower, followee, options);
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async follow(
|
public async follow(
|
||||||
_follower: { id: MiUser['id'] },
|
_follower: { id: MiUser['id'] },
|
||||||
|
@ -189,8 +215,7 @@ export class UserFollowingService implements OnModuleInit {
|
||||||
await this.insertFollowingDoc(followee, follower, silent, withReplies);
|
await this.insertFollowingDoc(followee, follower, silent, withReplies);
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
||||||
const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee, requestId), followee));
|
this.deliverAccept(follower, followee, requestId);
|
||||||
this.queueService.deliver(followee, content, follower.inbox, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,8 +596,7 @@ export class UserFollowingService implements OnModuleInit {
|
||||||
await this.insertFollowingDoc(followee, follower, false, request.withReplies);
|
await this.insertFollowingDoc(followee, follower, false, request.withReplies);
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
||||||
const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee as MiPartialLocalUser, request.requestId!), followee));
|
this.deliverAccept(follower, followee as MiPartialLocalUser, request.requestId ?? undefined);
|
||||||
this.queueService.deliver(followee, content, follower.inbox, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.userEntityService.pack(followee.id, followee, {
|
this.userEntityService.pack(followee.id, followee, {
|
||||||
|
|
|
@ -170,7 +170,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, { requestId: activity.id });
|
await this.userFollowingService.followFromRemote(actor, followee, { requestId: activity.id });
|
||||||
return 'ok';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue