diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2018-12-08 18:55:00 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-12-08 18:55:00 +0900 |
| commit | 1d8fb65959a71836f06f4f87d5fc223c56122cf2 (patch) | |
| tree | a578a88d2ab840040d2bca9a42943c47b44b08f0 /src/remote | |
| parent | improve user-integration display in the user page (#3541) (diff) | |
| download | sharkey-1d8fb65959a71836f06f4f87d5fc223c56122cf2.tar.gz sharkey-1d8fb65959a71836f06f4f87d5fc223c56122cf2.tar.bz2 sharkey-1d8fb65959a71836f06f4f87d5fc223c56122cf2.zip | |
Fix follow duplicate (#3548)
* フォローとリクエスト両方存在しても解除する
* 既にフォローしてても承認できるように
Diffstat (limited to 'src/remote')
| -rw-r--r-- | src/remote/activitypub/kernel/undo/follow.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/remote/activitypub/kernel/undo/follow.ts b/src/remote/activitypub/kernel/undo/follow.ts index f112ee8bfb..af06aa5b31 100644 --- a/src/remote/activitypub/kernel/undo/follow.ts +++ b/src/remote/activitypub/kernel/undo/follow.ts @@ -5,6 +5,7 @@ import unfollow from '../../../../services/following/delete'; import cancelRequest from '../../../../services/following/requests/cancel'; import { IFollow } from '../../type'; import FollowRequest from '../../../../models/follow-request'; +import Following from '../../../../models/following'; export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { const id = typeof activity.object == 'string' ? activity.object : activity.object.id; @@ -30,9 +31,16 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { followeeId: followee._id }); + const following = await Following.findOne({ + followerId: actor._id, + followeeId: followee._id + }); + if (req) { await cancelRequest(followee, actor); - } else { + } + + if (following) { await unfollow(actor, followee); } }; |