MT#19795 rtc api consider app id for sessions

a reseller can manage multiple apps. these will have different networks in the
future, enabling one to allow or disallow networks depending on that.
in that case, the subscriber must have the possibility to select, which app they
are going to use. if none is selected, the default app is used.

Change-Id: I191bf3911004d405086821a89b46e4fa59379a46
changes/33/6933/3
Gerhard Jungwirth 10 years ago committed by Dominik Kukacka
parent 5c5adb5b9a
commit 25792a1d9f

@ -40,6 +40,7 @@ sub hal_from_item {
});
if ($rtc_session) {
$resource->{rtc_browser_token} = $rtc_session->{data}{token};
$resource->{rtc_app_name} = $rtc_session->{data}{app}{name} if $rtc_session->{data}{app}{name};
} else {
# here either delete our DB entry, or recreate it accordingly
$item->delete;

@ -171,9 +171,16 @@ sub get_session {
my ($self, $session_id) = @_;
my $ua = $self->ua;
return $self->_create_response(
my $session = $self->_create_response(
$ua->get($self->host . "/sessions/id/$session_id"),
);
if ($session->{data}) {
my ($app_id) = $session->{data}{app}{href} =~ m!apps/id/(.*)$!;
my $item_res = $ua->get($self->host . "/apps/id/$app_id");
my $item_data = decode_json($item_res->content);
$session->{data}{app} = $item_data;
}
return $session;
}
sub delete_all_sessions {

@ -105,8 +105,8 @@ sub _create_rtc_user {
# 4. create related app
my $app = $comx->create_app(
$reseller_name . '_app',
$reseller_name . 'www.sipwise.com',
$reseller_name . '_default_app',
$reseller_name . '.www.sipwise.com',
$user->{data}{id},
);
if ($app->{code} != 201) {
@ -632,8 +632,13 @@ sub create_rtc_session {
my $comx_apps = $comx->get_apps_by_user_id($rtc_user->rtc_user_id);
my $comx_app;
if ($comx_apps->{data} && @{ $comx_apps->{data} }){
$comx_app = $comx_apps->{data}[0];
} else {
if ($resource->{rtc_app_name}) {
($comx_app) = grep {$_->{name} eq $resource->{rtc_app_name}} @{ $comx_apps->{data} };
} else { # default app
($comx_app) = grep {$_->{name} =~ m/_default_app$/;} @{ $comx_apps->{data} };
}
}
unless ($comx_app) {
return unless &{$err_code}(
'create_rtc_session: Could not find app.');
}

Loading…
Cancel
Save