diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-06-02 00:38:31 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-06-02 00:38:31 +0900 |
| commit | f14571dc42532c269e606f810ec2af03a3baeba5 (patch) | |
| tree | 04d86f4be12e93502665d4fcbf129f14be184956 /src/remote | |
| parent | wip (diff) | |
| download | sharkey-f14571dc42532c269e606f810ec2af03a3baeba5.tar.gz sharkey-f14571dc42532c269e606f810ec2af03a3baeba5.tar.bz2 sharkey-f14571dc42532c269e606f810ec2af03a3baeba5.zip | |
wip
Diffstat (limited to 'src/remote')
| -rw-r--r-- | src/remote/activitypub/kernel/undo/follow.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/remote/activitypub/kernel/undo/follow.ts b/src/remote/activitypub/kernel/undo/follow.ts index 763d5723c4..7377984616 100644 --- a/src/remote/activitypub/kernel/undo/follow.ts +++ b/src/remote/activitypub/kernel/undo/follow.ts @@ -2,7 +2,9 @@ import * as mongo from 'mongodb'; import User, { IRemoteUser } from '../../../../models/user'; import config from '../../../../config'; import unfollow from '../../../../services/following/delete'; +import cancelRequest from '../../../../services/following/requests/cancel'; import { IFollow } from '../../type'; +import FollowRequest from '../../../../models/follow-request'; export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { const id = typeof activity.object == 'string' ? activity.object : activity.object.id; @@ -23,5 +25,14 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません'); } - await unfollow(actor, followee); + const req = await FollowRequest.findOne({ + followerId: actor._id, + followeeId: followee._id + }); + + if (req) { + await cancelRequest(actor, followee); + } else { + await unfollow(actor, followee); + } }; |