|
Lines 108-119
sub update {
Link Here
|
| 108 |
return $c->render_resource_not_found("Ticket") |
108 |
return $c->render_resource_not_found("Ticket") |
| 109 |
unless $ticket; |
109 |
unless $ticket; |
| 110 |
|
110 |
|
|
|
111 |
my $assignee_before = $ticket->assignee_id; |
| 111 |
return try { |
112 |
return try { |
| 112 |
$ticket->set_from_api( $c->req->json ); |
113 |
$ticket->set_from_api( $c->req->json ); |
| 113 |
$ticket->store(); |
114 |
$ticket->store(); |
| 114 |
return $c->render( status => 200, openapi => $c->objects->to_api($ticket), ); |
115 |
|
| 115 |
} |
116 |
# Create update if assignee changed |
| 116 |
catch { |
117 |
if ( $assignee_before ne $ticket->assignee_id ) { |
|
|
118 |
my $patron = $c->stash('koha.user'); |
| 119 |
my $update = { |
| 120 |
user_id => $patron->id, |
| 121 |
ticket_id => $ticket->id, |
| 122 |
public => 0, |
| 123 |
assignee_id => $ticket->assignee_id, |
| 124 |
message => '' |
| 125 |
}; |
| 126 |
Koha::Ticket::Update->new($update)->store(); |
| 127 |
} |
| 128 |
return $c->render( status => 200, openapi => $c->objects->to_api($ticket) ); |
| 129 |
} catch { |
| 117 |
$c->unhandled_exception($_); |
130 |
$c->unhandled_exception($_); |
| 118 |
}; |
131 |
}; |
| 119 |
} |
132 |
} |
|
Lines 179-185
sub add_update {
Link Here
|
| 179 |
); |
192 |
); |
| 180 |
} |
193 |
} |
| 181 |
|
194 |
|
| 182 |
# Set reporter from session |
195 |
# Set user from session |
| 183 |
$ticket_update->{user_id} = $patron->id; |
196 |
$ticket_update->{user_id} = $patron->id; |
| 184 |
# FIXME: We should allow impersonation at a later date to |
197 |
# FIXME: We should allow impersonation at a later date to |
| 185 |
# allow an API user to submit on behalf of a user |
198 |
# allow an API user to submit on behalf of a user |
|
Lines 208-213
sub add_update {
Link Here
|
| 208 |
$ticket->set( { status => $ticket_update->{status} } )->store; |
221 |
$ticket->set( { status => $ticket_update->{status} } )->store; |
| 209 |
} |
222 |
} |
| 210 |
|
223 |
|
|
|
224 |
# Update ticket assignee if needed |
| 225 |
if ( $ticket_update->{assignee_id} ) { |
| 226 |
my $ticket = $update->ticket; |
| 227 |
$ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store; |
| 228 |
} |
| 229 |
|
| 211 |
# Optionally add to message_queue here to notify reporter |
230 |
# Optionally add to message_queue here to notify reporter |
| 212 |
if ( $update->public ) { |
231 |
if ( $update->public ) { |
| 213 |
my $notice = |
232 |
my $notice = |