X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=5cc72b05800bc15ebc60a92effb08baf3c553b8e;hb=a4b0ab90b1ac32f7cdb875387f511c980dbed9ce;hp=0c48c9529189bc4d418eea659c6d8613cb28a8a4;hpb=c73130aa6b83951b9e6ecc05c66d25292b5b9091;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 0c48c95291..5cc72b0580 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -706,7 +706,7 @@ class Item return GRAVITY_UNKNOWN; // Should not happen } - public static function insert($item, $notify = false, $dontcache = false) + public static function insert(array $item, bool $notify = false, bool $post_local = true) { $orig_item = $item; @@ -931,7 +931,7 @@ class Item $item["private"] = self::PRIVATE; } - if ($notify) { + if ($notify && $post_local) { $item['edit'] = false; $item['parent'] = $parent_id; @@ -953,7 +953,7 @@ class Item unset($_SESSION['authenticated']); unset($_SESSION['uid']); } - } else { + } elseif (!$notify) { Hook::callAll('post_remote', $item); } @@ -1039,7 +1039,7 @@ class Item } $event_id = Event::store($ev); - $item = Event::getItemArrayForId($event_id, $item); + $item = Event::getItemArrayForImportedId($event_id, $item); Logger::info('Event was stored', ['id' => $event_id]); } @@ -1061,13 +1061,7 @@ class Item // Create Diaspora signature if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) { - if ($uid == 0) { - $sender_contact = Contact::getById($item['contact-id'], ['uid']); - $sender_uid = $sender_contact['uid']; - } else { - $sender_uid = $uid; - } - $signed = Diaspora::createCommentSignature($sender_uid, $item); + $signed = Diaspora::createCommentSignature($item); if (!empty($signed)) { $item['diaspora_signed_text'] = json_encode($signed); } @@ -1147,15 +1141,13 @@ class Item return 0; } - if (!$dontcache) { - if ($notify) { - if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) { - Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']); - } - Hook::callAll('post_local_end', $posted_item); - } else { - Hook::callAll('post_remote_end', $posted_item); + if ($notify) { + if (!\Friendica\Content\Feature::isEnabled($posted_item['uid'], 'explicit_mentions') && ($posted_item['gravity'] == GRAVITY_COMMENT)) { + Tag::createImplicitMentions($posted_item['uri-id'], $posted_item['thr-parent-id']); } + Hook::callAll('post_local_end', $posted_item); + } else { + Hook::callAll('post_remote_end', $posted_item); } if ($posted_item['gravity'] === GRAVITY_PARENT) { @@ -1168,8 +1160,6 @@ class Item Post\UserNotification::setNotification($posted_item['uri-id'], $posted_item['uid']); - check_user_notification($posted_item['uri-id'], $posted_item['uid']); - // Distribute items to users who subscribed to their tags self::distributeByTags($posted_item); @@ -1471,7 +1461,7 @@ class Item } } - $distributed = self::insert($item, $notify, true); + $distributed = self::insert($item, $notify); if (!$distributed) { Logger::info("Distributed item wasn't stored", ['uri-id' => $item['uri-id'], 'user' => $uid]); @@ -1540,7 +1530,7 @@ class Item $item['contact-id'] = $item['author-id']; } - $public_shadow = self::insert($item, false, true); + $public_shadow = self::insert($item); Logger::info('Stored public shadow', ['thread' => $itemid, 'id' => $public_shadow]); } @@ -1599,7 +1589,7 @@ class Item unset($item['post-reason']); $item['contact-id'] = Contact::getIdForURL($item['author-link']); - $public_shadow = self::insert($item, false, true); + $public_shadow = self::insert($item); Logger::info('Stored public shadow', ['uri-id' => $item['uri-id'], 'id' => $public_shadow]); @@ -2765,6 +2755,8 @@ class Item $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']); } + $item['attachments'] = $attachments; + $hook_data = [ 'item' => $item, 'filter_reasons' => $filter_reasons