summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/kernel/undo/like.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-01-20 03:07:12 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-01-20 03:07:12 +0900
commit22830965e341c9c961e072b2e92cb7c404f8624d (patch)
tree761859da2df4d3893ae47f5957281a6076724818 /src/remote/activitypub/kernel/undo/like.ts
parentRefactor (diff)
downloadmisskey-22830965e341c9c961e072b2e92cb7c404f8624d.tar.gz
misskey-22830965e341c9c961e072b2e92cb7c404f8624d.tar.bz2
misskey-22830965e341c9c961e072b2e92cb7c404f8624d.zip
AP Undo Like (#3933)
* AP Undo Like * rename
Diffstat (limited to 'src/remote/activitypub/kernel/undo/like.ts')
-rw-r--r--src/remote/activitypub/kernel/undo/like.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/remote/activitypub/kernel/undo/like.ts b/src/remote/activitypub/kernel/undo/like.ts
new file mode 100644
index 0000000000..b324ec854c
--- /dev/null
+++ b/src/remote/activitypub/kernel/undo/like.ts
@@ -0,0 +1,21 @@
+import * as mongo from 'mongodb';
+import { IRemoteUser } from '../../../../models/user';
+import { ILike } from '../../type';
+import Note from '../../../../models/note';
+import deleteReaction from '../../../../services/note/reaction/delete';
+
+/**
+ * Process Undo.Like activity
+ */
+export default async (actor: IRemoteUser, activity: ILike): Promise<void> => {
+ const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
+
+ const noteId = new mongo.ObjectID(id.split('/').pop());
+
+ const note = await Note.findOne({ _id: noteId });
+ if (note === null) {
+ throw 'note not found';
+ }
+
+ await deleteReaction(actor, note);
+};