X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FItem%2FActivity.php;h=c9d192d249f07458ca66cfe613c0c5126231d0f4;hb=39a5bfc0c0ea3777b63adb57a7d6cb4b40a70e86;hp=df2be5dd0c0dd0a30c392280de17d4cff5ab8eb7;hpb=054c301ef0345c4ff9f35cfd08717757eab17b9d;p=friendica.git diff --git a/src/Module/Item/Activity.php b/src/Module/Item/Activity.php index df2be5dd0c..c9d192d249 100644 --- a/src/Module/Item/Activity.php +++ b/src/Module/Item/Activity.php @@ -1,6 +1,6 @@ isAuthenticated()) { throw new HTTPException\ForbiddenException(); } - if (empty($parameters['id']) || empty($parameters['verb'])) { + if (empty($this->parameters['id']) || empty($this->parameters['verb'])) { throw new HTTPException\BadRequestException(); } - $verb = $parameters['verb']; - $itemId = $parameters['id']; + $verb = $this->parameters['verb']; + $itemId = $this->parameters['id']; + $handled = false; if (in_array($verb, ['announce', 'unannounce'])) { - $item = Post::selectFirst(['network'], ['id' => $itemId]); + $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [DI::userSession()->getLocalUserId(), 0]]); if ($item['network'] == Protocol::DIASPORA) { - self::performDiasporaReshare($itemId); + $quote = Post::selectFirst(['id'], ['quote-uri-id' => $item['uri-id'], 'body' => '', 'origin' => true, 'uid' => DI::userSession()->getLocalUserId()]); + if (!empty($quote['id'])) { + if (!Item::markForDeletionById($quote['id'])) { + throw new HTTPException\BadRequestException(); + } + } else { + Diaspora::performReshare($item['uri-id'], DI::userSession()->getLocalUserId()); + } + $handled = true; } } - if (!Item::performActivity($itemId, $verb, local_user())) { + if (!$handled && !Item::performActivity($itemId, $verb, DI::userSession()->getLocalUserId())) { throw new HTTPException\BadRequestException(); } @@ -85,32 +91,4 @@ class Activity extends BaseModule System::jsonExit($return); } - - private static function performDiasporaReshare(int $itemId) - { - $fields = ['uri-id', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; - $item = Post::selectFirst($fields, ['id' => $itemId, 'private' => [Item::PUBLIC, Item::UNLISTED]]); - if (!DBA::isResult($item) || ($item['body'] == '')) { - return; - } - - if (strpos($item['body'], '[/share]') !== false) { - $pos = strpos($item['body'], '[share'); - $post = substr($item['body'], $pos); - } else { - $post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']); - - if (!empty($item['title'])) { - $post .= '[h3]' . $item['title'] . "[/h3]\n"; - } - - $post .= $item['body']; - $post .= '[/share]'; - } - $_REQUEST['body'] = $post; - $_REQUEST['profile_uid'] = local_user(); - - require_once 'mod/item.php'; - item_post(DI::app()); - } }