Update inbox handler, upsert statuses to fix duplicate bug. Fixes #2670, #2961, #3556

This commit is contained in:
Daniel Supernault 2022-08-31 21:41:17 -06:00
parent 9d31f73bfa
commit 2c20d9e398
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 37 additions and 17 deletions

View file

@ -28,7 +28,24 @@ class Status extends Model
*/ */
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $fillable = ['profile_id', 'visibility', 'in_reply_to_id', 'reblog_of_id', 'type']; protected $fillable = [
'scope',
'caption',
'rendered',
'url',
'uri',
'object_url',
'created_at',
'local',
'is_nsfw',
'scope',
'cw_summary',
'profile_id',
'visibility',
'in_reply_to_id',
'reblog_of_id',
'type'
];
const STATUS_TYPES = [ const STATUS_TYPES = [
'text', 'text',

View file

@ -474,22 +474,25 @@ class Helpers {
return; return;
} }
$status = new Status; $status = Status::updateOrCreate(
$status->profile_id = $pid; [
$status->url = $url; 'uri' => $url
$status->uri = $url; ], [
$status->object_url = $id; 'profile_id' => $pid,
$status->caption = strip_tags($activity['content']); 'url' => $url,
$status->rendered = Purify::clean($activity['content']); 'object_url' => $id,
$status->created_at = Carbon::parse($ts)->tz('UTC'); 'caption' => strip_tags($activity['content']),
$status->in_reply_to_id = $reply_to; 'rendered' => Purify::clean($activity['content']),
$status->local = false; 'created_at' => Carbon::parse($ts)->tz('UTC'),
$status->is_nsfw = $cw; 'in_reply_to_id' => $reply_to,
$status->scope = $scope; 'local' => false,
$status->visibility = $scope; 'is_nsfw' => $cw,
$status->cw_summary = $cw == true && isset($activity['summary']) ? 'scope' => $scope,
Purify::clean(strip_tags($activity['summary'])) : null; 'visibility' => $scope,
$status->save(); 'cw_summary' => ($cw == true && isset($activity['summary']) ?
Purify::clean(strip_tags($activity['summary'])) : null)
]
);
if($reply_to == null) { if($reply_to == null) {
self::importNoteAttachment($activity, $status); self::importNoteAttachment($activity, $status);