- $post['uri-id'] = ItemURI::getIdByURI($post['uri']);
-
- $quote_uri_id = Item::getQuoteUriId($post['body'], $post['uid']);
- if (!empty($quote_uri_id)) {
- $post['quote-uri-id'] = $quote_uri_id;
- $post['body'] = BBCode::removeSharedData($post['body']);
- }
-
- if ($orig_post) {
- $fields = [
- 'title' => $post['title'],
- 'body' => $post['body'],
- 'attach' => $post['attach'],
- 'file' => $post['file'],
- 'edited' => DateTimeFormat::utcNow(),
- 'changed' => DateTimeFormat::utcNow()
- ];
-
- Item::update($fields, ['id' => $post_id]);
- Item::updateDisplayCache($post['uri-id']);
-
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\OKException(DI::l10n()->t('Post updated.'));
- }
-
- unset($post['edit']);
- unset($post['self']);
- unset($post['api_source']);
-
- $post_id = Item::insert($post);
- if (!$post_id) {
- DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\InternalServerErrorException(DI::l10n()->t('Item wasn\'t stored.'));
- }
-
- $post = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
- if (!DBA::isResult($post)) {
- Logger::error('Item couldn\'t be fetched.', ['post_id' => $post_id]);
- if ($return_path) {
- DI::baseUrl()->redirect($return_path);
- }
-
- throw new HTTPException\InternalServerErrorException(DI::l10n()->t('Item couldn\'t be fetched.'));
- }
-
- if (!\Friendica\Content\Feature::isEnabled($post['uid'], 'explicit_mentions') && ($post['gravity'] == Item::GRAVITY_COMMENT)) {
- Tag::createImplicitMentions($post['uri-id'], $post['thr-parent-id']);
- }
-
- Hook::callAll('post_local_end', $post);
-
- $recipients = explode(',', $emailcc);
- if (count($recipients)) {
- foreach ($recipients as $recipient) {
- $address = trim($recipient);
- if (!strlen($address)) {
- continue;
- }
-
- $author = DBA::selectFirst('contact', ['thumb'], ['uid' => $uid, 'self' => true]);
-
- DI::emailer()->send(new ItemCCEMail(DI::app(), DI::l10n(), DI::baseUrl(),
- $post, $address, $author['thumb'] ?? ''));
- }
- }
-
- Logger::debug('post_complete');
-
- item_post_return(DI::baseUrl(), $return_path);
- // NOTREACHED