]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Twitter/Statuses/Retweet.php
Reenable Twitter/Statuses tests
[friendica.git] / src / Module / Api / Twitter / Statuses / Retweet.php
index 71ce6ed4ba2b3c3a109b455772252f4e9fec4179..15fc26925f8b1c751cdf415a919fe441f2c53513 100644 (file)
@@ -31,6 +31,7 @@ use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException\BadRequestException;
 use Friendica\Network\HTTPException\ForbiddenException;
 use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Protocol\Diaspora;
 
 /**
  * Repeats a status.
@@ -39,7 +40,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
  */
 class Retweet extends BaseApi
 {
-       protected function post(array $request = [], array $post = [])
+       protected function post(array $request = [])
        {
                self::checkAllowedScope(self::SCOPE_WRITE);
                $uid = self::getCurrentUserID();
@@ -51,45 +52,22 @@ class Retweet extends BaseApi
                }
 
                $fields = ['uri-id', 'network', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
-               $item = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
-       
+               $item   = Post::selectFirst($fields, ['id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
+
                if (DBA::isResult($item) && !empty($item['body'])) {
                        if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::TWITTER])) {
                                if (!Item::performActivity($id, 'announce', $uid)) {
                                        throw new InternalServerErrorException();
                                }
-       
+
                                $item_id = $id;
                        } else {
-                               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]";
-                               }
-                               $item = [
-                                       'uid'  => $uid,
-                                       'body' => $post,
-                                       'app'  => $request['source'] ?? '',
-                               ];
-
-                               if (empty($item['app']) && !empty(self::getCurrentApplication()['name'])) {
-                                       $item['app'] = self::getCurrentApplication()['name'];
-                               }
-       
-                               $item_id = Item::insert($item, true);
+                               $item_id = Diaspora::performReshare($item['uri-id'], $uid);
                        }
                } else {
                        throw new ForbiddenException();
                }
-       
+
                $status_info = DI::twitterStatus()->createFromItemId($item_id, $uid)->toArray();
 
                DI::apiResponse()->exit('status', ['status' => $status_info], $this->parameters['extension'] ?? null);