Skip to content

Commit 4d309f8

Browse files
authored
🚑 Only log status when all relevant fields have been updated + make moderation_notes nullable again (#3160)
1 parent 2ae32c3 commit 4d309f8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

‎app/Http/Controllers/Frontend/Admin/StatusEditController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ public function edit(Request $request): RedirectResponse {
106106
StatusUpdateEvent::dispatch($status->refresh());
107107

108108
$payload = [
109-
'visibility' => $validated['visibility'],
110-
'event_id' => $validated['event_id'],
109+
'visibility' => $validated['visibility'],
110+
'event_id' => $validated['event_id'],
111+
'moderation_notes' => null,
111112
];
112113

113114
if ($status->body !== $validated['body']) {

‎app/Models/Status.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ class Status extends Model
4545

4646
use HasFactory, LogsActivity;
4747

48-
protected $fillable = [
48+
protected $fillable = [
4949
'user_id', 'body', 'business', 'visibility', 'event_id', 'mastodon_post_id', 'client_id',
5050
'moderation_notes', 'lock_visibility', 'hide_body',
5151
];
52-
protected $hidden = ['user_id', 'business'];
53-
protected $appends = ['favorited', 'statusInvisibleToMe', 'description'];
54-
protected $casts = [
52+
protected $hidden = ['user_id', 'business'];
53+
protected $appends = ['favorited', 'statusInvisibleToMe', 'description'];
54+
protected $casts = [
5555
'id' => 'integer',
5656
'user_id' => 'integer',
5757
'business' => Business::class,
@@ -63,6 +63,7 @@ class Status extends Model
6363
'lock_visibility' => 'boolean',
6464
'hide_body' => 'boolean'
6565
];
66+
protected static array $recordEvents = ['updated'];
6667

6768
public function user(): BelongsTo {
6869
return $this->belongsTo(User::class);
@@ -130,6 +131,9 @@ public function getStatusInvisibleToMeAttribute(): bool {
130131
}
131132

132133
public function getActivitylogOptions(): LogOptions {
133-
return LogOptions::defaults()->logOnly(['moderation_notes', 'lock_visibility', 'hide_body']);
134+
return LogOptions::defaults()
135+
->logOnly(['moderation_notes', 'lock_visibility', 'hide_body'])
136+
->logOnlyDirty()
137+
->dontSubmitEmptyLogs();
134138
}
135139
}

0 commit comments

Comments
 (0)