ignore rogue matrix call events; support verto.media RPC as a horrible hack; fix NA::Matrix dep

This commit is contained in:
Matthew Hodgson 2014-11-28 14:43:28 +00:00 committed by Paul "LeoNerd" Evans
parent 72c1cc743e
commit 9f4abd59f5
3 changed files with 33 additions and 21 deletions

View File

@ -1 +1,2 @@
vuc.yaml vucbot.yaml
vertobot.yaml

17
contrib/vertobot/bot.pl Normal file → Executable file
View File

@ -6,7 +6,7 @@ use 5.010; # //
use IO::Socket::SSL qw(SSL_VERIFY_NONE); use IO::Socket::SSL qw(SSL_VERIFY_NONE);
use IO::Async::Loop; use IO::Async::Loop;
use Net::Async::WebSocket::Client; use Net::Async::WebSocket::Client;
use Net::Async::Matrix 0.11; use Net::Async::Matrix 0.11_002;
use JSON; use JSON;
use YAML; use YAML;
use Data::UUID; use Data::UUID;
@ -148,11 +148,16 @@ sub on_unknown_event
} }
} }
elsif ($event->{type} eq 'm.call.hangup') { elsif ($event->{type} eq 'm.call.hangup') {
if ($bridgestate->{$room_id}->{matrix_callid} eq $event->{content}->{call_id}) {
send_verto_json_request("verto.bye", { send_verto_json_request("verto.bye", {
"dialogParams" => \%dp, "dialogParams" => \%dp,
"sessid" => $bridgestate->{$room_id}->{sessid}, "sessid" => $bridgestate->{$room_id}->{sessid},
})->get; })->get;
} }
else {
warn "Ignoring unrecognised callid: ".$event->{content}->{call_id};
}
}
else { else {
warn "Unhandled event: $event->{type}"; warn "Unhandled event: $event->{type}";
} }
@ -253,11 +258,13 @@ exit 0;
{ {
my $json = JSON->new->decode( $_[0] ); my $json = JSON->new->decode( $_[0] );
if ($json->{method}) { if ($json->{method}) {
if ($json->{method} eq 'verto.answer') { if (($json->{method} eq 'verto.answer' && $json->{params}->{sdp}) ||
$json->{method} eq 'verto.media') {
my $room_id = $roomid_by_callid->{$json->{params}->{callID}}; my $room_id = $roomid_by_callid->{$json->{params}->{callID}};
my $room = $bot_matrix_rooms{$room_id}; my $room = $bot_matrix_rooms{$room_id};
if ($json->{params}->{sdp}) {
# HACK HACK HACK HACK # HACK HACK HACK HACK
$room->_do_POST_json( "/send/m.call.answer", { $room->_do_POST_json( "/send/m.call.answer", {
call_id => $bridgestate->{$room_id}->{matrix_callid}, call_id => $bridgestate->{$room_id}->{matrix_callid},
@ -268,12 +275,16 @@ exit 0;
}, },
})->then( sub { })->then( sub {
send_verto_json_response( { send_verto_json_response( {
method => "verto.answer", method => $json->{method},
}, $json->{id}); }, $json->{id});
})->get; })->get;
} }
}
else { else {
warn ("[Verto] unhandled method: " . $json->{method}); warn ("[Verto] unhandled method: " . $json->{method});
send_verto_json_response( {
method => $json->{method},
}, $json->{id});
} }
} }
elsif ($json->{result}) { elsif ($json->{result}) {

View File

@ -1,6 +1,6 @@
requires 'parent', 0; requires 'parent', 0;
requires 'Future', '>= 0.29'; requires 'Future', '>= 0.29';
requires 'Net::Async::Matrix', '>= 0.11'; requires 'Net::Async::Matrix', '>= 0.11_002';
requires 'Net::Async::Matrix::Utils'; requires 'Net::Async::Matrix::Utils';
requires 'Net::Async::WebSocket::Protocol', 0; requires 'Net::Async::WebSocket::Protocol', 0;
requires 'Data::UUID', 0; requires 'Data::UUID', 0;