From 8353f087e51f3010d71c54d8835069b734cb5118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20=C3=96zbey?= <48382593+the-turk@users.noreply.github.com> Date: Sun, 18 Jul 2021 23:47:34 +0300 Subject: [PATCH] suspend anonymously (#39) * suspend anonymously closes https://github.com/flarum/core/issues/2614 * format less file * empty methods should return null --- .../forum/components/UserSuspendedNotification.js | 1 - .../forum/components/UserUnsuspendedNotification.js | 4 +--- extensions/suspend/less/forum.less | 6 ++++++ extensions/suspend/locale/en.yml | 4 ++-- .../Listener/SendNotificationWhenUserIsSuspended.php | 2 +- .../SendNotificationWhenUserIsUnsuspended.php | 2 +- .../src/Notification/UserSuspendedBlueprint.php | 11 ++--------- .../src/Notification/UserUnsuspendedBlueprint.php | 12 +++--------- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js b/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js index 0d9b36035..a7bc60aa1 100644 --- a/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js +++ b/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js @@ -15,7 +15,6 @@ export default class UserSuspendedNotification extends Notification { const timeReadable = dayjs(suspendedUntil).from(notification.createdAt(), true); return app.translator.trans('flarum-suspend.forum.notifications.user_suspended_text', { - user: notification.fromUser(), timeReadable, }); } diff --git a/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js b/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js index d6fc5c62d..e8bde8590 100644 --- a/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js +++ b/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js @@ -12,8 +12,6 @@ export default class UserUnsuspendedNotification extends Notification { content() { const notification = this.attrs.notification; - return app.translator.trans('flarum-suspend.forum.notifications.user_unsuspended_text', { - user: notification.fromUser(), - }); + return app.translator.trans('flarum-suspend.forum.notifications.user_unsuspended_text'); } } diff --git a/extensions/suspend/less/forum.less b/extensions/suspend/less/forum.less index dc3ff814f..34e5d652c 100644 --- a/extensions/suspend/less/forum.less +++ b/extensions/suspend/less/forum.less @@ -10,3 +10,9 @@ margin-right: 5px; } } +.Notification--userSuspended, +.Notification--userUnsuspended { + > .Avatar { + display: none; + } +} diff --git a/extensions/suspend/locale/en.yml b/extensions/suspend/locale/en.yml index 55ae520b8..c76d904bc 100644 --- a/extensions/suspend/locale/en.yml +++ b/extensions/suspend/locale/en.yml @@ -15,8 +15,8 @@ flarum-suspend: forum: # These translations are used in the suspension notifications notifications: - user_suspended_text: "{username} suspended you for {timeReadable}" - user_unsuspended_text: "{username} unsuspended you" + user_suspended_text: "You have been suspended for {timeReadable}" + user_unsuspended_text: You have been unsuspended # These translations are used in the Suspend User modal dialog (admin function). suspend_user: diff --git a/extensions/suspend/src/Listener/SendNotificationWhenUserIsSuspended.php b/extensions/suspend/src/Listener/SendNotificationWhenUserIsSuspended.php index 5b95f5b8b..1db55549c 100644 --- a/extensions/suspend/src/Listener/SendNotificationWhenUserIsSuspended.php +++ b/extensions/suspend/src/Listener/SendNotificationWhenUserIsSuspended.php @@ -31,7 +31,7 @@ class SendNotificationWhenUserIsSuspended public function handle(Suspended $event) { $this->notifications->sync( - new UserSuspendedBlueprint($event->user, $event->actor), + new UserSuspendedBlueprint($event->user), [$event->user] ); } diff --git a/extensions/suspend/src/Listener/SendNotificationWhenUserIsUnsuspended.php b/extensions/suspend/src/Listener/SendNotificationWhenUserIsUnsuspended.php index 26af57b66..2b89a08ea 100644 --- a/extensions/suspend/src/Listener/SendNotificationWhenUserIsUnsuspended.php +++ b/extensions/suspend/src/Listener/SendNotificationWhenUserIsUnsuspended.php @@ -31,7 +31,7 @@ class SendNotificationWhenUserIsUnsuspended public function handle(Unsuspended $event) { $this->notifications->sync( - new UserUnsuspendedBlueprint($event->user, $event->actor), + new UserUnsuspendedBlueprint($event->user), [$event->user] ); } diff --git a/extensions/suspend/src/Notification/UserSuspendedBlueprint.php b/extensions/suspend/src/Notification/UserSuspendedBlueprint.php index d525b8666..e8f32617f 100644 --- a/extensions/suspend/src/Notification/UserSuspendedBlueprint.php +++ b/extensions/suspend/src/Notification/UserSuspendedBlueprint.php @@ -19,19 +19,12 @@ class UserSuspendedBlueprint implements BlueprintInterface */ public $user; - /** - * @var User - */ - public $actor; - /** * @param User $user - * @param User $actor */ - public function __construct(User $user, User $actor) + public function __construct(User $user) { $this->user = $user; - $this->actor = $actor; } /** @@ -47,7 +40,7 @@ class UserSuspendedBlueprint implements BlueprintInterface */ public function getFromUser() { - return $this->actor; + return null; } /** diff --git a/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php b/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php index 46d7f15f9..5221154e8 100644 --- a/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php +++ b/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php @@ -19,19 +19,12 @@ class UserUnsuspendedBlueprint implements BlueprintInterface */ public $user; - /** - * @var User - */ - public $actor; - /** * @param User $user - * @param User $actor */ - public function __construct(User $user, User $actor) + public function __construct(User $user) { $this->user = $user; - $this->actor = $actor; } /** @@ -47,7 +40,7 @@ class UserUnsuspendedBlueprint implements BlueprintInterface */ public function getFromUser() { - return $this->actor; + return null; } /** @@ -55,6 +48,7 @@ class UserUnsuspendedBlueprint implements BlueprintInterface */ public function getData() { + return null; } /**