diff --git a/app/Status.php b/app/Status.php index ba1614a60..e944ac242 100644 --- a/app/Status.php +++ b/app/Status.php @@ -28,7 +28,24 @@ class Status extends Model */ 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 = [ 'text', diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 1a210b056..3f41b7e22 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -474,22 +474,25 @@ class Helpers { return; } - $status = new Status; - $status->profile_id = $pid; - $status->url = $url; - $status->uri = $url; - $status->object_url = $id; - $status->caption = strip_tags($activity['content']); - $status->rendered = Purify::clean($activity['content']); - $status->created_at = Carbon::parse($ts)->tz('UTC'); - $status->in_reply_to_id = $reply_to; - $status->local = false; - $status->is_nsfw = $cw; - $status->scope = $scope; - $status->visibility = $scope; - $status->cw_summary = $cw == true && isset($activity['summary']) ? - Purify::clean(strip_tags($activity['summary'])) : null; - $status->save(); + $status = Status::updateOrCreate( + [ + 'uri' => $url + ], [ + 'profile_id' => $pid, + 'url' => $url, + 'object_url' => $id, + 'caption' => strip_tags($activity['content']), + 'rendered' => Purify::clean($activity['content']), + 'created_at' => Carbon::parse($ts)->tz('UTC'), + 'in_reply_to_id' => $reply_to, + 'local' => false, + 'is_nsfw' => $cw, + 'scope' => $scope, + 'visibility' => $scope, + 'cw_summary' => ($cw == true && isset($activity['summary']) ? + Purify::clean(strip_tags($activity['summary'])) : null) + ] + ); if($reply_to == null) { self::importNoteAttachment($activity, $status);