summaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-04-03 17:19:52 +0900
committerGitHub <noreply@github.com>2018-04-03 17:19:52 +0900
commitc666a2b26ea664cea5694bb42a6f18e13a742909 (patch)
tree3ff6b88fce69b533a93b6c33c0818c346b738194 /src/remote
parentMerge pull request #1381 from akihikodaki/unfollow (diff)
parentImplement remote account unfollow (diff)
downloadmisskey-c666a2b26ea664cea5694bb42a6f18e13a742909.tar.gz
misskey-c666a2b26ea664cea5694bb42a6f18e13a742909.tar.bz2
misskey-c666a2b26ea664cea5694bb42a6f18e13a742909.zip
Merge pull request #1382 from akihikodaki/unfollow
Implement remote account unfollow
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/activitypub/act/undo/index.ts2
-rw-r--r--src/remote/activitypub/act/undo/unfollow.ts33
-rw-r--r--src/remote/activitypub/renderer/undo.ts4
3 files changed, 15 insertions, 24 deletions
diff --git a/src/remote/activitypub/act/undo/index.ts b/src/remote/activitypub/act/undo/index.ts
index b43ae86173..c34d56e704 100644
--- a/src/remote/activitypub/act/undo/index.ts
+++ b/src/remote/activitypub/act/undo/index.ts
@@ -15,7 +15,7 @@ export default async (resolver, actor, activity) => {
switch (result.object.$ref) {
case 'following':
- await unfollow(result.resolver, result.object);
+ await unfollow(result.object);
}
}));
diff --git a/src/remote/activitypub/act/undo/unfollow.ts b/src/remote/activitypub/act/undo/unfollow.ts
index 0523699bfe..c17e06e8a9 100644
--- a/src/remote/activitypub/act/undo/unfollow.ts
+++ b/src/remote/activitypub/act/undo/unfollow.ts
@@ -1,24 +1,11 @@
-import FollowedLog from '../../../../models/followed-log';
-import Following from '../../../../models/following';
-import FollowingLog from '../../../../models/following-log';
-import User from '../../../../models/user';
+import queue from '../../../../queue';
-export default async (resolver, { $id }) => {
- const following = await Following.findOneAndDelete({ _id: $id });
- if (following === null) {
- return;
- }
-
- await Promise.all([
- User.update({ _id: following.followerId }, { $inc: { followingCount: -1 } }),
- User.findOne({ _id: following.followerId }).then(({ followingCount }) => FollowingLog.insert({
- userId: following.followerId,
- count: followingCount - 1
- })),
- User.update({ _id: following.followeeId }, { $inc: { followersCount: -1 } }),
- User.findOne({ _id: following.followeeId }).then(({ followersCount }) => FollowedLog.insert({
- userId: following.followeeId,
- count: followersCount - 1
- })),
- ]);
-};
+export default ({ $id }) => new Promise((resolve, reject) => {
+ queue.create('http', { type: 'unfollow', id: $id }).save(error => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve();
+ }
+ });
+});
diff --git a/src/remote/activitypub/renderer/undo.ts b/src/remote/activitypub/renderer/undo.ts
new file mode 100644
index 0000000000..f38e224b60
--- /dev/null
+++ b/src/remote/activitypub/renderer/undo.ts
@@ -0,0 +1,4 @@
+export default object => ({
+ type: 'Undo',
+ object
+});