X-Git-Url: https://reisub.nsupdate.info/git/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=a4ba41a69586fd66b9e78d5fc567b90531d044f4;hb=e6cd5a4d663c74213a572a5528c32f721b677c9e;hp=d8fbac8307d18065e19f9c7bd5a7963e77828108;hpb=74bc3de4723af3f2bf61705edba090caa102d171;p=friendica.git%2F.git diff --git a/src/Model/Item.php b/src/Model/Item.php index d8fbac8307..a4ba41a695 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1967,7 +1967,7 @@ class Item check_user_notification($current_post); // Distribute items to users who subscribed to their tags - self::distributeByTags($item, $orig_item); + self::distributeByTags($item); $transmit = $notify || ($item['visible'] && ($parent_origin || $item['origin'])); @@ -1992,9 +1992,8 @@ class Item * Distribute the given item to users who subscribed to their tags * * @param array $item Processed item - * @param array $original Original item */ - private static function distributeByTags(array $item, array $original) + private static function distributeByTags(array $item) { if (($item['uid'] != 0) || ($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], Protocol::FEDERATED)) { return; @@ -2002,9 +2001,7 @@ class Item $uids = Tag::getUIDListByURIId($item['uri-id']); foreach ($uids as $uid) { - $original['uri-id'] = $item['uri-id']; - $original['gravity'] = $item['gravity']; - $stored = self::storeForUser($original, $uid); + $stored = self::storeForUserByUriId($item['uri-id'], $uid); Logger::info('Stored item for users', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]); } } @@ -2169,14 +2166,33 @@ class Item } /** - * Store public items for the receivers + * Store a public item defined by their URI-ID for the given users + * + * @param integer $uri_id URI-ID of the given item + * @param integer $uid The user that will receive the item entry + * @return integer stored item id + */ + public static function storeForUserByUriId(int $uri_id, int $uid) + { + $item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $uri_id, 'uid' => 0]); + if (empty($item) || ($item['private'] != self::PRIVATE)) { + return 0; + } + + $stored = self::storeForUser($item, $uid); + Logger::info('Public item stored for user', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'stored' => $stored]); + return $stored; + } + + /** + * Store a public item array for the given users * * @param array $item The item entry that will be stored * @param integer $uid The user that will receive the item entry * @return integer stored item id * @throws \Exception */ - public static function storeForUser(array $item, int $uid) + private static function storeForUser(array $item, int $uid) { if (self::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) { Logger::info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid]); @@ -2187,6 +2203,8 @@ class Item unset($item['parent']); unset($item['mention']); unset($item['starred']); + unset($item['unseen']); + unset($item['psid']); $item['uid'] = $uid; $item['origin'] = 0; @@ -3018,11 +3036,7 @@ class Item } if (!Item::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $uid])) { - $parent_item = self::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $item['parent-uri-id'], 'uid' => 0]); - if (!empty($parent_item) && ($parent_item['private'] != self::PRIVATE)) { - $stored = self::storeForUser($parent_item, $uid); - Logger::info('Public item stored for user', ['uri-id' => $parent_item['uri-id'], 'uid' => $uid, 'stored' => $stored]); - } + $stored = self::storeForUserByUriId($item['parent-uri-id'], $uid); } // Retrieves the local post owner