X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=5cc72b05800bc15ebc60a92effb08baf3c553b8e;hb=a4b0ab90b1ac32f7cdb875387f511c980dbed9ce;hp=7cda359003c8c31cb5d2eb9d7dc88bc85e3a4033;hpb=9226b98724b688e269e18e37b5c369c719d5b715;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 7cda359003..5cc72b0580 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -363,7 +363,7 @@ class Item return true; } - private static function guid($item, $notify) + public static function guid($item, $notify) { if (!empty($item['guid'])) { return Strings::escapeTags(trim($item['guid'])); @@ -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,7 +1061,7 @@ class Item // Create Diaspora signature if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) { - $signed = Diaspora::createCommentSignature($uid, $item); + $signed = Diaspora::createCommentSignature($item); if (!empty($signed)) { $item['diaspora_signed_text'] = json_encode($signed); } @@ -1141,12 +1141,13 @@ class Item return 0; } - if (!$dontcache) { - if ($notify) { - 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) { @@ -1159,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); @@ -1462,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]); @@ -1531,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]); } @@ -1590,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]); @@ -2756,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