|
@@ -42,6 +42,7 @@ use App\Services\StatusService;
|
|
use App\Services\UserFilterService;
|
|
use App\Services\UserFilterService;
|
|
use App\Services\NetworkTimelineService;
|
|
use App\Services\NetworkTimelineService;
|
|
use App\Models\Conversation;
|
|
use App\Models\Conversation;
|
|
|
|
+use App\Models\RemoteReport;
|
|
use App\Jobs\ProfilePipeline\IncrementPostCount;
|
|
use App\Jobs\ProfilePipeline\IncrementPostCount;
|
|
use App\Jobs\ProfilePipeline\DecrementPostCount;
|
|
use App\Jobs\ProfilePipeline\DecrementPostCount;
|
|
|
|
|
|
@@ -122,6 +123,10 @@ class Inbox
|
|
$this->handleStoryReplyActivity();
|
|
$this->handleStoryReplyActivity();
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+ case 'Flag':
|
|
|
|
+ $this->handleFlagActivity();
|
|
|
|
+ break
|
|
|
|
+
|
|
// case 'Update':
|
|
// case 'Update':
|
|
// (new UpdateActivity($this->payload, $this->profile))->handle();
|
|
// (new UpdateActivity($this->payload, $this->profile))->handle();
|
|
// break;
|
|
// break;
|
|
@@ -1140,4 +1145,80 @@ class Inbox
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function handleFlagActivity()
|
|
|
|
+ {
|
|
|
|
+ if(!isset(
|
|
|
|
+ $this->payload['id'],
|
|
|
|
+ $this->payload['type'],
|
|
|
|
+ $this->payload['actor'],
|
|
|
|
+ $this->payload['content'],
|
|
|
|
+ $this->payload['object']
|
|
|
|
+ )) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $id = $this->payload['id'];
|
|
|
|
+ $actor = $this->payload['actor'];
|
|
|
|
+ $content = Purify::clean($this->payload['content']);
|
|
|
|
+ $object = $this->payload['object'];
|
|
|
|
+
|
|
|
|
+ if(Helpers::validateLocalUrl($id) || parse_url($id, PHP_URL_HOST) !== parse_url($actor, PHP_URL_HOST)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!is_array($object) || empty($object)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(count($object) > 40) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $objects = collect([]);
|
|
|
|
+ $accountId = null;
|
|
|
|
+
|
|
|
|
+ foreach($object as $objectUrl) {
|
|
|
|
+ if(!Helpers::validateLocalUrl($objectUrl)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(str_contains($objectUrl, '/users/')) {
|
|
|
|
+ $username = last(explode('/', $objectUrl));
|
|
|
|
+ $profileId = Profile::whereUsername($username)->first();
|
|
|
|
+ if($profileId) {
|
|
|
|
+ $accountId = $profileId->id;
|
|
|
|
+ }
|
|
|
|
+ } else if(str_contains($object_url, '/p/')) {
|
|
|
|
+ $postId = last(explode('/', $objectUrl));
|
|
|
|
+ $objects->push($postId);
|
|
|
|
+ } else {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!$accountId || !$objects->count()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $instanceHost = parse_url($id, PHP_URL_HOST);
|
|
|
|
+
|
|
|
|
+ $instance = Instance::updateOrCreate([
|
|
|
|
+ 'domain' => $instanceHost
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $report = new RemoteReport;
|
|
|
|
+ $report->status_ids = $objects->toArray();
|
|
|
|
+ $report->comment = $content;
|
|
|
|
+ $report->account_id = $accountId;
|
|
|
|
+ $report->uri = $id;
|
|
|
|
+ $report->instance_id = $instance->id;
|
|
|
|
+ $report->report_meta = [
|
|
|
|
+ 'actor' => $actor,
|
|
|
|
+ 'object' => $object
|
|
|
|
+ ];
|
|
|
|
+ $report->save();
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|