浏览代码

Merge pull request #2206 from pixelfed/staging

Update AP Inbox, add follow notifications
daniel 5 年之前
父节点
当前提交
f5fdd7d31c
共有 2 个文件被更改,包括 10 次插入12 次删除
  1. 2 1
      CHANGELOG.md
  2. 8 11
      app/Util/ActivityPub/Inbox.php

+ 2 - 1
CHANGELOG.md

@@ -39,7 +39,8 @@
 - Updated Inbox, move expensive HTTP Signature validation to job queue ([f2ae45e5a](https://github.com/pixelfed/pixelfed/commit/f2ae45e5a))
 - Updated MomentUI, fix bugs and improve UI ([90b89cb8](https://github.com/pixelfed/pixelfed/commit/90b89cb8))
 - Updated PostComponent, improve embed model. Fixes ([#2189](https://github.com/pixelfed/pixelfed/issues/2189)) ([b12e504e](https://github.com/pixelfed/pixelfed/commit/b12e504e))
-- Updated PostComponent, hide edit button after 24 hours. Fixes [#2188](https://github.com/pixelfed/pixelfed/issues/2188)) ([a1fee6a2](https://github.com/pixelfed/pixelfed/commit/a1fee6a2))
+- Updated PostComponent, hide edit button after 24 hours. Fixes ([#2188](https://github.com/pixelfed/pixelfed/issues/2188)) ([a1fee6a2](https://github.com/pixelfed/pixelfed/commit/a1fee6a2))
+- Updated AP Inbox, add follow notifications ([b8819fbb](https://github.com/pixelfed/pixelfed/commit/b8819fbb))
 
 
 ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)

+ 8 - 11
app/Util/ActivityPub/Inbox.php

@@ -197,18 +197,9 @@ class Inbox
             $follower->profile_id = $actor->id;
             $follower->following_id = $target->id;
             $follower->local_profile = empty($actor->domain);
+            $follower->save();
 
-            if($target->domain == null) {
-                Notification::firstOrCreate([
-                    'profile_id' => $target->id,
-                    'actor_id' => $actor->id,
-                    'action' => 'follow',
-                    'message' => $follower->toText(),
-                    'rendered' => $follower->toHtml(),
-                    'item_id' => $target->id,
-                    'item_type' => 'App\Profile'
-                ]);
-            }
+            FollowPipeline::dispatch($follower);
 
             // send Accept to remote profile
             $accept = [
@@ -446,6 +437,12 @@ class Inbox
                 Follower::whereProfileId($profile->id)
                     ->whereFollowingId($following->id)
                     ->delete();
+                Notification::whereProfileId($following->id)
+                    ->whereActorId($profile->id)
+                    ->whereAction('follow')
+                    ->whereItemId($following->id)
+                    ->whereItemType('App\Profile')
+                    ->forceDelete();
                 break;
                 
             case 'Like':