]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Merge pull request #5776 from annando/fix-contact
[friendica.git] / mod / item.php
index 125606d2778697a2d9e36383cf1eb84616f00f15..213a9907898bf0cafa98de592528716c2018bd23 100644 (file)
@@ -39,7 +39,7 @@ require_once 'include/items.php';
 
 function item_post(App $a) {
        if (!local_user() && !remote_user()) {
-               return;
+               return 0;
        }
 
        require_once 'include/security.php';
@@ -152,9 +152,9 @@ function item_post(App $a) {
 
        // Check for multiple posts with the same message id (when the post was created via API)
        if (($message_id != '') && ($profile_uid != 0)) {
-               if (DBA::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) {
+               if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) {
                        logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
-                       return;
+                       return 0;
                }
        }
 
@@ -183,7 +183,7 @@ function item_post(App $a) {
        $user = DBA::selectFirst('user', [], ['uid' => $profile_uid]);
 
        if (!DBA::isResult($user) && !$parent) {
-               return;
+               return 0;
        }
 
        $categories = '';
@@ -395,12 +395,12 @@ function item_post(App $a) {
                                $tagged[] = $tag;
                        }
                        // When the forum is private or the forum is addressed with a "!" make the post private
-                       if (is_array($success['contact']) && ($success['contact']['prv'] || ($tag_type == '!'))) {
+                       if (is_array($success['contact']) && (!empty($success['contact']['prv']) || ($tag_type == '!'))) {
                                $private_forum = $success['contact']['prv'];
                                $only_to_forum = ($tag_type == '!');
                                $private_id = $success['contact']['id'];
                                $forum_contact = $success['contact'];
-                       } elseif (is_array($success['contact']) && $success['contact']['forum'] &&
+                       } elseif (is_array($success['contact']) && !empty($success['contact']['forum']) &&
                                ($str_contact_allow == '<' . $success['contact']['id'] . '>')) {
                                $private_forum = false;
                                $only_to_forum = true;
@@ -843,6 +843,10 @@ function item_post(App $a) {
 
        logger('post_complete');
 
+       if ($api_source) {
+               return $post_id;
+       }
+
        item_post_return(System::baseUrl(), $api_source, $return_path);
        // NOTREACHED
 }