use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
-use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
-use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Model\Group;
use Friendica\Model\Item;
-use Friendica\Model\Notification;
-use Friendica\Model\Profile;
use Friendica\Model\User;
-use Friendica\Model\Verb;
use Friendica\Module\BaseSettings;
use Friendica\Module\Security\Login;
-use Friendica\Protocol\Activity;
use Friendica\Protocol\Email;
-use Friendica\Util\Temporal;
-use Friendica\Worker\Delivery;
function settings_init(App $a)
{
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item as ItemModel;
-use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
-use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Psr\Log\LoggerInterface;
{
$type = \Friendica\Factory\Api\Mastodon\Notification::getType($Notification);
- $desktop_notification = !in_array($type, [Notification::TYPE_RESHARE, Notification::TYPE_LIKE]);
-
- if (DI::pConfig()->get($Notification->uid, 'system', 'notify_like') && ($type == Notification::TYPE_LIKE)) {
- $desktop_notification = true;
- }
-
- if (DI::pConfig()->get($Notification->uid, 'system', 'notify_announce') && ($type == Notification::TYPE_RESHARE)) {
- $desktop_notification = true;
- }
-
- if ($desktop_notification) {
+ if (DI::notify()->NotifyOnDesktop($Notification, $type)) {
DI::notify()->createFromNotification($Notification);
}
$owner = User::getOwnerDataById(local_user());
$navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
+ if (!DI::notify()->NotifyOnDesktop($notification)) {
+ return null;
+ }
if (($notification->type == Post\UserNotification::TYPE_NONE) && in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP])) {
return null;
}
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Navigation\Notifications\Exception;
use Friendica\Navigation\Notifications\Factory;
use Friendica\Network\HTTPException;
+use Friendica\Object\Api\Mastodon\Notification;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
/** @var IManageConfigValues */
protected $config;
+ /** @var IManagePersonalConfigValues */
+ private $pConfig;
+
/** @var Emailer */
protected $emailer;
protected static $table_name = 'notify';
- public function __construct(Database $database, LoggerInterface $logger, L10n $l10n, BaseURL $baseUrl, IManageConfigValues $config, Emailer $emailer, Factory\Notification $notification, Factory\Notify $factory = null)
+ public function __construct(Database $database, LoggerInterface $logger, L10n $l10n, BaseURL $baseUrl, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, Emailer $emailer, Factory\Notification $notification, Factory\Notify $factory = null)
{
$this->l10n = $l10n;
$this->baseUrl = $baseUrl;
$this->config = $config;
+ $this->pConfig = $pConfig;
$this->emailer = $emailer;
$this->notification = $notification;
return false;
}
+ public function NotifyOnDesktop(Entity\Notification $Notification, string $type = null): bool
+ {
+ if (is_null($type)) {
+ $type = \Friendica\Factory\Api\Mastodon\Notification::getType($Notification);
+ }
+
+ if (!in_array($type, [Notification::TYPE_RESHARE, Notification::TYPE_LIKE])) {
+ return true;
+ }
+
+ if ($this->pConfig->get($Notification->uid, 'system', 'notify_like') && ($type == Notification::TYPE_LIKE)) {
+ return true;
+ }
+
+ if ($this->pConfig->get($Notification->uid, 'system', 'notify_announce') && ($type == Notification::TYPE_RESHARE)) {
+ return true;
+ }
+
+ return false;
+ }
+
public function createFromNotification(Entity\Notification $Notification)
{
$this->logger->info('Start', ['uid' => $Notification->uid, 'id' => $Notification->id, 'type' => $Notification->type]);