Remove now unused literal "status" in API responses

master
Daniel Berteaud 10 years ago
parent 8f3243a075
commit c5b3f557e9
  1. 56
      vroom.pl

@ -1129,7 +1129,6 @@ post '/create' => sub {
# Create a session for this user, but don't set a role for now # Create a session for this user, but don't set a role for now
$self->login; $self->login;
my $json = { my $json = {
status => 'error',
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
room => $name room => $name
@ -1151,7 +1150,6 @@ post '/create' => sub {
$json->{msg} = $self->l('ERROR_OCCURRED'); $json->{msg} = $self->l('ERROR_OCCURRED');
return $self->render(json => $json, status => 500); return $self->render(json => $json, status => 500);
} }
$json->{status} = 'success';
$json->{err} = ''; $json->{err} = '';
$self->session($name => {role => 'owner'}); $self->session($name => {role => 'owner'});
$self->associate_key_to_room( $self->associate_key_to_room(
@ -1239,8 +1237,8 @@ any '/api' => sub {
if ($err || !$req->{action} || !$req->{param}){ if ($err || !$req->{action} || !$req->{param}){
return $self->render( return $self->render(
json => { json => {
status => 'error', msg => $err,
msg => $err err => $err
}, },
status => 503 status => 503
); );
@ -1250,7 +1248,6 @@ any '/api' => sub {
if (!grep { $req->{param}->{language} eq $_ } @supported_lang){ if (!grep { $req->{param}->{language} eq $_ } @supported_lang){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('UNSUPPORTED_LANG'), msg => $self->l('UNSUPPORTED_LANG'),
err => 'UNSUPPORTED_LANG' err => 'UNSUPPORTED_LANG'
}, },
@ -1259,9 +1256,7 @@ any '/api' => sub {
} }
$self->session(language => $req->{param}->{language}); $self->session(language => $req->{param}->{language});
return $self->render( return $self->render(
json => { json => {}
status => 'success',
}
); );
} }
@ -1276,7 +1271,6 @@ any '/api' => sub {
if (!$res){ if (!$res){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('NOT_ALLOWED'), msg => $self->l('NOT_ALLOWED'),
err => 'NOT_ALLOWED' err => 'NOT_ALLOWED'
}, },
@ -1295,7 +1289,6 @@ any '/api' => sub {
} }
return $self->render( return $self->render(
json => { json => {
status => 'success',
rooms => $rooms rooms => $rooms
} }
); );
@ -1304,7 +1297,6 @@ any '/api' => sub {
if (!$req->{param}->{room}){ if (!$req->{param}->{room}){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_ROOM_NAME_MISSING'), msg => $self->l('ERROR_ROOM_NAME_MISSING'),
err => 'ERROR_ROOM_NAME_MISSING' err => 'ERROR_ROOM_NAME_MISSING'
}, },
@ -1316,7 +1308,6 @@ any '/api' => sub {
if (!$room){ if (!$room){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => sprintf($self->l('ERROR_ROOM_s_DOESNT_EXIST'), $req->{param}->{room}), msg => sprintf($self->l('ERROR_ROOM_s_DOESNT_EXIST'), $req->{param}->{room}),
err => 'ERROR_ROOM_DOESNT_EXIST' err => 'ERROR_ROOM_DOESNT_EXIST'
}, },
@ -1331,7 +1322,6 @@ any '/api' => sub {
if (!$self->valid_email($addr) && $addr ne ''){ if (!$self->valid_email($addr) && $addr ne ''){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_MAIL_INVALID'), msg => $self->l('ERROR_MAIL_INVALID'),
err => 'ERROR_MAIL_INVALID' err => 'ERROR_MAIL_INVALID'
}, },
@ -1357,7 +1347,6 @@ any '/api' => sub {
if (!$token || !$sent){ if (!$token || !$sent){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED' err => 'ERROR_OCCURRED'
}, },
@ -1368,7 +1357,6 @@ any '/api' => sub {
} }
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => sprintf($self->l('INVITE_SENT_TO_s'), join("\n", @$rcpts)), msg => sprintf($self->l('INVITE_SENT_TO_s'), join("\n", @$rcpts)),
} }
); );
@ -1380,7 +1368,6 @@ any '/api' => sub {
my $m = ($req->{action} eq 'lock_room') ? 'ROOM_LOCKED' : 'ROOM_UNLOCKED'; my $m = ($req->{action} eq 'lock_room') ? 'ROOM_LOCKED' : 'ROOM_UNLOCKED';
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l($m), msg => $self->l($m),
err => $m err => $m
} }
@ -1390,7 +1377,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1424,7 +1410,6 @@ any '/api' => sub {
return $self->render( return $self->render(
json => { json => {
msg => $msg, msg => $msg,
status => 'success'
} }
); );
} }
@ -1447,14 +1432,12 @@ any '/api' => sub {
if ($self->modify_room($room) && $self->update_email_notifications($room->{name},$req->{param}->{emails})){ if ($self->modify_room($room) && $self->update_email_notifications($room->{name},$req->{param}->{emails})){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l('ROOM_CONFIG_UPDATED') msg => $self->l('ROOM_CONFIG_UPDATED')
} }
); );
} }
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED' err => 'ERROR_OCCURRED'
}, },
@ -1469,7 +1452,6 @@ any '/api' => sub {
return $self->render( return $self->render(
json => { json => {
msg => $self->l(($req->{param}->{password}) ? 'PASSWORD_PROTECT_SET' : 'PASSWORD_PROTECT_UNSET'), msg => $self->l(($req->{param}->{password}) ? 'PASSWORD_PROTECT_SET' : 'PASSWORD_PROTECT_UNSET'),
status => 'success'
} }
); );
} }
@ -1477,7 +1459,6 @@ any '/api' => sub {
json => { json => {
msg => $self->('ERROR_OCCURRED'), msg => $self->('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1486,7 +1467,6 @@ any '/api' => sub {
if (grep { $req->{param}->{room} eq $_ } (split /[,;]/, $config->{'rooms.common_names'})){ if (grep { $req->{param}->{room} eq $_ } (split /[,;]/, $config->{'rooms.common_names'})){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_COMMON_ROOM_NAME'), msg => $self->l('ERROR_COMMON_ROOM_NAME'),
err => 'ERROR_COMMON_ROOM_NAME' err => 'ERROR_COMMON_ROOM_NAME'
}, },
@ -1499,7 +1479,6 @@ any '/api' => sub {
return $self->render( return $self->render(
json => { json => {
msg => $self->l(($req->{param}->{password}) ? 'ROOM_NOW_RESERVED' : 'ROOM_NO_MORE_RESERVED'), msg => $self->l(($req->{param}->{password}) ? 'ROOM_NOW_RESERVED' : 'ROOM_NO_MORE_RESERVED'),
status => 'success'
} }
); );
} }
@ -1507,7 +1486,6 @@ any '/api' => sub {
json => { json => {
msg => $self->('ERROR_OCCURRED'), msg => $self->('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1518,7 +1496,6 @@ any '/api' => sub {
if ($self->modify_room($room)){ if ($self->modify_room($room)){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l(($set eq 'on') ? 'ROOM_NOW_PERSISTENT' : 'ROOM_NO_MORE_PERSISTENT') msg => $self->l(($set eq 'on') ? 'ROOM_NOW_PERSISTENT' : 'ROOM_NO_MORE_PERSISTENT')
} }
); );
@ -1527,7 +1504,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1539,7 +1515,6 @@ any '/api' => sub {
if ($self->modify_room($room)){ if ($self->modify_room($room)){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l(($set eq 'on') ? 'FORCE_DISPLAY_NAME' : 'NAME_WONT_BE_ASKED') msg => $self->l(($set eq 'on') ? 'FORCE_DISPLAY_NAME' : 'NAME_WONT_BE_ASKED')
} }
); );
@ -1548,7 +1523,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1562,7 +1536,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_MAIL_INVALID'), msg => $self->l('ERROR_MAIL_INVALID'),
err => 'ERROR_MAIL_INVALID', err => 'ERROR_MAIL_INVALID',
status => 'error'
}, },
status => 400 status => 400
); );
@ -1570,7 +1543,6 @@ any '/api' => sub {
elsif ($set eq 'on' && $self->add_notification($room->{name},$email)){ elsif ($set eq 'on' && $self->add_notification($room->{name},$email)){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => sprintf($self->l('s_WILL_BE_NOTIFIED'), $email) msg => sprintf($self->l('s_WILL_BE_NOTIFIED'), $email)
} }
); );
@ -1578,7 +1550,6 @@ any '/api' => sub {
elsif ($set eq 'off' && $self->remove_notification($room->{name},$email)){ elsif ($set eq 'off' && $self->remove_notification($room->{name},$email)){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => sprintf($self->l('s_WONT_BE_NOTIFIED_ANYMORE'), $email) msg => sprintf($self->l('s_WONT_BE_NOTIFIED_ANYMORE'), $email)
} }
); );
@ -1587,7 +1558,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1604,7 +1574,6 @@ any '/api' => sub {
); );
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l('AUTH_SUCCESS') msg => $self->l('AUTH_SUCCESS')
} }
); );
@ -1613,7 +1582,6 @@ any '/api' => sub {
elsif ($room->{owner_password}){ elsif ($room->{owner_password}){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('WRONG_PASSWORD'), msg => $self->l('WRONG_PASSWORD'),
err => 'WRONG_PASSWORD' err => 'WRONG_PASSWORD'
}, },
@ -1625,7 +1593,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('NOT_ALLOWED'), msg => $self->l('NOT_ALLOWED'),
err => 'NOT_ALLOWED', err => 'NOT_ALLOWED',
status => 'error'
}, },
status => 403 status => 403
); );
@ -1640,7 +1607,6 @@ any '/api' => sub {
ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no', ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no',
persistent => ($room->{persistent}) ? 'yes' : 'no', persistent => ($room->{persistent}) ? 'yes' : 'no',
notif => $self->get_notification($room->{name}), notif => $self->get_notification($room->{name}),
status => 'success'
} }
); );
} }
@ -1667,7 +1633,6 @@ any '/api' => sub {
if (!$res){ if (!$res){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED' err => 'ERROR_OCCURRED'
}, },
@ -1683,7 +1648,6 @@ any '/api' => sub {
locked => ($room->{locked}) ? 'yes' : 'no', locked => ($room->{locked}) ? 'yes' : 'no',
ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no', ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no',
notif => $self->get_notification($room->{name}), notif => $self->get_notification($room->{name}),
status => 'success'
}, },
); );
} }
@ -1712,7 +1676,6 @@ any '/api' => sub {
return $self->render( return $self->render(
json => { json => {
role => $role, role => $role,
status => 'success'
} }
); );
} }
@ -1734,9 +1697,7 @@ any '/api' => sub {
); );
} }
return $self->render( return $self->render(
json => { json => {}
status => 'success'
}
); );
} }
# Promote a participant to be owner of a room # Promote a participant to be owner of a room
@ -1745,7 +1706,6 @@ any '/api' => sub {
if (!$peer_id){ if (!$peer_id){
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_PEER_ID_MISSING'), msg => $self->l('ERROR_PEER_ID_MISSING'),
err => 'ERROR_PEER_ID_MISSING' err => 'ERROR_PEER_ID_MISSING'
}, },
@ -1755,14 +1715,12 @@ any '/api' => sub {
elsif ($self->promote_peer({room => $room->{name}, peer_id => $peer_id})){ elsif ($self->promote_peer({room => $room->{name}, peer_id => $peer_id})){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l('PEER_PROMOTED') msg => $self->l('PEER_PROMOTED')
} }
); );
} }
return $self->render( return $self->render(
json => { json => {
status => 'error',
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED' err => 'ERROR_OCCURRED'
}, },
@ -1776,7 +1734,6 @@ any '/api' => sub {
$self->create_etherpad_session($room->{name}))){ $self->create_etherpad_session($room->{name}))){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l('DATA_WIPED') msg => $self->l('DATA_WIPED')
} }
); );
@ -1785,7 +1742,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );
@ -1795,7 +1751,6 @@ any '/api' => sub {
if ($self->create_etherpad_session($room->{name})){ if ($self->create_etherpad_session($room->{name})){
return $self->render( return $self->render(
json => { json => {
status => 'success',
msg => $self->l('SESSION_CREATED') msg => $self->l('SESSION_CREATED')
} }
); );
@ -1804,7 +1759,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
styaus => 503 styaus => 503
); );
@ -1815,7 +1769,6 @@ any '/api' => sub {
return $self->render( return $self->render(
json => { json => {
msg => $self->l('ROOM_DELETED'), msg => $self->l('ROOM_DELETED'),
status => 'success'
} }
); );
} }
@ -1823,7 +1776,6 @@ any '/api' => sub {
json => { json => {
msg => $self->l('ERROR_OCCURRED'), msg => $self->l('ERROR_OCCURRED'),
err => 'ERROR_OCCURRED', err => 'ERROR_OCCURRED',
status => 'error'
}, },
status => 503 status => 503
); );

Loading…
Cancel
Save