Skip to content

Commit a0157fc

Browse files
committed
Update Inbox handler, fix missing object_url and uri fields for direct statuses
1 parent dec061f commit a0157fc

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

app/Util/ActivityPub/Inbox.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ public function handleNoteCreate()
282282
}
283283

284284
if($actor->followers_count == 0) {
285-
if(config('federation.activitypub.ingest.store_notes_without_followers')) {
286-
} else if(FollowerService::followerCount($actor->id, true) == 0) {
285+
if(config('federation.activitypub.ingest.store_notes_without_followers')) {
286+
} else if(FollowerService::followerCount($actor->id, true) == 0) {
287287
return;
288288
}
289289
}
@@ -401,6 +401,8 @@ public function handleDirectMessage()
401401
$status->visibility = 'direct';
402402
$status->scope = 'direct';
403403
$status->url = $activity['id'];
404+
$status->uri = $activity['id'];
405+
$status->object_url = $activity['id'];
404406
$status->in_reply_to_profile_id = $profile->id;
405407
$status->save();
406408

@@ -703,12 +705,17 @@ public function handleDeleteActivity()
703705
return;
704706
}
705707
$status = Status::whereProfileId($profile->id)
706-
->whereObjectUrl($id)
708+
->where(function($q) use($id) {
709+
return $q->where('object_url', $id)
710+
->orWhere('url', $id);
711+
})
707712
->first();
708713
if(!$status) {
709714
return;
710715
}
711-
FeedRemoveRemotePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
716+
if($status->scope && $status->scope != 'direct') {
717+
FeedRemoveRemotePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
718+
}
712719
RemoteStatusDelete::dispatch($status)->onQueue('high');
713720
return;
714721
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
use App\Status;
7+
use Illuminate\Database\UniqueConstraintViolationException;
8+
9+
return new class extends Migration
10+
{
11+
/**
12+
* Run the migrations.
13+
*/
14+
public function up(): void
15+
{
16+
foreach(Status::whereScope('direct')->whereNotNull('url')->whereNull('object_url')->lazyById(50, 'id') as $status) {
17+
try {
18+
$status->object_url = $status->url;
19+
$status->uri = $status->url;
20+
$status->save();
21+
} catch (Exception | UniqueConstraintViolationException $e) {
22+
continue;
23+
}
24+
}
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*/
30+
public function down(): void
31+
{
32+
}
33+
};

0 commit comments

Comments
 (0)