]> git.mxchange.org Git - friendica.git/commitdiff
Improved code style
authorMichael <heluecht@pirati.ca>
Mon, 6 Jan 2025 22:15:41 +0000 (22:15 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 6 Jan 2025 22:15:41 +0000 (22:15 +0000)
src/BaseModule.php
src/Module/Api/Mastodon/Lists/Accounts.php
src/Module/Api/Mastodon/Markers.php
src/Module/Api/Mastodon/PushSubscription.php
src/Module/Api/Mastodon/ScheduledStatuses.php
src/Module/Api/Mastodon/Statuses.php

index aa72249c7326fc942c60e3fa438630dc51a2570a..bdfba74ce9cfed9b07fcd0c2c41c8d716204fc04 100644 (file)
@@ -237,7 +237,7 @@ abstract class BaseModule implements ICanHandleRequests
                        case Router::GET:
                                $this->get($request);
                                break;
-                       }
+               }
 
                $timestamp = microtime(true);
                // "rawContent" is especially meant for technical endpoints.
index 5d3798946ca7d7ba636ad526cdb0c5d760199d3d..796ced67b841d264f835461f7a54136aff2c4cd0 100644 (file)
@@ -7,7 +7,6 @@
 
 namespace Friendica\Module\Api\Mastodon\Lists;
 
-use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Circle;
@@ -40,7 +39,7 @@ class Accounts extends BaseApi
                $this->checkAllowedScope(self::SCOPE_WRITE);
 
                $request = $this->getRequest([
-                       'account_ids' =>  [], // Array of account IDs to add to the list
+                       'account_ids' => [], // Array of account IDs to add to the list
                ], $request);
 
                if (empty($request['account_ids']) || empty($this->parameters['id'])) {
index 5c9b6476a1738ff3f09035569be47acb5345a893..358dc6c01aa4b3f9bcdd5d4c57ffcc641d4a2a38 100644 (file)
@@ -36,7 +36,7 @@ class Markers extends BaseApi
                }
 
                $condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline];
-               $marker = DBA::selectFirst('application-marker', [], $condition);
+               $marker    = DBA::selectFirst('application-marker', [], $condition);
                if (!empty($marker['version'])) {
                        $version = $marker['version'] + 1;
                } else {
@@ -62,7 +62,7 @@ class Markers extends BaseApi
 
        private function fetchTimelines(int $application_id, int $uid): \stdClass
        {
-               $values = new \stdClass();
+               $values  = new \stdClass();
                $markers = DBA::select('application-marker', [], ['application-id' => $application_id, 'uid' => $uid]);
                while ($marker = DBA::fetch($markers)) {
                        $values->{$marker['timeline']} = [
index 835a8273d59576b7ba2afdc3c99bf71e63be6727..0c8e1d52571737cd60cb7b659f2808faf1b59d9b 100644 (file)
@@ -49,9 +49,9 @@ class PushSubscription extends BaseApi
                $subscription = [
                        'application-id'                => $application['id'],
                        'uid'                           => $uid,
-                       'endpoint'                      => $request['subscription']['endpoint'] ?? '',
+                       'endpoint'                      => $request['subscription']['endpoint']       ?? '',
                        'pubkey'                        => $request['subscription']['keys']['p256dh'] ?? '',
-                       'secret'                        => $request['subscription']['keys']['auth'] ?? '',
+                       'secret'                        => $request['subscription']['keys']['auth']   ?? '',
                        Notification::TYPE_FOLLOW       => filter_var($request['data']['alerts'][Notification::TYPE_FOLLOW] ?? false, FILTER_VALIDATE_BOOLEAN),
                        Notification::TYPE_LIKE         => filter_var($request['data']['alerts'][Notification::TYPE_LIKE] ?? false, FILTER_VALIDATE_BOOLEAN),
                        Notification::TYPE_RESHARE      => filter_var($request['data']['alerts'][Notification::TYPE_RESHARE] ?? false, FILTER_VALIDATE_BOOLEAN),
index 3cb8568639616d09538fb5803637bfcb2edb08eb..92033804322a7446f642c54f179768387a5f4af4 100644 (file)
@@ -8,7 +8,6 @@
 namespace Friendica\Module\Api\Mastodon;
 
 use Friendica\App\Router;
-use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Post;
@@ -58,10 +57,10 @@ class ScheduledStatuses extends BaseApi
                }
 
                $request = $this->getRequest([
-                       'limit'           => 20, // Max number of results to return. Defaults to 20.
-                       'max_id'          => 0,  // Return results older than ID
-                       'since_id'        => 0,  // Return results newer than ID
-                       'min_id'          => 0,  // Return results immediately newer than ID
+                       'limit'    => 20, // Max number of results to return. Defaults to 20.
+                       'max_id'   => 0,  // Return results older than ID
+                       'since_id' => 0,  // Return results newer than ID
+                       'min_id'   => 0,  // Return results immediately newer than ID
                ], $request);
 
                $params = ['order' => ['id' => true], 'limit' => $request['limit']];
@@ -77,7 +76,7 @@ class ScheduledStatuses extends BaseApi
                }
 
                if (!empty($request['min_id'])) {
-                       $condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $request['min_id']]);
+                       $condition       = DBA::mergeConditions($condition, ["`uri-id` > ?", $request['min_id']]);
                        $params['order'] = ['uri-id'];
                }
 
index 8d0fcdd2099318594efbcfc1f8c0a026c4d5f710..9bf6ca382e802cbf27b3e6437485259ec58316e2 100644 (file)
@@ -64,18 +64,18 @@ class Statuses extends BaseApi
                        throw new HTTPException\NotFoundException('Item with URI ID ' . $this->parameters['id'] . ' not found for user ' . $uid . '.');
                }
 
-               $item['title']      = '';
-               $item['uid']        = $post['uid'];
-               $item['body']       = $this->formatStatus($request['status'], $uid);
-               $item['network']    = $post['network'];
-               $item['gravity']    = $post['gravity'];
-               $item['verb']       = $post['verb'];
-               $item['allow_cid']  = $post['allow_cid'];
-               $item['allow_gid']  = $post['allow_gid'];
-               $item['deny_cid']   = $post['deny_cid'];
-               $item['deny_gid']   = $post['deny_gid'];
-               $item['app']        = $this->getApp();
-               $item['sensitive']  = $request['sensitive'];
+               $item['title']     = '';
+               $item['uid']       = $post['uid'];
+               $item['body']      = $this->formatStatus($request['status'], $uid);
+               $item['network']   = $post['network'];
+               $item['gravity']   = $post['gravity'];
+               $item['verb']      = $post['verb'];
+               $item['allow_cid'] = $post['allow_cid'];
+               $item['allow_gid'] = $post['allow_gid'];
+               $item['deny_cid']  = $post['deny_cid'];
+               $item['deny_gid']  = $post['deny_gid'];
+               $item['app']       = $this->getApp();
+               $item['sensitive'] = $request['sensitive'];
 
                if (!empty($request['language'])) {
                        $item['language'] = json_encode([$request['language'] => 1]);
@@ -91,7 +91,7 @@ class Statuses extends BaseApi
                        if (!isset($request['friendica']['title']) && $post['gravity'] == Item::GRAVITY_PARENT && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) {
                                $item['title'] = $spoiler_text;
                        } else {
-                               $item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $spoiler_text . "[/abstract]\n" . $item['body'];
+                               $item['body']            = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $spoiler_text . "[/abstract]\n" . $item['body'];
                                $item['content-warning'] = BBCode::toPlaintext($spoiler_text);
                        }
                }
@@ -307,7 +307,8 @@ class Statuses extends BaseApi
 
                if (!empty($request['scheduled_at'])) {
                        $item['guid'] = Item::guid($item, true);
-                       $item['uri'] = Item::newURI($item['guid']);
+                       $item['uri']  = Item::newURI($item['guid']);
+
                        $id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at']));
                        if (empty($id)) {
                                $this->logAndJsonError(500, $this->errorFactory->InternalError());
@@ -385,7 +386,7 @@ class Statuses extends BaseApi
 
                foreach ($media_ids as $id) {
                        if (DI::mstdnAttachment()->isAttach($id) && Attach::exists(['id' => substr($id, 7)])) {
-                               $attach = Attach::selectFirst([], ['id' => substr($id, 7)]);
+                               $attach     = Attach::selectFirst([], ['id' => substr($id, 7)]);
                                $attachment = [
                                        'type'     => Post\Media::getType($attach['filetype']),
                                        'mimetype' => $attach['filetype'],
@@ -422,8 +423,8 @@ class Statuses extends BaseApi
                        ];
 
                        if (count($media) > 1) {
-                               $attachment['preview'] = DI::baseUrl() . '/photo/' . $media[1]['resource-id'] . '-' . $media[1]['scale'] . $ext;
-                               $attachment['preview-width'] = $media[1]['width'];
+                               $attachment['preview']        = DI::baseUrl() . '/photo/' . $media[1]['resource-id'] . '-' . $media[1]['scale'] . $ext;
+                               $attachment['preview-width']  = $media[1]['width'];
                                $attachment['preview-height'] = $media[1]['height'];
                        }
                        $item['attachments'][] = $attachment;