Browse Source

Add contact blocklist feature

pull/1082/head
Timothée Jaussoin 3 years ago
parent
commit
96b1508cbd
  1. 1
      CHANGELOG.md
  2. 5
      app/Contact.php
  3. 20
      app/Reported.php
  4. 20
      app/User.php
  5. 1
      app/views/conf.tpl
  6. 27
      app/widgets/Blocked/Blocked.php
  7. 3
      app/widgets/Blocked/blocked.css
  8. 26
      app/widgets/Blocked/blocked.tpl
  9. 9
      app/widgets/Blocked/locales.ini
  10. 4
      app/widgets/Chat/Chat.php
  11. 14
      app/widgets/Chat/_chat_header.tpl
  12. 29
      app/widgets/ChatActions/ChatActions.php
  13. 189
      composer.lock
  14. 39
      database/migrations/20220801205253_create_reported_table.php
  15. 4
      lib/moxl/src/Xec/Payload/Message.php
  16. 5
      lib/moxl/src/Xec/Payload/Presence.php

1
CHANGELOG.md

@ -7,6 +7,7 @@ v0.21 (trunk)
* Add PWA Push Notification support through the service worker
* CSS fixes
* Upgrade Embed to v4.x and add Twitter integration
* Add contact blocklist feature
v0.20
---------------------------

5
app/Contact.php

@ -279,6 +279,11 @@ class Contact extends Model
);
}
public function isBlocked(): bool
{
return \App\User::me()->hasBlocked($this->id);
}
public function isEmpty(): bool
{
$this->isValidDate();

20
app/Reported.php

@ -0,0 +1,20 @@
<?php
namespace App;
use Movim\Model;
class Reported extends Model
{
protected $keyType = 'string';
protected $table = 'reported';
public $fillable = [
'id'
];
public function users()
{
return $this->belongsToMany('App\User')->withTimestamps();
}
}

20
app/User.php

@ -15,6 +15,7 @@ class User extends Model
public $incrementing = false;
private static $me = null;
private $unreads = null;
private $blocked = [];
public function save(array $options = [])
{
@ -60,6 +61,11 @@ class User extends Model
return $this->hasMany('App\PushSubscription');
}
public function reported()
{
return $this->belongsToMany('App\Reported')->withTimestamps();
}
public function getResolvedNicknameAttribute()
{
return $this->nickname ?? $this->id;
@ -138,6 +144,9 @@ class User extends Model
{
$contact = Contact::firstOrNew(['id' => $this->id]);
$contact->save();
// Load the blocked accounts in memory
$this->refreshBlocked();
}
public function setConfig(array $config)
@ -208,4 +217,15 @@ class User extends Model
$this->attributes['public'] = false;
$this->save();
}
public function refreshBlocked()
{
$this->blocked = $this->reported()->get()->pluck('id')->toArray();
}
public function hasBlocked(string $jid): bool
{
return in_array($jid, $this->blocked);
}
}

1
app/views/conf.tpl

@ -37,5 +37,6 @@
<?php } ?>
<?php $this->widget('Account');?>
<?php $this->widget('AdHoc');?>
<?php $this->widget('Blocked');?>
</div>
</main>

27
app/widgets/Blocked/Blocked.php

@ -0,0 +1,27 @@
<?php
class Blocked extends \Movim\Widget\Base
{
public function load()
{
$this->addcss('blocked.css');
}
/**
* @brief Unblock the contact
*/
public function ajaxUnblockContact(string $jid)
{
$this->user->reported()->detach($jid);
$this->user->refreshBlocked();
Toast::send($this->__('blocked.account_unblocked'));
$this->rpc('MovimTpl.remove', '#blocked-'.cleanupId($jid));
}
public function display()
{
$this->view->assign('blocked', $this->user->reported()->get());
}
}

3
app/widgets/Blocked/blocked.css

@ -0,0 +1,3 @@
#blocked_widget_list:not(:empty) ~ .placeholder {
display: none;
}

26
app/widgets/Blocked/blocked.tpl

@ -0,0 +1,26 @@
<div class="tabelem padded_top_bottom" title="{$c->__('blocked.title')}" id="blocked_widget">
<ul class="list thick">
<li>
<span class="primary icon gray">
<i class="material-icons">info</i>
</span>
<div>
<p class="line normal">{$c->__('blocked.info')}</p>
<p class="line">{$c->__('blocked.info2')}</p>
</div>
</li>
</ul>
<ul class="list thin" id="blocked_widget_list">{loop="$blocked"}<li id="blocked-{$value->id|cleanupId}">
<span class="control icon active divided"
onclick="Blocked_ajaxUnblockContact('{$value->id|echapJS}')">
<i class="material-icons">close</i>
</span>
<div>
<p class="line normal">{$value->id} <span class="second">{$value->created_at|strtotime|prepareDate}</span></p>
</div>
</li>{/loop}</ul>
<div class="placeholder">
<i class="material-icons">block</i>
<h4>{$c->__('blocked.placeholder')}</h4>
</div>
</div>

9
app/widgets/Blocked/locales.ini

@ -0,0 +1,9 @@
[blocked]
title = Blocked
block_account = Block the account
unblock_account = Unblock the account
account_blocked = Account blocked
account_unblocked = Account unblocked
placeholder = You will find here the users you have blocked
info = The following users are blocked by Movim and cannot contact you anymore.
info2 = The administrator is also aware of this list and can therefore block those users system wide.

4
app/widgets/Chat/Chat.php

@ -1369,7 +1369,9 @@ class Chat extends \Movim\Widget\Base
}
$msgkey = '<' . $message->jidfrom;
$msgkey .= ($message->type == 'groupchat') ? cleanupId($message->resource, true) : '';
$msgkey .= ($message->type == 'groupchat' && $message->resource != null)
? cleanupId($message->resource, true)
: '';
$msgkey .= '>' . substr($message->published, 11, 5);
$counter = count($this->_wrapper[$date]);

14
app/widgets/Chat/_chat_header.tpl

@ -311,5 +311,19 @@
</div>
</li>
{/if}
<hr />
{if="$contact->isBlocked()"}
<li onclick="ChatActions_ajaxUnblockContact('{$contact->jid|echapJS}')">
<div>
<p class="normal">{$c->__('blocked.unblock_account')}</p>
</div>
</li>
{else}
<li onclick="ChatActions_ajaxBlockContact('{$contact->jid|echapJS}')">
<div>
<p class="normal">{$c->__('blocked.block_account')}</p>
</div>
</li>
{/if}
</ul>
{/if}

29
app/widgets/ChatActions/ChatActions.php

@ -1,5 +1,6 @@
<?php
use App\Reported;
use App\Url;
use Moxl\Xec\Action\Message\Retract;
@ -11,12 +12,38 @@ class ChatActions extends \Movim\Widget\Base
/**
* @brief Get a Drawer view of a contact
*/
public function ajaxGetContact($jid)
public function ajaxGetContact(string $jid)
{
$c = new ContactActions;
$c->ajaxGetDrawer($jid);
}
/**
* @brief Block the contact
*/
public function ajaxBlockContact(string $jid)
{
$r = Reported::firstOrCreate(['id' => $jid]);
$this->user->reported()->syncWithoutDetaching([$r->id]);
$this->user->refreshBlocked();
Toast::send($this->__('blocked.account_blocked'));
$this->rpc('Chats_ajaxClose', $jid, true);
}
/**
* @brief Unblock the contact
*/
public function ajaxUnblockContact(string $jid)
{
$this->user->reported()->detach($jid);
$this->user->refreshBlocked();
Toast::send($this->__('blocked.account_unblocked'));
}
/**
* @brief Display the message dialog
*/

189
composer.lock

@ -68,7 +68,7 @@
},
{
"name": "cakephp/core",
"version": "4.4.2",
"version": "4.4.3",
"source": {
"type": "git",
"url": "https://github.com/cakephp/core.git",
@ -125,16 +125,16 @@
},
{
"name": "cakephp/database",
"version": "4.4.2",
"version": "4.4.3",
"source": {
"type": "git",
"url": "https://github.com/cakephp/database.git",
"reference": "61b147195a5899a9b51989af9150a13b647e9190"
"reference": "25694dd69cbfa61a6b17674b76aa2accd1f779f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/database/zipball/61b147195a5899a9b51989af9150a13b647e9190",
"reference": "61b147195a5899a9b51989af9150a13b647e9190",
"url": "https://api.github.com/repos/cakephp/database/zipball/25694dd69cbfa61a6b17674b76aa2accd1f779f9",
"reference": "25694dd69cbfa61a6b17674b76aa2accd1f779f9",
"shasum": ""
},
"require": {
@ -176,20 +176,20 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/database"
},
"time": "2022-06-20T14:25:54+00:00"
"time": "2022-07-21T13:36:55+00:00"
},
{
"name": "cakephp/datasource",
"version": "4.4.2",
"version": "4.4.3",
"source": {
"type": "git",
"url": "https://github.com/cakephp/datasource.git",
"reference": "41b4243d226fc802e1075247c81c8bc48fad4343"
"reference": "2f890a6b8d8b33da2d26fcb486ecf5484d9ab014"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/datasource/zipball/41b4243d226fc802e1075247c81c8bc48fad4343",
"reference": "41b4243d226fc802e1075247c81c8bc48fad4343",
"url": "https://api.github.com/repos/cakephp/datasource/zipball/2f890a6b8d8b33da2d26fcb486ecf5484d9ab014",
"reference": "2f890a6b8d8b33da2d26fcb486ecf5484d9ab014",
"shasum": ""
},
"require": {
@ -234,20 +234,20 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/datasource"
},
"time": "2022-06-27T10:55:08+00:00"
"time": "2022-07-06T14:29:38+00:00"
},
{
"name": "cakephp/utility",
"version": "4.4.2",
"version": "4.4.3",
"source": {
"type": "git",
"url": "https://github.com/cakephp/utility.git",
"reference": "564cf3bea3bb31e0cb53fa199c39f17105af01ec"
"reference": "32866aac3d4fef7649fb524da6c59e14e7d18a0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/utility/zipball/564cf3bea3bb31e0cb53fa199c39f17105af01ec",
"reference": "564cf3bea3bb31e0cb53fa199c39f17105af01ec",
"url": "https://api.github.com/repos/cakephp/utility/zipball/32866aac3d4fef7649fb524da6c59e14e7d18a0d",
"reference": "32866aac3d4fef7649fb524da6c59e14e7d18a0d",
"shasum": ""
},
"require": {
@ -293,7 +293,7 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/utility"
},
"time": "2022-07-05T07:59:19+00:00"
"time": "2022-07-16T21:24:52+00:00"
},
{
"name": "cboden/ratchet",
@ -960,34 +960,31 @@
},
{
"name": "doctrine/event-manager",
"version": "1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f"
"reference": "eb2ecf80e3093e8f3c2769ac838e27d8ede8e683"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/eb2ecf80e3093e8f3c2769ac838e27d8ede8e683",
"reference": "eb2ecf80e3093e8f3c2769ac838e27d8ede8e683",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/common": "<2.9@dev"
"doctrine/common": "<2.9"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"phpunit/phpunit": "^7.0"
"doctrine/coding-standard": "^9",
"phpstan/phpstan": "~1.4.10 || ^1.5.4",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
@ -1034,7 +1031,7 @@
],
"support": {
"issues": "https://github.com/doctrine/event-manager/issues",
"source": "https://github.com/doctrine/event-manager/tree/1.1.x"
"source": "https://github.com/doctrine/event-manager/tree/1.1.2"
},
"funding": [
{
@ -1050,7 +1047,7 @@
"type": "tidelift"
}
],
"time": "2020-05-29T18:28:51+00:00"
"time": "2022-07-27T22:18:11+00:00"
},
{
"name": "doctrine/inflector",
@ -1855,7 +1852,7 @@
},
{
"name": "illuminate/bus",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
@ -1908,7 +1905,7 @@
},
{
"name": "illuminate/collections",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
@ -1962,7 +1959,7 @@
},
{
"name": "illuminate/container",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
@ -2013,7 +2010,7 @@
},
{
"name": "illuminate/contracts",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@ -2061,7 +2058,7 @@
},
{
"name": "illuminate/database",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
@ -2129,7 +2126,7 @@
},
{
"name": "illuminate/events",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
@ -2184,7 +2181,7 @@
},
{
"name": "illuminate/macroable",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -2230,7 +2227,7 @@
},
{
"name": "illuminate/pipeline",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
@ -2278,7 +2275,7 @@
},
{
"name": "illuminate/support",
"version": "v8.83.22",
"version": "v8.83.23",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
@ -2346,16 +2343,16 @@
},
{
"name": "league/commonmark",
"version": "2.3.4",
"version": "2.3.5",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "155ec1c95626b16fda0889cf15904d24890a60d5"
"reference": "84d74485fdb7074f4f9dd6f02ab957b1de513257"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/155ec1c95626b16fda0889cf15904d24890a60d5",
"reference": "155ec1c95626b16fda0889cf15904d24890a60d5",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/84d74485fdb7074f4f9dd6f02ab957b1de513257",
"reference": "84d74485fdb7074f4f9dd6f02ab957b1de513257",
"shasum": ""
},
"require": {
@ -2377,13 +2374,13 @@
"github/gfm": "0.29.0",
"michelf/php-markdown": "^1.4",
"nyholm/psr7": "^1.5",
"phpstan/phpstan": "^0.12.88 || ^1.0.0",
"phpunit/phpunit": "^9.5.5",
"phpstan/phpstan": "^1.8.2",
"phpunit/phpunit": "^9.5.21",
"scrutinizer/ocular": "^1.8.1",
"symfony/finder": "^5.3",
"symfony/finder": "^5.3 | ^6.0",
"symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0",
"unleashedtech/php-coding-standard": "^3.1",
"vimeo/psalm": "^4.7.3"
"unleashedtech/php-coding-standard": "^3.1.1",
"vimeo/psalm": "^4.24.0"
},
"suggest": {
"symfony/yaml": "v2.3+ required if using the Front Matter extension"
@ -2448,7 +2445,7 @@
"type": "tidelift"
}
],
"time": "2022-07-17T16:25:47+00:00"
"time": "2022-07-29T10:59:45+00:00"
},
{
"name": "league/config",
@ -2804,16 +2801,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.59.1",
"version": "2.60.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "a9000603ea337c8df16cc41f8b6be95a65f4d0f5"
"reference": "00a259ae02b003c563158b54fb6743252b638ea6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/a9000603ea337c8df16cc41f8b6be95a65f4d0f5",
"reference": "a9000603ea337c8df16cc41f8b6be95a65f4d0f5",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/00a259ae02b003c563158b54fb6743252b638ea6",
"reference": "00a259ae02b003c563158b54fb6743252b638ea6",
"shasum": ""
},
"require": {
@ -2902,7 +2899,7 @@
"type": "tidelift"
}
],
"time": "2022-06-29T21:43:55+00:00"
"time": "2022-07-27T15:57:48+00:00"
},
{
"name": "nette/schema",
@ -4921,16 +4918,16 @@
},
{
"name": "symfony/config",
"version": "v5.4.9",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979"
"reference": "ec79e03125c1d2477e43dde8528535d90cc78379"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/8f551fe22672ac7ab2c95fe46d899f960ed4d979",
"reference": "8f551fe22672ac7ab2c95fe46d899f960ed4d979",
"url": "https://api.github.com/repos/symfony/config/zipball/ec79e03125c1d2477e43dde8528535d90cc78379",
"reference": "ec79e03125c1d2477e43dde8528535d90cc78379",
"shasum": ""
},
"require": {
@ -4980,7 +4977,7 @@
"description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/config/tree/v5.4.9"
"source": "https://github.com/symfony/config/tree/v5.4.11"
},
"funding": [
{
@ -4996,20 +4993,20 @@
"type": "tidelift"
}
],
"time": "2022-05-17T10:39:36+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/console",
"version": "v5.4.10",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000"
"reference": "535846c7ee6bc4dd027ca0d93220601456734b10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/4d671ab4ddac94ee439ea73649c69d9d200b5000",
"reference": "4d671ab4ddac94ee439ea73649c69d9d200b5000",
"url": "https://api.github.com/repos/symfony/console/zipball/535846c7ee6bc4dd027ca0d93220601456734b10",
"reference": "535846c7ee6bc4dd027ca0d93220601456734b10",
"shasum": ""
},
"require": {
@ -5079,7 +5076,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.4.10"
"source": "https://github.com/symfony/console/tree/v5.4.11"
},
"funding": [
{
@ -5095,7 +5092,7 @@
"type": "tidelift"
}
],
"time": "2022-06-26T13:00:04+00:00"
"time": "2022-07-22T10:42:43+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -5166,16 +5163,16 @@
},
{
"name": "symfony/filesystem",
"version": "v5.4.9",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba"
"reference": "6699fb0228d1bc35b12aed6dd5e7455457609ddd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/36a017fa4cce1eff1b8e8129ff53513abcef05ba",
"reference": "36a017fa4cce1eff1b8e8129ff53513abcef05ba",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/6699fb0228d1bc35b12aed6dd5e7455457609ddd",
"reference": "6699fb0228d1bc35b12aed6dd5e7455457609ddd",
"shasum": ""
},
"require": {
@ -5210,7 +5207,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v5.4.9"
"source": "https://github.com/symfony/filesystem/tree/v5.4.11"
},
"funding": [
{
@ -5226,20 +5223,20 @@
"type": "tidelift"
}
],
"time": "2022-05-20T13:55:35+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v5.4.10",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "e7793b7906f72a8cc51054fbca9dcff7a8af1c1e"
"reference": "0a5868e0999e9d47859ba3d918548ff6943e6389"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e7793b7906f72a8cc51054fbca9dcff7a8af1c1e",
"reference": "e7793b7906f72a8cc51054fbca9dcff7a8af1c1e",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/0a5868e0999e9d47859ba3d918548ff6943e6389",
"reference": "0a5868e0999e9d47859ba3d918548ff6943e6389",
"shasum": ""
},
"require": {
@ -5283,7 +5280,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v5.4.10"
"source": "https://github.com/symfony/http-foundation/tree/v5.4.11"
},
"funding": [
{
@ -5299,7 +5296,7 @@
"type": "tidelift"
}
],
"time": "2022-06-19T13:13:40+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -5874,16 +5871,16 @@
},
{
"name": "symfony/routing",
"version": "v5.4.8",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "e07817bb6244ea33ef5ad31abc4a9288bef3f2f7"
"reference": "3e01ccd9b2a3a4167ba2b3c53612762300300226"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/e07817bb6244ea33ef5ad31abc4a9288bef3f2f7",
"reference": "e07817bb6244ea33ef5ad31abc4a9288bef3f2f7",
"url": "https://api.github.com/repos/symfony/routing/zipball/3e01ccd9b2a3a4167ba2b3c53612762300300226",
"reference": "3e01ccd9b2a3a4167ba2b3c53612762300300226",
"shasum": ""
},
"require": {
@ -5944,7 +5941,7 @@
"url"
],
"support": {
"source": "https://github.com/symfony/routing/tree/v5.4.8"
"source": "https://github.com/symfony/routing/tree/v5.4.11"
},
"funding": [
{
@ -5960,7 +5957,7 @@
"type": "tidelift"
}
],
"time": "2022-04-18T21:45:37+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/service-contracts",
@ -6047,16 +6044,16 @@
},
{
"name": "symfony/string",
"version": "v5.4.10",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "4432bc7df82a554b3e413a8570ce2fea90e94097"
"reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/4432bc7df82a554b3e413a8570ce2fea90e94097",
"reference": "4432bc7df82a554b3e413a8570ce2fea90e94097",
"url": "https://api.github.com/repos/symfony/string/zipball/5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
"reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
"shasum": ""
},
"require": {
@ -6113,7 +6110,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v5.4.10"
"source": "https://github.com/symfony/string/tree/v5.4.11"
},
"funding": [
{
@ -6129,20 +6126,20 @@
"type": "tidelift"
}
],
"time": "2022-06-26T15:57:47+00:00"
"time": "2022-07-24T16:15:25+00:00"
},
{
"name": "symfony/translation",
"version": "v5.4.9",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "1639abc1177d26bcd4320e535e664cef067ab0ca"
"reference": "7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/1639abc1177d26bcd4320e535e664cef067ab0ca",
"reference": "1639abc1177d26bcd4320e535e664cef067ab0ca",
"url": "https://api.github.com/repos/symfony/translation/zipball/7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21",
"reference": "7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21",
"shasum": ""
},
"require": {
@ -6210,7 +6207,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v5.4.9"
"source": "https://github.com/symfony/translation/tree/v5.4.11"
},
"funding": [
{
@ -6226,7 +6223,7 @@
"type": "tidelift"
}
],
"time": "2022-05-06T12:33:37+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/translation-contracts",

39
database/migrations/20220801205253_create_reported_table.php

@ -0,0 +1,39 @@
<?php
use Movim\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateReportedTable extends Migration
{
public function up()
{
$this->schema->create('reported', function (Blueprint $table) {
$table->string('id', 256)->unique();
$table->boolean('blocked')->default(false);
$table->timestamps();
});
$this->schema->create('reported_user', function (Blueprint $table) {
$table->string('user_id', 256);
$table->string('reported_id', 256);
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('reported_id')
->references('id')->on('reported')
->onDelete('cascade');
$table->unique(['user_id', 'reported_id']);
$table->timestamps();
});
}
public function down()
{
$this->schema->drop('reported_user');
$this->schema->drop('reported');
}
}

4
lib/moxl/src/Xec/Payload/Message.php

@ -21,6 +21,10 @@ class Message extends Payload
$message = \App\Message::findByStanza($stanza);
$message = $message->set($stanza, $parent);
if ($message->type == 'chat' && \App\User::me()->hasBlocked($message->jidfrom)) {
return;
}
if ($stanza->composing || $stanza->paused || $stanza->active) {
$from = ($message->type == 'groupchat')
? $message->jidfrom.'/'.$message->resource

5
lib/moxl/src/Xec/Payload/Presence.php

@ -10,6 +10,11 @@ class Presence extends Payload
{
public function handle($stanza, $parent = false)
{
$jid = explodeJid($stanza->attributes()->from);
if (\App\User::me()->hasBlocked($jid['jid'])) {
return;
}
// Subscribe request
if ((string)$stanza->attributes()->type == 'subscribe') {
$session = Session::start();

Loading…
Cancel
Save