Lines 116-124
sub update {
Link Here
|
116 |
); |
116 |
); |
117 |
} |
117 |
} |
118 |
|
118 |
|
|
|
119 |
my $assignee_before = $ticket->assignee_id; |
119 |
return try { |
120 |
return try { |
120 |
$ticket->set_from_api( $c->req->json ); |
121 |
$ticket->set_from_api( $c->req->json ); |
121 |
$ticket->store(); |
122 |
$ticket->store(); |
|
|
123 |
|
124 |
# Create update if assignee changed |
125 |
if ( $assignee_before ne $ticket->assignee_id ) { |
126 |
my $patron = $c->stash('koha.user'); |
127 |
my $update = |
128 |
{ user_id => $patron->id, ticket_id => $ticket->id, public => 0, assignee_id => $ticket->assignee_id }; |
129 |
Koha::Ticket::Updates->new($update)->store(); |
130 |
} |
122 |
return $c->render( status => 200, openapi => $ticket->to_api ); |
131 |
return $c->render( status => 200, openapi => $ticket->to_api ); |
123 |
} |
132 |
} |
124 |
catch { |
133 |
catch { |
Lines 197-203
sub add_update {
Link Here
|
197 |
); |
206 |
); |
198 |
} |
207 |
} |
199 |
|
208 |
|
200 |
# Set reporter from session |
209 |
# Set user from session |
201 |
$ticket_update->{user_id} = $patron->id; |
210 |
$ticket_update->{user_id} = $patron->id; |
202 |
# FIXME: We should allow impersonation at a later date to |
211 |
# FIXME: We should allow impersonation at a later date to |
203 |
# allow an API user to submit on behalf of a user |
212 |
# allow an API user to submit on behalf of a user |
Lines 226-231
sub add_update {
Link Here
|
226 |
$ticket->set( { status => $ticket_update->{status} } )->store; |
235 |
$ticket->set( { status => $ticket_update->{status} } )->store; |
227 |
} |
236 |
} |
228 |
|
237 |
|
|
|
238 |
# Update ticket assignee if needed |
239 |
if ( $ticket_update->{assignee_id} ) { |
240 |
my $ticket = $update->ticket; |
241 |
$ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store; |
242 |
} |
243 |
|
229 |
# Optionally add to message_queue here to notify reporter |
244 |
# Optionally add to message_queue here to notify reporter |
230 |
if ( $update->public ) { |
245 |
if ( $update->public ) { |
231 |
my $notice = |
246 |
my $notice = |