]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Mastodon/Statuses.php
Prevent expandTags to be performed on existing links in Module\Api\Mastodon\Statuses
[friendica.git] / src / Module / Api / Mastodon / Statuses.php
index 77915cab27d9dbb0edd18c90c8a90c396efea24c..ed5abf1996b9e44cb817b0c43287519627249424 100644 (file)
@@ -63,7 +63,10 @@ class Statuses extends BaseApi
                // The imput is defined as text. So we can use Markdown for some enhancements
                $body = Markdown::toBBCode($request['status']);
 
-               $body = BBCode::expandTags($body);
+               // Avoids potential double expansion of existing links
+               $body = BBCode::performWithEscapedTags($body, ['url'], function ($body) {
+                       return BBCode::expandTags($body);
+               });
 
                $item = [];
                $item['uid']        = $uid;
@@ -104,7 +107,7 @@ class Statuses extends BaseApi
                                        $item['deny_gid']  = $owner['deny_gid'];
                                } else {
                                        $item['allow_cid'] = '';
-                                       $item['allow_gid'] = [Group::FOLLOWERS];
+                                       $item['allow_gid'] = '<' . Group::FOLLOWERS . '>';
                                        $item['deny_cid']  = '';
                                        $item['deny_gid']  = '';
                                }
@@ -140,6 +143,8 @@ class Statuses extends BaseApi
                        $item['gravity']     = GRAVITY_COMMENT;
                        $item['object-type'] = Activity\ObjectType::COMMENT;
                } else {
+                       self::checkThrottleLimit();
+
                        $item['gravity']     = GRAVITY_PARENT;
                        $item['object-type'] = Activity\ObjectType::NOTE;
                }
@@ -181,6 +186,16 @@ class Statuses extends BaseApi
                        }
                }
 
+               if (!empty($request['scheduled_at'])) {
+                       $item['guid'] = Item::guid($item, true);
+                       $item['uri'] = Item::newURI($item['uid'], $item['guid']);
+                       $id = Post\Delayed::add($item['uri'], $item, PRIORITY_HIGH, Post\Delayed::PREPARED, $request['scheduled_at']);
+                       if (empty($id)) {
+                               DI::mstdnError()->InternalError();
+                       }
+                       System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray());
+               }
+
                $id = Item::insert($item, true);
                if (!empty($id)) {
                        $item = Post::selectFirst(['uri-id'], ['id' => $id]);