Skip to content

Commit

Permalink
Update Inbox handler, fix missing object_url and uri fields for direc…
Browse files Browse the repository at this point in the history
…t statuses
  • Loading branch information
dansup committed Dec 8, 2023
1 parent dec061f commit a0157fc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/Util/ActivityPub/Inbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ public function handleNoteCreate()
}

if($actor->followers_count == 0) {
if(config('federation.activitypub.ingest.store_notes_without_followers')) {
} else if(FollowerService::followerCount($actor->id, true) == 0) {
if(config('federation.activitypub.ingest.store_notes_without_followers')) {
} else if(FollowerService::followerCount($actor->id, true) == 0) {
return;
}
}
Expand Down Expand Up @@ -401,6 +401,8 @@ public function handleDirectMessage()
$status->visibility = 'direct';
$status->scope = 'direct';
$status->url = $activity['id'];
$status->uri = $activity['id'];
$status->object_url = $activity['id'];
$status->in_reply_to_profile_id = $profile->id;
$status->save();

Expand Down Expand Up @@ -703,12 +705,17 @@ public function handleDeleteActivity()
return;
}
$status = Status::whereProfileId($profile->id)
->whereObjectUrl($id)
->where(function($q) use($id) {
return $q->where('object_url', $id)
->orWhere('url', $id);
})
->first();
if(!$status) {
return;
}
FeedRemoveRemotePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
if($status->scope && $status->scope != 'direct') {
FeedRemoveRemotePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
}
RemoteStatusDelete::dispatch($status)->onQueue('high');
return;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Status;
use Illuminate\Database\UniqueConstraintViolationException;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
foreach(Status::whereScope('direct')->whereNotNull('url')->whereNull('object_url')->lazyById(50, 'id') as $status) {
try {
$status->object_url = $status->url;
$status->uri = $status->url;
$status->save();
} catch (Exception | UniqueConstraintViolationException $e) {
continue;
}
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
}
};

0 comments on commit a0157fc

Please sign in to comment.