summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/kernel/undo
diff options
context:
space:
mode:
Diffstat (limited to 'src/remote/activitypub/kernel/undo')
-rw-r--r--src/remote/activitypub/kernel/undo/index.ts6
-rw-r--r--src/remote/activitypub/kernel/undo/like.ts21
2 files changed, 26 insertions, 1 deletions
diff --git a/src/remote/activitypub/kernel/undo/index.ts b/src/remote/activitypub/kernel/undo/index.ts
index ba56dd6328..471988f052 100644
--- a/src/remote/activitypub/kernel/undo/index.ts
+++ b/src/remote/activitypub/kernel/undo/index.ts
@@ -1,9 +1,10 @@
import * as debug from 'debug';
import { IRemoteUser } from '../../../../models/user';
-import { IUndo, IFollow, IBlock } from '../../type';
+import { IUndo, IFollow, IBlock, ILike } from '../../type';
import unfollow from './follow';
import unblock from './block';
+import undoLike from './like';
import Resolver from '../../resolver';
const log = debug('misskey:activitypub');
@@ -35,6 +36,9 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
case 'Block':
unblock(actor, object as IBlock);
break;
+ case 'Like':
+ undoLike(actor, object as ILike);
+ break;
}
return null;
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);
+};