Create notifications for shared posts

This commit is contained in:
Michael 2020-08-12 04:35:24 +00:00
parent 4b15b9fe56
commit 4ee858740e
2 changed files with 9 additions and 3 deletions

View file

@ -597,7 +597,7 @@ function check_item_notification($itemid, $uid, $notification_type) {
$fields = ['id', 'uri-id', 'mention', 'parent', 'parent-uri-id', 'title', 'body', $fields = ['id', 'uri-id', 'mention', 'parent', 'parent-uri-id', 'title', 'body',
'author-link', 'author-name', 'author-avatar', 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-id',
'guid', 'parent-uri', 'uri', 'contact-id', 'network']; 'guid', 'parent-uri', 'uri', 'contact-id', 'network'];
$condition = ['id' => $itemid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'deleted' => false]; $condition = ['id' => $itemid, 'deleted' => false];
$item = Item::selectFirstForUser($uid, $fields, $condition); $item = Item::selectFirstForUser($uid, $fields, $condition);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
return false; return false;

View file

@ -27,6 +27,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Protocol\Activity;
class UserItem class UserItem
{ {
@ -50,7 +51,8 @@ class UserItem
*/ */
public static function setNotification(int $iid) public static function setNotification(int $iid)
{ {
$fields = ['id', 'uri-id', 'uid', 'body', 'parent', 'gravity', 'tag', 'contact-id', 'thr-parent', 'parent-uri', 'author-id']; $fields = ['id', 'uri-id', 'uid', 'body', 'parent', 'gravity', 'tag',
'contact-id', 'thr-parent', 'parent-uri', 'author-id', 'verb'];
$item = Item::selectFirst($fields, ['id' => $iid, 'origin' => false]); $item = Item::selectFirst($fields, ['id' => $iid, 'origin' => false]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
return; return;
@ -197,7 +199,7 @@ class UserItem
*/ */
private static function checkShared(array $item, int $uid) private static function checkShared(array $item, int $uid)
{ {
if ($item['gravity'] != GRAVITY_PARENT) { if (($item['gravity'] != GRAVITY_PARENT) && ($item['verb'] != Activity::ANNOUNCE)) {
return false; return false;
} }
@ -206,6 +208,10 @@ class UserItem
return true; return true;
} }
if ($item['gravity'] != GRAVITY_PARENT) {
return false;
}
// Or the contact is a mentioned forum // Or the contact is a mentioned forum
$tags = DBA::select('tag-view', ['url'], ['uri-id' => $item['uri-id'], 'type' => [Tag::MENTION, Tag::EXCLUSIVE_MENTION]]); $tags = DBA::select('tag-view', ['url'], ['uri-id' => $item['uri-id'], 'type' => [Tag::MENTION, Tag::EXCLUSIVE_MENTION]]);
while ($tag = DBA::fetch($tags)) { while ($tag = DBA::fetch($tags)) {