summaryrefslogtreecommitdiff
path: root/src/models/following.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-13 00:07:16 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-13 00:07:16 +0900
commit0cf7c76d2c1f34e331a70b104c6bbd6468b09ebb (patch)
treef8b5d8f6a9c1b87a17989de46e1b834809950a68 /src/models/following.ts
parentAdd home customize link (diff)
parentwip (diff)
downloadmisskey-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.ts27
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
+ });
+}