summaryrefslogtreecommitdiff
path: root/src/remote/activitypub
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
parentRefactor (diff)
downloadsharkey-22830965e341c9c961e072b2e92cb7c404f8624d.tar.gz
sharkey-22830965e341c9c961e072b2e92cb7c404f8624d.tar.bz2
sharkey-22830965e341c9c961e072b2e92cb7c404f8624d.zip
AP Undo Like (#3933)
* AP Undo Like * rename
Diffstat (limited to 'src/remote/activitypub')
-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);
+};