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;
DI::pConfig()->set(local_user(), 'expire', 'photos', $expire_photos);
DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
+ // Reset like notifications when they are going to be shown again
+ if (!DI::pConfig()->get(local_user(), 'system', 'notify_like') && $notify_like) {
+ DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]);
+ }
+
DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like);
+
+ // Reset share notifications when they are going to be shown again
+ if (!DI::pConfig()->get(local_user(), 'system', 'notify_announce') && $notify_announce) {
+ DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
+ }
+
DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce);
DI::pConfig()->set(local_user(), 'system', 'email_textonly', $email_textonly);
use Exception;
use Friendica\BaseCollection;
use Friendica\BaseRepository;
+use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Model\Verb;
protected static $table_name = 'notification';
- public function __construct(Database $database, LoggerInterface $logger, Factory\Notification $factory)
+ /** @var IManagePersonalConfigValues */
+ private $pconfig;
+
+ public function __construct(IManagePersonalConfigValues $pconfig, Database $database, LoggerInterface $logger, Factory\Notification $factory)
{
parent::__construct($database, $logger, $factory);
+
+ $this->pconfig = $pconfig;
}
/**
return $this->select($condition, $params);
}
+
+ /**
+ * Returns only the most recent notifications for the same conversation or contact
+ *
+ * @param int $uid
+ * @return Collection\Notifications
+ * @throws Exception
+ */
+ public function selectDetailedForUser(int $uid): Collection\Notifications
+ {
+ $condition = [];
+ if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
+ $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(\Friendica\Protocol\Activity::LIKE)]);
+ }
+
+ if (!$this->pconfig->get($uid, 'system', 'notify_announce')) {
+ $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(\Friendica\Protocol\Activity::ANNOUNCE)]);
+ }
+
+ return $this->selectForUser(local_user(), $condition, ['limit' => 50, 'order' => ['id' => true]]);
+ }
+
/**
* Returns only the most recent notifications for the same conversation or contact
*
*/
public function selectDigestForUser(int $uid): Collection\Notifications
{
+ $values = [$uid];
+
+ $like_condition = '';
+ if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
+ $like_condition = 'AND vid != ?';
+ $values[] = Verb::getID(\Friendica\Protocol\Activity::LIKE);
+ }
+
+ $announce_condition = '';
+ if (!$this->pconfig->get($uid, 'system', 'notify_announce')) {
+ $announce_condition = 'AND vid != ?';
+ $values[] = Verb::getID(\Friendica\Protocol\Activity::ANNOUNCE);
+ }
+
$rows = $this->db->p("
SELECT notification.*
FROM notification
SELECT MAX(`id`)
FROM notification
WHERE uid = ?
- AND vid != ?
+ $like_condition
+ $announce_condition
GROUP BY IFNULL(`parent-uri-id`, `actor-id`)
)
ORDER BY `seen`, `id` DESC
LIMIT 50
- ", $uid, Verb::getID(\Friendica\Protocol\Activity::LIKE));
+ ", ...$values);
$Entities = new Collection\Notifications();
foreach ($rows as $fields) {