瀏覽代碼

Merge pull request #4138 from pixelfed/staging

Staging
daniel 2 年之前
父節點
當前提交
f84439df23
共有 4 個文件被更改,包括 38 次插入24 次删除
  1. 3 1
      CHANGELOG.md
  2. 16 12
      app/Jobs/MentionPipeline/MentionPipeline.php
  3. 18 10
      app/Jobs/StatusPipeline/StatusTagsPipeline.php
  4. 1 1
      app/Like.php

+ 3 - 1
CHANGELOG.md

@@ -88,7 +88,9 @@
 - Update SharePipeline, fix share handling and notification generation ([83e1e203](https://github.com/pixelfed/pixelfed/commit/83e1e203))
 - Update SharePipeline, fix ReblogService and undo handling ([016c6e41](https://github.com/pixelfed/pixelfed/commit/016c6e41))
 - Update AP Helpers, fix media validation bug that would reject media with alttext/name longer than 255 chars and store remote alt text if set ([a7f58349](https://github.com/pixelfed/pixelfed/commit/a7f58349))
--  ([](https://github.com/pixelfed/pixelfed/commit/))
+- Update MentionPipeline, store non-local mentions ([17149230](https://github.com/pixelfed/pixelfed/commit/17149230))
+- Update Like model, increase rate limit to 500 likes per day ([ab7676f9](https://github.com/pixelfed/pixelfed/commit/))
+-  ([](https://github.com/pixelfed/pixelfed/commit/ab7676f9))
 
 ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)
 

+ 16 - 12
app/Jobs/MentionPipeline/MentionPipeline.php

@@ -10,6 +10,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
+use App\Services\StatusService;
 
 class MentionPipeline implements ShouldQueue
 {
@@ -59,17 +60,20 @@ class MentionPipeline implements ShouldQueue
             return true;
         }
 
-        try {
-            $notification = new Notification();
-            $notification->profile_id = $target;
-            $notification->actor_id = $actor->id;
-            $notification->action = 'mention';
-            $notification->message = $mention->toText();
-            $notification->rendered = $mention->toHtml();
-            $notification->item_id = $status->id;
-            $notification->item_type = "App\Status";
-            $notification->save();
-        } catch (Exception $e) {
-        }
+        Notification::firstOrCreate(
+            [
+                'profile_id' => $target,
+                'actor_id' => $actor->id,
+                'action' => 'mention',
+                'item_type' => 'App\Status',
+                'item_id' => $status->id,
+            ],
+            [
+                'message' => $mention->toText(),
+                'rendered' => $mention->toHtml()
+            ]
+        );
+
+        StatusService::del($status->id);
     }
 }

+ 18 - 10
app/Jobs/StatusPipeline/StatusTagsPipeline.php

@@ -8,14 +8,15 @@ use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
+use App\Services\AccountService;
 use App\Services\CustomEmojiService;
 use App\Services\StatusService;
 use App\Jobs\MentionPipeline\MentionPipeline;
 use App\Mention;
-use App\Services\AccountService;
 use App\Hashtag;
 use App\StatusHashtag;
 use App\Services\TrendingHashtagService;
+use App\Util\ActivityPub\Helpers;
 
 class StatusTagsPipeline implements ShouldQueue
 {
@@ -89,17 +90,24 @@ class StatusTagsPipeline implements ShouldQueue
 			return $tag &&
 				$tag['type'] == 'Mention' &&
 				isset($tag['href']) &&
-				substr($tag['href'], 0, 8) === 'https://' &&
-				parse_url($tag['href'], PHP_URL_HOST) == config('pixelfed.domain.app');
+				substr($tag['href'], 0, 8) === 'https://';
 		})
 		->map(function($tag) use($status) {
-			$parts = explode('/', $status['href']);
-			if(!$parts) {
-				return;
-			}
-			$pid = AccountService::usernameToId(end($parts));
-			if(!$pid) {
-				return;
+			if(Helpers::validateLocalUrl($tag['href'])) {
+				$parts = explode('/', $tag['href']);
+				if(!$parts) {
+					return;
+				}
+				$pid = AccountService::usernameToId(end($parts));
+				if(!$pid) {
+					return;
+				}
+			} else {
+				$acct = Helpers::profileFetch($tag['href']);
+				if(!$acct) {
+					return;
+				}
+				$pid = $acct->id;
 			}
 			$mention = new Mention;
 			$mention->status_id = $status->id;

+ 1 - 1
app/Like.php

@@ -9,7 +9,7 @@ class Like extends Model
 {
     use SoftDeletes;
 
-    const MAX_PER_DAY = 200;
+    const MAX_PER_DAY = 500;
 
     /**
      * The attributes that should be mutated to dates.