diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 00:07:16 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 00:07:16 +0900 |
| commit | 0cf7c76d2c1f34e331a70b104c6bbd6468b09ebb (patch) | |
| tree | f8b5d8f6a9c1b87a17989de46e1b834809950a68 /src/models/following.ts | |
| parent | Add home customize link (diff) | |
| parent | wip (diff) | |
| download | misskey-0cf7c76d2c1f34e331a70b104c6bbd6468b09ebb.tar.gz misskey-0cf7c76d2c1f34e331a70b104c6bbd6468b09ebb.tar.bz2 misskey-0cf7c76d2c1f34e331a70b104c6bbd6468b09ebb.zip | |
Merge branch 'master' of https://github.com/syuilo/misskey
Diffstat (limited to 'src/models/following.ts')
| -rw-r--r-- | src/models/following.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/models/following.ts b/src/models/following.ts index b4090d8c7e..f10e349ee9 100644 --- a/src/models/following.ts +++ b/src/models/following.ts @@ -11,3 +11,30 @@ export type IFollowing = { followeeId: mongo.ObjectID; followerId: mongo.ObjectID; }; + +/** + * Followingを物理削除します + */ +export async function deleteFollowing(following: string | mongo.ObjectID | IFollowing) { + let f: IFollowing; + + // Populate + if (mongo.ObjectID.prototype.isPrototypeOf(following)) { + f = await Following.findOne({ + _id: following + }); + } else if (typeof following === 'string') { + f = await Following.findOne({ + _id: new mongo.ObjectID(following) + }); + } else { + f = following as IFollowing; + } + + if (f == null) return; + + // このFollowingを削除 + await Following.remove({ + _id: f._id + }); +} |