Browse Source

Fix maximum video width in Chat

Load the first frame of the videos to have a nice preview
Add a Registration required message when exploring gateways services
Hide the Room jid when adding a gateway one
Add selectgroup in resulting rooms when exploring gateways
Put first the user server gateway in the list
Update the dependencies
pull/1228/head
Timothée Jaussoin 2 years ago
parent
commit
260d3a8582
  1. 1
      app/widgets/Chat/chat.css
  2. 2
      app/widgets/Chat/chat.js
  3. 1
      app/widgets/Rooms/locales.ini
  4. 193
      app/widgets/RoomsUtils/RoomsUtils.php
  5. 2
      app/widgets/RoomsUtils/_rooms_add.tpl
  6. 14
      app/widgets/RoomsUtils/_rooms_gateway_rooms.tpl
  7. 3
      app/widgets/RoomsUtils/roomsutils.css
  8. 114
      composer.lock
  9. 10
      public/theme/css/form.css
  10. 5
      src/Moxl/Xec/Action/Disco/Items.php

1
app/widgets/Chat/chat.css

@ -325,6 +325,7 @@ main:not(.enabled) #chat_widget {
#chat_widget ul li div.bubble.file video:not(.gif) {
height: 200px;
max-width: 100%;
}
#chat_widget li div.bubble.sticker.file img:not(.emoji):not(.hfr) {

2
app/widgets/Chat/chat.js

@ -1408,7 +1408,7 @@ var Chat = {
},
getVideoPlayer: function (file) {
var video = document.createElement('video');
video.setAttribute('src', file.uri);
video.setAttribute('src', file.uri + '#t=0.5');
video.setAttribute('loop', 'loop');
if (file.thumbnail && Object.keys(file.thumbnail).length !== 0) {

1
app/widgets/Rooms/locales.ini

@ -16,6 +16,7 @@ owner = Owner
admin = Admin
visitor = Visitor
explore_placeholder = Name or description
disco_registration_required = A registration is required before using the service
[chatrooms]
title = Chatrooms

193
app/widgets/RoomsUtils/RoomsUtils.php

@ -26,7 +26,7 @@ use Moxl\Xec\Action\Muc\ChangeAffiliation;
use Moxl\Xec\Action\Presence\Muc;
use Moxl\Xec\Action\Presence\Unavailable;
include_once WIDGETS_PATH.'Chat/Chat.php';
include_once WIDGETS_PATH . 'Chat/Chat.php';
class RoomsUtils extends Base
{
@ -38,6 +38,7 @@ class RoomsUtils extends Base
$this->registerEvent('vcard_set_handle', 'onAvatarSet', 'chat');
$this->registerEvent('disco_items_nosave_handle', 'onDiscoGateway');
$this->registerEvent('disco_items_nosave_error', 'onDiscoGatewayError');
$this->registerEvent('disco_items_errorregistrationrequired', 'onDiscoRegistrationRequired');
$this->registerEvent('muc_creategroupchat_handle', 'onChatroomCreated');
$this->registerEvent('muc_createchannel_handle', 'onChatroomCreated');
$this->registerEvent('muc_changeaffiliation_handle', 'onAffiliationChanged');
@ -49,6 +50,7 @@ class RoomsUtils extends Base
$this->registerEvent('presence_muc_errorgone', 'onPresenceMucNotAllowed');
$this->addjs('roomsutils.js');
$this->addcss('roomsutils.css');
}
/**
@ -77,19 +79,19 @@ class RoomsUtils extends Base
$view->assign('linksCount', $linksCount);
$view->assign('presences', $conference->presences()
->with('capability')
->get());
->with('capability')
->get());
if ($conference->isGroupChat()) {
$view->assign('members', $conference->activeMembers()
->with('contact')
->get());
->with('contact')
->get());
}
$view->assign('banned', $conference->members()
->with('contact')
->where('affiliation', '=', 'outcast')
->get());
->with('contact')
->where('affiliation', '=', 'outcast')
->get());
$view->assign('me', $this->user->id);
@ -120,14 +122,14 @@ class RoomsUtils extends Base
public function ajaxGetDrawerFingerprints($room, $deviceId)
{
$fingerprints = $this->user->bundles()
->whereIn('jid', function ($query) use ($room) {
$query->select('jid')
->from('members')
->where('conference', $room);
})
->with('capability.identities')
->get()
->mapToGroups(fn ($tuple) => [$tuple['jid'] => $tuple]);
->whereIn('jid', function ($query) use ($room) {
$query->select('jid')
->from('members')
->where('conference', $room);
})
->with('capability.identities')
->get()
->mapToGroups(fn ($tuple) => [$tuple['jid'] => $tuple]);
$tpl = $this->tpl();
$tpl->assign('fingerprints', $fingerprints);
@ -153,8 +155,8 @@ class RoomsUtils extends Base
$view = $this->tpl();
$view->assign('room', $this->user->session->conferences()
->where('conference', $room)
->first());
->where('conference', $room)
->first());
Dialog::fill($view->draw('_rooms_avatar'));
}
@ -204,6 +206,11 @@ class RoomsUtils extends Base
Toast::send($this->__('chatrooms.notallowed'));
}
public function onDiscoRegistrationRequired($packet)
{
Toast::send($this->__('rooms.disco_registration_required'));
}
/**
* @brief Affiliation changed for a user
*/
@ -274,12 +281,12 @@ class RoomsUtils extends Base
// Disconnect properly
$nick = $values['nick'] ?? $this->user->session->username;
$session = Session::start();
$session->delete($values['jid'] . '/' .$nick);
$session->delete($values['jid'] . '/' . $nick);
$pu = new Unavailable;
$pu->setTo($values['jid'])
->setResource($nick)
->request();
->setResource($nick)
->request();
$this->user->session->presences()->where('jid', $values['jid'])->delete();
//$this->rpc('RoomsUtils.configureDisconnect', $values['jid']);
@ -298,8 +305,8 @@ class RoomsUtils extends Base
$view = $this->tpl();
$view->assign('room', $this->user->session->conferences()
->where('conference', $room)
->first());
->where('conference', $room)
->first());
Dialog::fill($view->draw('_rooms_subject'));
$this->rpc('MovimUtils.applyAutoheight');
@ -310,15 +317,17 @@ class RoomsUtils extends Base
*/
public function ajaxSetSubject($room, $form)
{
if (!validateRoom($room)
|| !Validator::stringType()->length(0, 200)->validate($form->subject->value)) {
if (
!validateRoom($room)
|| !Validator::stringType()->length(0, 200)->validate($form->subject->value)
) {
return;
}
$p = new SetSubject;
$p->setTo($room)
->setSubject($form->subject->value)
->request();
->setSubject($form->subject->value)
->request();
}
/**
@ -343,32 +352,35 @@ class RoomsUtils extends Base
$view = $this->tpl();
$view->assign('info', \App\Info::where('server', $room)
->where('node', '')
->whereCategory('conference')
->first());
->where('node', '')
->whereCategory('conference')
->first());
$view->assign('mucservice', \App\Info::where('parent', $this->user->session->host)
->whereCategory('conference')
->whereType('text')
->first());
->whereCategory('conference')
->whereType('text')
->first());
$view->assign('id', $room);
$view->assign('create', $create);
$view->assign(
'conference',
$this->user->session->conferences()
->where('conference', $room)->first()
->where('conference', $room)->first()
);
$view->assign('name', $name);
$view->assign('username', $this->user->session->username);
$view->assign(
'gateways',
\App\Info::select('name', 'server', 'parent')
->whereCategory('gateway')
->whereNotNull('parent')
->groupBy('name', 'server', 'parent')
->orderBy('parent')
->orderBy('server')
->get()
);
$gateways = \App\Info::select('name', 'server', 'parent')
->whereCategory('gateway')
->whereNotNull('parent')
->groupBy('name', 'server', 'parent')
->orderBy('parent')
->orderBy('server')
->get();
$gateways = $gateways->filter(fn ($gateway) => $gateway->parent === $this->user->session->host)
->concat($gateways->reject(fn ($gateway) => $gateway->parent === $this->user->session->host));
$view->assign('gateways', $gateways);
$this->rpc('Rooms.setDefaultServices', $this->user->session->getChatroomsServices());
@ -381,14 +393,14 @@ class RoomsUtils extends Base
public function ajaxResolveSlug($name)
{
$service = Info::where('parent', $this->user->session->host)
->whereCategory('conference')
->whereType('text')
->first();
->whereCategory('conference')
->whereType('text')
->first();
$slugified = (new Slugify)->slugify($name);
if ($service && !empty($slugified)) {
$this->rpc('Rooms.setJid', $slugified.'@'. $service->server);
$this->rpc('Rooms.setJid', $slugified . '@' . $service->server);
}
}
@ -404,9 +416,9 @@ class RoomsUtils extends Base
} else {
$m = new Muc;
$m->enableCreate()
->setTo(strtolower($form->jid->value))
->setNickname($form->nick->value ?? $this->user->session->username)
->request();
->setTo(strtolower($form->jid->value))
->setNickname($form->nick->value ?? $this->user->session->username)
->request();
}
}
@ -493,8 +505,8 @@ class RoomsUtils extends Base
$d = new Delete;
$d->setId($room)
->setVersion($conference->bookmarkversion)
->request();
->setVersion($conference->bookmarkversion)
->request();
}
/**
@ -510,9 +522,9 @@ class RoomsUtils extends Base
$id = generateUUID();
$i = new Invite;
$i->setTo($form->to->value)
->setId($id)
->setInvite($form->invite->value)
->request();
->setId($id)
->setInvite($form->invite->value)
->request();
// Create and save a message in the database to display the invitation
$m = new Message;
@ -575,7 +587,7 @@ class RoomsUtils extends Base
$d = new Destroy;
$d->setTo($room)
->request();
->request();
}
/**
@ -656,9 +668,9 @@ class RoomsUtils extends Base
public function ajaxMucUsersAutocomplete($room)
{
$this->rpc("Chat.onAutocomplete", $this->user->session->conferences()
->where('conference', $room)
->first()->presences
->pluck('resource'));
->where('conference', $room)
->first()->presences
->pluck('resource'));
}
/**
@ -666,14 +678,14 @@ class RoomsUtils extends Base
*/
public function ajaxDiscoGateway(string $server)
{
if (empty($server)) {
$this->ajaxResetGatewayRooms();
$this->rpc('Rooms.selectGatewayRoom', '', '');
} else {
$this->ajaxResetGatewayRooms();
$this->rpc('Rooms.selectGatewayRoom', '', '');
if (!empty($server)) {
$r = new Items;
$r->setTo($server)
->disableSave()
->request();
->disableSave()
->request();
}
}
@ -688,8 +700,8 @@ class RoomsUtils extends Base
$view = $this->tpl();
$view->assign('room', $this->user->session->conferences()
->where('conference', $room)
->first());
->where('conference', $room)
->first());
Dialog::fill($view->draw('_rooms_ban'));
}
@ -705,8 +717,8 @@ class RoomsUtils extends Base
$p = new ChangeAffiliation;
$p = $p->setTo($room)
->setJid($form->jid->value)
->setAffiliation('outcast');
->setJid($form->jid->value)
->setAffiliation('outcast');
if (!empty($form->reason->value)) {
$p = $p->setReason($form->reason->value);
@ -726,8 +738,8 @@ class RoomsUtils extends Base
$view = $this->tpl();
$view->assign('room', $this->user->session->conferences()
->where('conference', $room)
->first());
->where('conference', $room)
->first());
$view->assign('jid', $jid);
Dialog::fill($view->draw('_rooms_unban'));
@ -744,9 +756,9 @@ class RoomsUtils extends Base
$p = new ChangeAffiliation;
$p->setTo($room)
->setJid($jid)
->setAffiliation('none')
->request();
->setJid($jid)
->setAffiliation('none')
->request();
}
/**
@ -759,8 +771,8 @@ class RoomsUtils extends Base
}
$conference = $this->user->session->conferences()
->where('conference', $room)
->first();
->where('conference', $room)
->first();
$view = $this->tpl();
$view->assign('room', $conference);
@ -781,15 +793,32 @@ class RoomsUtils extends Base
$p = new ChangeAffiliation;
$p->setTo($room)
->setJid($form->jid->value)
->setAffiliation($form->affiliation->value)
->request();
->setJid($form->jid->value)
->setAffiliation($form->affiliation->value)
->request();
}
public function onDiscoGateway($packet)
{
$view = $this->tpl();
$view->assign('rooms', $packet->content);
$rooms = collect($packet->content);
$rooms = $rooms->map(function ($name, $key) {
$item = new stdClass;
$explodedName = explode('/', $name);
if (count($explodedName) > 1) {
$item->parent = $explodedName[0];
array_shift($explodedName);
$item->name = implode(' / ', $explodedName);
} else {
$item->name = $name;
}
return $item;
});
$view->assign('rooms', $rooms);
$this->rpc('MovimTpl.fill', '#gateway_rooms', $view->draw('_rooms_gateway_rooms'));
}
@ -807,4 +836,4 @@ class RoomsUtils extends Base
{
return (new Chat)->prepareEmbed($embed, true);
}
}
}

2
app/widgets/RoomsUtils/_rooms_add.tpl

@ -106,7 +106,7 @@
{if="isset($id) && !$create"}
<input type="hidden" value="{$id}" name="jid"/>
{else}
<div>
<div id="bookmarkmucadd_jid">
<input
name="jid"
{if="isset($mucservice)"}

14
app/widgets/RoomsUtils/_rooms_gateway_rooms.tpl

@ -1,11 +1,21 @@
<div class="select">
<select onchange="Rooms.selectGatewayRoom(this.value, this.options[this.selectedIndex].label)">
{$group = null}
{loop="$rooms"}
{if="$group != $value->parent"}
{if="$group != null"}
</optgroup>
{/if}
<optgroup label="{$value->parent}">
{/if}
<option value="{$key}">
{$name = explodeJid($key)['username']}
{$value} · {$name}
{$value->name}
</option>
{$group = $value->parent}
{/loop}
{if="$group != null"}
</optgroup>
{/if}
</select>
</div>
<label>{$c->__('rooms.gateway_room')}</label>

3
app/widgets/RoomsUtils/roomsutils.css

@ -0,0 +1,3 @@
#gateway_rooms:not(:empty) ~ #bookmarkmucadd_jid {
display: none;
}

114
composer.lock

@ -1793,7 +1793,7 @@
},
{
"name": "illuminate/bus",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
@ -1846,16 +1846,16 @@
},
{
"name": "illuminate/collections",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "66ff5aab0dd10659aff0efe3ff101819db192dfe"
"reference": "f494398dbaaead9e5ff16a18002d11634e8358e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/66ff5aab0dd10659aff0efe3ff101819db192dfe",
"reference": "66ff5aab0dd10659aff0efe3ff101819db192dfe",
"url": "https://api.github.com/repos/illuminate/collections/zipball/f494398dbaaead9e5ff16a18002d11634e8358e6",
"reference": "f494398dbaaead9e5ff16a18002d11634e8358e6",
"shasum": ""
},
"require": {
@ -1897,11 +1897,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-08-02T14:57:32+00:00"
"time": "2023-08-11T14:48:51+00:00"
},
{
"name": "illuminate/conditionable",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/conditionable.git",
@ -1947,7 +1947,7 @@
},
{
"name": "illuminate/container",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
@ -1998,7 +1998,7 @@
},
{
"name": "illuminate/contracts",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@ -2046,16 +2046,16 @@
},
{
"name": "illuminate/database",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "a52129be2133f83298204770b6110631a1ee13a9"
"reference": "cb735802ee3c303494ebfa4112f3f6b78ba80ec5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/a52129be2133f83298204770b6110631a1ee13a9",
"reference": "a52129be2133f83298204770b6110631a1ee13a9",
"url": "https://api.github.com/repos/illuminate/database/zipball/cb735802ee3c303494ebfa4112f3f6b78ba80ec5",
"reference": "cb735802ee3c303494ebfa4112f3f6b78ba80ec5",
"shasum": ""
},
"require": {
@ -2111,20 +2111,20 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-08-08T14:15:49+00:00"
"time": "2023-08-14T14:50:08+00:00"
},
{
"name": "illuminate/events",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
"reference": "84bafe2c432b22d21c3fb30be42fe2ae9b2f8fd8"
"reference": "e8cbfa31e1ada8d178ffcd7a5e26e101ec280c59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/events/zipball/84bafe2c432b22d21c3fb30be42fe2ae9b2f8fd8",
"reference": "84bafe2c432b22d21c3fb30be42fe2ae9b2f8fd8",
"url": "https://api.github.com/repos/illuminate/events/zipball/e8cbfa31e1ada8d178ffcd7a5e26e101ec280c59",
"reference": "e8cbfa31e1ada8d178ffcd7a5e26e101ec280c59",
"shasum": ""
},
"require": {
@ -2166,11 +2166,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-06-27T14:35:49+00:00"
"time": "2023-08-11T15:02:04+00:00"
},
{
"name": "illuminate/macroable",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -2216,7 +2216,7 @@
},
{
"name": "illuminate/pipeline",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
@ -2264,16 +2264,16 @@
},
{
"name": "illuminate/support",
"version": "v10.18.0",
"version": "v10.19.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "9ce4a26975a919ec33ed21307633ac02208537a8"
"reference": "0a8526d55756955fcec6be7c2c6cd14d915c8c0f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/9ce4a26975a919ec33ed21307633ac02208537a8",
"reference": "9ce4a26975a919ec33ed21307633ac02208537a8",
"url": "https://api.github.com/repos/illuminate/support/zipball/0a8526d55756955fcec6be7c2c6cd14d915c8c0f",
"reference": "0a8526d55756955fcec6be7c2c6cd14d915c8c0f",
"shasum": ""
},
"require": {
@ -2331,7 +2331,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-08-08T14:14:45+00:00"
"time": "2023-08-14T21:56:59+00:00"
},
{
"name": "league/commonmark",
@ -2795,25 +2795,29 @@
},
{
"name": "nesbot/carbon",
"version": "2.68.1",
"version": "2.69.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "4f991ed2a403c85efbc4f23eb4030063fdbe01da"
"reference": "4308217830e4ca445583a37d1bf4aff4153fa81c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4f991ed2a403c85efbc4f23eb4030063fdbe01da",
"reference": "4f991ed2a403c85efbc4f23eb4030063fdbe01da",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4308217830e4ca445583a37d1bf4aff4153fa81c",
"reference": "4308217830e4ca445583a37d1bf4aff4153fa81c",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1.8 || ^8.0",
"psr/clock": "^1.0",
"symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php80": "^1.16",
"symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
},
"provide": {
"psr/clock-implementation": "1.0"
},
"require-dev": {
"doctrine/dbal": "^2.0 || ^3.1.4",
"doctrine/orm": "^2.7",
@ -2893,7 +2897,7 @@
"type": "tidelift"
}
],
"time": "2023-06-20T18:29:04+00:00"
"time": "2023-08-03T09:00:52+00:00"
},
{
"name": "nette/schema",
@ -3404,6 +3408,54 @@
},
"time": "2021-02-03T23:26:27+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"time": "2022-11-25T14:36:26+00:00"
},
{
"name": "psr/container",
"version": "2.0.2",

10
public/theme/css/form.css

@ -36,7 +36,7 @@ form > div label {
}
form > div textarea[required] + label:after,
form > div input[required] + label:after {
form > div input[required]:not([type=checkbox]) + label:after {
content: '✱';
margin-left: 0.5rem;
}
@ -415,14 +415,6 @@ input[type=button].flat:focus {
margin: 0;
}
.button.action:hover {
transform: scale(1.1);
}
.button.action:active {
transform: scale(1);
}
.button.action.small {
height: 5rem;
width: 5rem;

5
src/Moxl/Xec/Action/Disco/Items.php

@ -107,4 +107,9 @@ class Items extends Action
$this->pack($this->_to);
$this->deliver();
}
public function errorRegistrationRequired(string $errorId, ?string $message = null)
{
$this->deliver();
}
}
Loading…
Cancel
Save