]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Replace "notice" calls
[friendica.git] / mod / item.php
index 26dcef91cdf21db43ccb612974b0c6d0ff27b432..cc8e9538583ff3c53fd19f1785f58eba47f2775e 100644 (file)
@@ -36,6 +36,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Session;
 use Friendica\Core\System;
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Attach;
@@ -89,7 +90,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::info('item post: duplicate post');
+                       Logger::warning('duplicate post');
                        item_post_return(DI::baseUrl(), $api_source, $return_path);
                } else {
                        $_SESSION['post-random'] = $_REQUEST['post_id_random'];
@@ -128,7 +129,7 @@ function item_post(App $a) {
                }
 
                if (!DBA::isResult($toplevel_item)) {
-                       notice(DI::l10n()->t('Unable to locate original post.'));
+                       DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
                        if ($return_path) {
                                DI::baseUrl()->redirect($return_path);
                        }
@@ -177,8 +178,8 @@ function item_post(App $a) {
 
        // Now check that valid personal details have been provided
        if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
-               Logger::notice('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
-               notice(DI::l10n()->t('Permission denied.'));
+               Logger::warning('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, '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);
                }
@@ -334,7 +335,7 @@ function item_post(App $a) {
                                System::jsonExit(['preview' => '']);
                        }
 
-                       notice(DI::l10n()->t('Empty post discarded.'));
+                       DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.'));
                        if ($return_path) {
                                DI::baseUrl()->redirect($return_path);
                        }
@@ -401,7 +402,7 @@ function item_post(App $a) {
                $body              = $item['body'];
                $inform            = $item['inform'];
                $postopts          = $item['postopts'];
-               $private           = $item['private']; 
+               $private           = $item['private'];
                $str_contact_allow = $item['allow_cid'];
                $str_group_allow   = $item['allow_gid'];
                $str_contact_deny  = $item['deny_cid'];
@@ -595,14 +596,7 @@ function item_post(App $a) {
        $datarray['protocol'] = Conversation::PARCEL_DIRECT;
        $datarray['direction'] = Conversation::PUSH;
 
-       if ($orig_post) {
-               $datarray['edit'] = true;
-       } else {
-               // If this was a share, add missing data here
-               $datarray = Item::addShareDataFromOriginal($datarray);
-
-               $datarray['edit'] = false;
-       }
+       $datarray['edit'] = $orig_post;
 
        // Check for hashtags in the body and repair or add hashtag links
        if ($preview || $orig_post) {
@@ -621,6 +615,7 @@ 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);
 
                $o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
 
@@ -641,7 +636,7 @@ function item_post(App $a) {
                        unset($datarray['self']);
                        unset($datarray['api_source']);
 
-                       Post\Delayed::add($datarray['uri'], $datarray, PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
+                       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);
                }
        }
@@ -661,6 +656,7 @@ function item_post(App $a) {
        }
 
        $datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
+       $datarray['body']   = Item::improveSharedDataInBody($datarray);
 
        if ($orig_post) {
                $fields = [
@@ -689,7 +685,7 @@ function item_post(App $a) {
        $post_id = Item::insert($datarray);
 
        if (!$post_id) {
-               notice(DI::l10n()->t('Item wasn\'t stored.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
                if ($return_path) {
                        DI::baseUrl()->redirect($return_path);
                }
@@ -755,7 +751,7 @@ function item_post(App $a) {
                }
        }
 
-       Logger::info('post_complete');
+       Logger::debug('post_complete');
 
        if ($api_source) {
                return $post_id;
@@ -780,7 +776,7 @@ function item_post_return($baseurl, $api_source, $return_path)
                $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
        }
 
-       Logger::info('post_json', ['json' => $json]);
+       Logger::debug('post_json', ['json' => $json]);
 
        System::jsonExit($json);
 }
@@ -845,7 +841,7 @@ function drop_item(int $id, string $return = '')
        $item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
 
        if (!DBA::isResult($item)) {
-               notice(DI::l10n()->t('Item not found.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
                DI::baseUrl()->redirect('network');
        }
 
@@ -866,8 +862,8 @@ function drop_item(int $id, string $return = '')
 
                item_redirect_after_action($item, $return);
        } else {
-               Logger::notice('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
-               notice(DI::l10n()->t('Permission denied.'));
+               Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
+               DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                DI::baseUrl()->redirect('display/' . $item['guid']);
                //NOTREACHED
        }