From 67823bc788ce744e1228a8602b9a5aa805771ced Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 10 Jul 2020 14:38:17 +0100 Subject: Centralise update creation to include fields. Given the user, we can infer the name if not provided, and the extra data if a staff user. We can also provide defaults for various other fields. Always have superuser take precedence over from_body. --- perllib/FixMyStreet/App/Controller/Moderate.pm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Moderate.pm') diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index f4143f0b4..c936f13c0 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -340,13 +340,8 @@ sub moderate_state : Private { $problem->state($new_state); $problem->add_to_comments( { text => $c->stash->{moderation_reason}, - created => \'current_timestamp', - confirmed => \'current_timestamp', - user_id => $c->user->id, - name => $c->user->from_body ? $c->user->from_body->name : $c->user->name, - state => 'confirmed', - mark_fixed => 0, - anonymous => $c->user->from_body ? 0 : 1, + user => $c->user->obj, + anonymous => $c->user->is_superuser || $c->user->from_body ? 0 : 1, problem_state => $new_state, } ); return 'state'; -- cgit v1.2.3