Lines 116-127
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(); |
122 |
return $c->render( status => 200, openapi => $c->objects->to_api($ticket), ); |
123 |
|
123 |
} |
124 |
# Create update if assignee changed |
124 |
catch { |
125 |
if ( $assignee_before ne $ticket->assignee_id ) { |
|
|
126 |
my $patron = $c->stash('koha.user'); |
127 |
my $update = { |
128 |
user_id => $patron->id, |
129 |
ticket_id => $ticket->id, |
130 |
public => 0, |
131 |
assignee_id => $ticket->assignee_id, |
132 |
message => '' |
133 |
}; |
134 |
Koha::Ticket::Update->new($update)->store(); |
135 |
} |
136 |
return $c->render( status => 200, openapi => $c->objects->to_api($ticket) ); |
137 |
} catch { |
125 |
$c->unhandled_exception($_); |
138 |
$c->unhandled_exception($_); |
126 |
}; |
139 |
}; |
127 |
} |
140 |
} |
Lines 197-203
sub add_update {
Link Here
|
197 |
); |
210 |
); |
198 |
} |
211 |
} |
199 |
|
212 |
|
200 |
# Set reporter from session |
213 |
# Set user from session |
201 |
$ticket_update->{user_id} = $patron->id; |
214 |
$ticket_update->{user_id} = $patron->id; |
202 |
# FIXME: We should allow impersonation at a later date to |
215 |
# FIXME: We should allow impersonation at a later date to |
203 |
# allow an API user to submit on behalf of a user |
216 |
# 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; |
239 |
$ticket->set( { status => $ticket_update->{status} } )->store; |
227 |
} |
240 |
} |
228 |
|
241 |
|
|
|
242 |
# Update ticket assignee if needed |
243 |
if ( $ticket_update->{assignee_id} ) { |
244 |
my $ticket = $update->ticket; |
245 |
$ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store; |
246 |
} |
247 |
|
229 |
# Optionally add to message_queue here to notify reporter |
248 |
# Optionally add to message_queue here to notify reporter |
230 |
if ( $update->public ) { |
249 |
if ( $update->public ) { |
231 |
my $notice = |
250 |
my $notice = |