Avoid empty notifications / fixed link to the content

This commit is contained in:
Michael 2022-03-19 15:25:00 +00:00
parent 4329f5381b
commit fb6a435a6a
2 changed files with 9 additions and 8 deletions

View File

@ -139,9 +139,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
$this->logger->info('Parent post not found', ['uri-id' => $Notification->parentUriId]); $this->logger->info('Parent post not found', ['uri-id' => $Notification->parentUriId]);
return $message; return $message;
} }
if ($Notification->type == Post\UserNotification::TYPE_COMMENT_PARTICIPATION) { $link_item = Post::selectFirstPost(['guid'], ['uri-id' => $Notification->targetUriId]);
$link_item = Post::selectFirst(['guid'], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]], ['order' => ['uid' => true]]);
}
} else { } else {
$item = Post::selectFirst([], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]], ['order' => ['uid' => true]]); $item = Post::selectFirst([], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]], ['order' => ['uid' => true]]);
if (empty($item)) { if (empty($item)) {
@ -156,6 +154,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
return $message; return $message;
} }
} }
$link_item = $item;
} }
if (in_array($Notification->type, [Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_SHARED])) { if (in_array($Notification->type, [Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION, Post\UserNotification::TYPE_SHARED])) {
@ -166,7 +165,7 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
} }
} }
$link = $this->baseUrl . '/display/' . urlencode($link_item['guid'] ?? $item['guid']); $link = $this->baseUrl . '/display/' . urlencode($link_item['guid']);
$content = Plaintext::getPost($item, 70); $content = Plaintext::getPost($item, 70);
if (!empty($content['text'])) { if (!empty($content['text'])) {

View File

@ -27,6 +27,7 @@ use Friendica\BaseRepository;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\Post\UserNotification;
use Friendica\Model\Verb; use Friendica\Model\Verb;
use Friendica\Navigation\Notifications\Collection; use Friendica\Navigation\Notifications\Collection;
use Friendica\Navigation\Notifications\Entity; use Friendica\Navigation\Notifications\Entity;
@ -137,7 +138,8 @@ class Notification extends BaseRepository
*/ */
public function selectDigestForUser(int $uid): Collection\Notifications public function selectDigestForUser(int $uid): Collection\Notifications
{ {
$values = [$uid]; $values = [$uid, Verb::getID(\Friendica\Protocol\Activity::ANNOUNCE),
UserNotification::TYPE_COMMENT_PARTICIPATION, UserNotification::TYPE_ACTIVITY_PARTICIPATION, UserNotification::TYPE_THREAD_COMMENT];
$like_condition = ''; $like_condition = '';
if (!$this->pconfig->get($uid, 'system', 'notify_like')) { if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
@ -154,10 +156,10 @@ class Notification extends BaseRepository
$rows = $this->db->p(" $rows = $this->db->p("
SELECT notification.* SELECT notification.*
FROM notification FROM notification
WHERE id IN ( WHERE `id` IN (
SELECT MAX(`id`) SELECT MAX(`id`)
FROM notification FROM `notification`
WHERE uid = ? WHERE `uid` = ? AND NOT (`vid` = ? AND `type` IN (?, ?, ?))
$like_condition $like_condition
$announce_condition $announce_condition
GROUP BY IFNULL(`parent-uri-id`, `actor-id`) GROUP BY IFNULL(`parent-uri-id`, `actor-id`)