Browse Source

Implement the Jingle Finish event

feature/templater
Timothée Jaussoin 3 months ago
parent
commit
e3e6e3e9c9
  1. 1
      CHANGELOG.md
  2. 5
      app/Message.php
  3. 26
      app/Widgets/Chat/Chat.php
  4. 1
      app/Widgets/Chat/_chat_jingle_finish.tpl
  5. 2
      app/Widgets/Chats/_chats_item.tpl
  6. 6
      app/Widgets/Visio/Visio.php
  7. 1
      public/scripts/movim_visio.js
  8. 1
      src/Moxl/Xec/Handler.php
  9. 33
      src/Moxl/Xec/Payload/JingleFinish.php
  10. 3
      src/Moxl/Xec/Payload/JingleReject.php

1
CHANGELOG.md

@ -19,6 +19,7 @@ v0.32 (master)
* Fix #1459 Allow public posts to be read without Javascript enabled
* Fix #1460 Change geturl and seturl to text in Upload table
* Try to Resolve Pubsub Posts from incoming messages if they are not present in the database
* Implement the Jingle Finish event
v0.31
---------------------------

5
app/Message.php

@ -42,11 +42,12 @@ class Message extends Model
'chat',
'headline',
'invitation',
'jingle_end',
'jingle_finish',
'jingle_incoming',
'jingle_outgoing',
'jingle_end',
'jingle_reject',
'jingle_retract',
'jingle_reject'
];
public const MESSAGE_TYPE_MUC = [
'groupchat',

26
app/Widgets/Chat/Chat.php

@ -177,17 +177,18 @@ class Chat extends \Movim\Widget\Base
if (
$message->isEmpty() && !in_array($message->type, [
'jingle_end',
'jingle_finish',
'jingle_incoming',
'jingle_outgoing',
'jingle_end',
'muc_owner',
'jingle_retract',
'jingle_reject',
'muji_propose',
'muji_retract',
'jingle_retract',
'muc_admin',
'muc_member',
'muc_outcast',
'muc_member'
'muc_owner',
'muji_propose',
'muji_retract',
])
) {
return;
@ -1639,15 +1640,16 @@ class Chat extends \Movim\Widget\Base
// Internal messages
if (in_array($message->type, [
'muc_owner',
'muc_admin',
'muc_outcast',
'muc_member',
'jingle_reject',
'jingle_finish',
'jingle_incoming',
'jingle_outgoing',
'jingle_reject',
'jingle_retract',
'muji_propose'
'muc_admin',
'muc_member',
'muc_outcast',
'muc_owner',
'muji_propose',
])) {
$view = $this->tpl();
$view->assign('message', $message);

1
app/Widgets/Chat/_chat_jingle_finish.tpl

@ -0,0 +1 @@
<i class="material-symbols icon red">phone_disabled</i> {$c->__('chat.jingle_end')}

2
app/Widgets/Chats/_chats_item.tpl

@ -86,6 +86,8 @@
<i class="material-symbols icon gray">phone_missed</i> {$c->__('chat.jingle_retract')}
{elseif="$message->type == 'jingle_reject'"}
<i class="material-symbols icon orange">phone_missed</i> {$c->__('chat.jingle_reject')}
{elseif="$message->type == 'jingle_finish'"}
<i class="material-symbols icon red">phone_disabled</i> {$c->__('chat.jingle_end')}
{elseif="$message->type == 'jingle_outgoing'"}
<i class="material-symbols icon blue">call</i> {$c->__('chat.jingle_outgoing')}
{elseif="$message->type == 'jingle_end'"}

6
app/Widgets/Visio/Visio.php

@ -48,6 +48,7 @@ class Visio extends Base
$this->registerEvent('jingleaccept', 'onAccept');
$this->registerEvent('jingleretract', 'onRetract');
$this->registerEvent('jinglereject', 'onReject');
$this->registerEvent('jinglefinish', 'onFinish');
$this->registerEvent('jingle_sessioninitiate', 'onInitiateSDP');
//$this->registerEvent('jingle_sessioninitiate_erroritemnotfound', 'onNotFound');
@ -209,6 +210,11 @@ class Visio extends Base
$this->onTerminate($packet);
}
public function onFinish(Packet $packet)
{
$this->onTerminate($packet);
}
/*public function onNotFound(Packet $packet)
{
(CurrentCall::getInstance())->stop(\baseJid($packet->from), $packet->content);

1
public/scripts/movim_visio.js

@ -334,5 +334,6 @@ Visio_ajaxHttpGetStates();
MovimWebsocket.attach(() => {
if (MovimVisio.services.length == 0) {
Visio_ajaxResolveServices();
Visio_ajaxTryForceStop();
}
});

1
src/Moxl/Xec/Handler.php

@ -172,6 +172,7 @@ class Handler
'0c0238797befe918ac81efaa0200771b' => 'JingleProceed',
'46ee3ca42af934e8a3b4d42062817aa8' => 'JingleRetract',
'44d0c16e222fcdee6961c8939b647e15' => 'JingleReject',
'1622ee132ba08e9ccf42bfa3956931f9' => 'JingleFinish',
'd84d4b89d43e88a244197ccf499de8d8' => 'Jingle',
// TODO: Update the handlers to XEP-0482 when Dino is updated

33
src/Moxl/Xec/Payload/JingleFinish.php

@ -0,0 +1,33 @@
<?php
namespace Moxl\Xec\Payload;
use App\Message;
use Movim\CurrentCall;
class JingleFinish extends Payload
{
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
// We can only reject the current session
if (!CurrentCall::getInstance()->hasId((string)$stanza->attributes()->id)) return;
$from = (string)$parent->attributes()->from;
if (!$stanza->muji) {
$message = Message::eventMessageFactory(
'jingle',
baseJid($from),
(string)$stanza->attributes()->id
);
$message->type = 'jingle_finish';
$message->save();
$this->pack($message);
$this->event('jingle_message');
}
$this->pack((string)$stanza->attributes()->id, (string)$parent->attributes()->from);
$this->deliver();
}
}

3
src/Moxl/Xec/Payload/JingleReject.php

@ -10,8 +10,7 @@ class JingleReject extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
// We can only reject the current session
$jingleSid = CurrentCall::getInstance()->id;
if ($jingleSid && (string)$stanza->attributes()->id != $jingleSid) return;
if (!CurrentCall::getInstance()->hasId((string)$stanza->attributes()->id)) return;
$from = (string)$parent->attributes()->from;

Loading…
Cancel
Save