Travel API: comment support
This commit is contained in:
parent
46fc64de48
commit
7ae60f2ea4
3 changed files with 15 additions and 4 deletions
|
@ -806,8 +806,8 @@ sub startup {
|
|||
|
||||
$self->helper(
|
||||
'update_in_transit_comment' => sub {
|
||||
my ( $self, $comment ) = @_;
|
||||
my $uid = $self->current_user->{id};
|
||||
my ( $self, $comment, $uid ) = @_;
|
||||
$uid //= $self->current_user->{id};
|
||||
|
||||
my $status = $self->pg->db->select( 'in_transit', ['user_data'],
|
||||
{ user_id => $uid } )->expand->hash;
|
||||
|
|
|
@ -260,6 +260,10 @@ sub travel_v1 {
|
|||
|
||||
my ( $train, $error )
|
||||
= $self->checkin( $from_station, $train_id, $uid );
|
||||
if ( $payload->{comment} ) {
|
||||
$self->update_in_transit_comment(
|
||||
sanitize( q{}, $payload->{comment} ), $uid );
|
||||
}
|
||||
if ( $to_station and not $error ) {
|
||||
( $train, $error ) = $self->checkout( $to_station, 0, $uid );
|
||||
}
|
||||
|
@ -284,6 +288,11 @@ sub travel_v1 {
|
|||
elsif ( $payload->{action} eq 'checkout' ) {
|
||||
my $to_station = sanitize( q{}, $payload->{toStation} );
|
||||
|
||||
if ( $payload->{comment} ) {
|
||||
$self->update_in_transit_comment(
|
||||
sanitize( q{}, $payload->{comment} ), $uid );
|
||||
}
|
||||
|
||||
my ( $train, $error )
|
||||
= $self->checkout( $to_station, $payload->{force} ? 1 : 0, $uid );
|
||||
if ($error) {
|
||||
|
|
|
@ -85,7 +85,8 @@
|
|||
"no" : "1234",<br/>
|
||||
}<br/>
|
||||
"fromStation" : "Essen Hbf", (DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
|
||||
"toStation" : "Berlin Hbf" (optional, DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
|
||||
"toStation" : "Berlin Hbf", (optional, DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
|
||||
"comment" : "Beliebiger Text" (optional)<br/>
|
||||
}
|
||||
</p>
|
||||
<p>Payload zur Wahl eines neuen Ziels, wenn bereits eingecheckt:</p>
|
||||
|
@ -94,7 +95,8 @@
|
|||
"token" : "<%= $uid %>-<%= $token->{import} // 'TOKEN' %>",<br/>
|
||||
"action" : "checkout",<br/>
|
||||
"force" : True/False, (wenn True: Checkout jetzt durchführen und auftretende Fehler ignorieren. Kann zu Logeinträgen ohne Ankunftsdaten führen.)<br/>
|
||||
"toStation" : "Berlin Hbf" (DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
|
||||
"toStation" : "Berlin Hbf", (DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
|
||||
"comment" : "Beliebiger Text" (optional)<br/>
|
||||
}
|
||||
</p>
|
||||
<p>Payload zum Rückgängigmachen eines Checkins (nur während der Fahrt möglich):</p>
|
||||
|
|
Loading…
Reference in a new issue