]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Merge pull request #12244 from MrPetovan/bug/warnings
[friendica.git] / mod / item.php
index 0490e43a84325e721a8408473130fb0f57c37b8e..924059df815b4f00637a35e59c22e3328c7475fd 100644 (file)
@@ -34,7 +34,6 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
-use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -78,8 +77,6 @@ function item_post(App $a) {
 
        Logger::debug('postvars', ['_REQUEST' => $_REQUEST]);
 
-       $api_source = $_REQUEST['api_source'] ?? false;
-
        $return_path = $_REQUEST['return'] ?? '';
        $preview = intval($_REQUEST['preview'] ?? 0);
 
@@ -91,7 +88,7 @@ function item_post(App $a) {
        if (!$preview && !empty($_REQUEST['post_id_random'])) {
                if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
                        Logger::warning('duplicate post');
-                       item_post_return(DI::baseUrl(), $api_source, $return_path);
+                       item_post_return(DI::baseUrl(), $return_path);
                } else {
                        $_SESSION['post-random'] = $_REQUEST['post_id_random'];
                }
@@ -107,7 +104,7 @@ function item_post(App $a) {
        $toplevel_user_id = null;
 
        $objecttype = null;
-       $profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: DI::userSession()->getLocalUserId();
+       $profile_uid = DI::userSession()->getLocalUserId();
        $posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
 
        if ($parent_item_id || $thr_parent_uri) {
@@ -178,7 +175,7 @@ function item_post(App $a) {
 
        // Now check that valid personal details have been provided
        if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
-               Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
+               Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
                DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                if ($return_path) {
                        DI::baseUrl()->redirect($return_path);
@@ -323,13 +320,6 @@ function item_post(App $a) {
 
                $pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
 
-               // if using the API, we won't see pubmail_enable - figure out if it should be set
-               if ($api_source && $profile_uid && $profile_uid == DI::userSession()->getLocalUserId() && !$private) {
-                       if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
-                               $pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", DI::userSession()->getLocalUserId(), '']);
-                       }
-               }
-
                if (!strlen($body)) {
                        if ($preview) {
                                System::jsonExit(['preview' => '']);
@@ -580,7 +570,7 @@ function item_post(App $a) {
                'parent'        => $toplevel_item_id,
                'self'          => $self,
                // This triggers posts via API and the mirror functions
-               'api_source'    => $api_source,
+               'api_source'    => false,
                // This field is for storing the raw conversation data
                'protocol'      => Conversation::PARCEL_DIRECT,
                'direction'     => Conversation::PUSH,
@@ -612,7 +602,8 @@ function item_post(App $a) {
                $datarray['author-uri-id'] = ItemURI::getIdByURI($datarray['author-link']);
                $datarray['owner-updated'] = '';
                $datarray['has-media'] = false;
-               $datarray['body'] = Item::improveSharedDataInBody($datarray);
+               $datarray['quote-uri-id'] = Item::getQuoteUriId($datarray['body'], $datarray['uid']);
+               $datarray['body'] = BBCode::removeSharedData($datarray['body']);
 
                $o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
 
@@ -634,7 +625,7 @@ function item_post(App $a) {
                        unset($datarray['api_source']);
 
                        Post\Delayed::add($datarray['uri'], $datarray, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
-                       item_post_return(DI::baseUrl(), $api_source, $return_path);
+                       item_post_return(DI::baseUrl(), $return_path);
                }
        }
 
@@ -653,7 +644,12 @@ function item_post(App $a) {
        }
 
        $datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
-       $datarray['body']   = Item::improveSharedDataInBody($datarray);
+
+       $quote_uri_id = Item::getQuoteUriId($datarray['body'], $datarray['uid']);
+       if (!empty($quote_uri_id)) {
+               $datarray['quote-uri-id'] = $quote_uri_id;
+               $datarray['body']         = BBCode::removeSharedData($datarray['body']);
+       }
 
        if ($orig_post) {
                $fields = [
@@ -750,20 +746,12 @@ function item_post(App $a) {
 
        Logger::debug('post_complete');
 
-       if ($api_source) {
-               return $post_id;
-       }
-
-       item_post_return(DI::baseUrl(), $api_source, $return_path);
+       item_post_return(DI::baseUrl(), $return_path);
        // NOTREACHED
 }
 
-function item_post_return($baseurl, $api_source, $return_path)
+function item_post_return($baseurl, $return_path)
 {
-       if ($api_source) {
-               return;
-       }
-
        if ($return_path) {
                DI::baseUrl()->redirect($return_path);
        }