]> git.mxchange.org Git - friendica.git/commitdiff
Rename BaseApi->logErrorAndJsonExit to logAndJsonError to better match the functionality
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Oct 2023 13:37:49 +0000 (09:37 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Oct 2023 13:44:03 +0000 (09:44 -0400)
- Also it's shorter and we're paying by the character

57 files changed:
src/Module/Api/Friendica/Statuses/Dislike.php
src/Module/Api/Friendica/Statuses/DislikedBy.php
src/Module/Api/Friendica/Statuses/Undislike.php
src/Module/Api/Mastodon/Accounts.php
src/Module/Api/Mastodon/Accounts/Block.php
src/Module/Api/Mastodon/Accounts/Follow.php
src/Module/Api/Mastodon/Accounts/Followers.php
src/Module/Api/Mastodon/Accounts/Following.php
src/Module/Api/Mastodon/Accounts/Lists.php
src/Module/Api/Mastodon/Accounts/Mute.php
src/Module/Api/Mastodon/Accounts/Note.php
src/Module/Api/Mastodon/Accounts/Relationships.php
src/Module/Api/Mastodon/Accounts/Statuses.php
src/Module/Api/Mastodon/Accounts/Unblock.php
src/Module/Api/Mastodon/Accounts/Unfollow.php
src/Module/Api/Mastodon/Accounts/Unmute.php
src/Module/Api/Mastodon/Apps.php
src/Module/Api/Mastodon/Apps/VerifyCredentials.php
src/Module/Api/Mastodon/Conversations.php
src/Module/Api/Mastodon/Conversations/Read.php
src/Module/Api/Mastodon/Lists.php
src/Module/Api/Mastodon/Lists/Accounts.php
src/Module/Api/Mastodon/Markers.php
src/Module/Api/Mastodon/Media.php
src/Module/Api/Mastodon/Mutes.php
src/Module/Api/Mastodon/Notifications.php
src/Module/Api/Mastodon/Notifications/Dismiss.php
src/Module/Api/Mastodon/Polls.php
src/Module/Api/Mastodon/PushSubscription.php
src/Module/Api/Mastodon/ScheduledStatuses.php
src/Module/Api/Mastodon/Search.php
src/Module/Api/Mastodon/Statuses.php
src/Module/Api/Mastodon/Statuses/Bookmark.php
src/Module/Api/Mastodon/Statuses/Card.php
src/Module/Api/Mastodon/Statuses/Context.php
src/Module/Api/Mastodon/Statuses/Favourite.php
src/Module/Api/Mastodon/Statuses/FavouritedBy.php
src/Module/Api/Mastodon/Statuses/Mute.php
src/Module/Api/Mastodon/Statuses/Pin.php
src/Module/Api/Mastodon/Statuses/Reblog.php
src/Module/Api/Mastodon/Statuses/RebloggedBy.php
src/Module/Api/Mastodon/Statuses/Source.php
src/Module/Api/Mastodon/Statuses/Unbookmark.php
src/Module/Api/Mastodon/Statuses/Unfavourite.php
src/Module/Api/Mastodon/Statuses/Unmute.php
src/Module/Api/Mastodon/Statuses/Unpin.php
src/Module/Api/Mastodon/Statuses/Unreblog.php
src/Module/Api/Mastodon/Tags.php
src/Module/Api/Mastodon/Tags/Follow.php
src/Module/Api/Mastodon/Tags/Unfollow.php
src/Module/Api/Mastodon/Timelines/Direct.php
src/Module/Api/Mastodon/Timelines/ListTimeline.php
src/Module/Api/Mastodon/Timelines/Tag.php
src/Module/BaseApi.php
src/Module/OAuth/Authorize.php
src/Module/OAuth/Revoke.php
src/Module/OAuth/Token.php

index 99c8eb857a57985c24bcf70879b7817836406f87..c436c8546918d96501666ab6109796fc2fc13ac0 100644 (file)
@@ -39,12 +39,12 @@ class Dislike extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Item::performActivity($item['id'], 'dislike', $uid);
index 3c13120873e6697b6202742b91368d6b84dc69fa..f6470330d54a47838df4220040a0f90ee222067f 100644 (file)
@@ -41,12 +41,12 @@ class DislikedBy extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::DISLIKE, 'deleted' => false]);
index 5387f1b10578871c0d94e54b5c64a95ad08a21d9..ba53f902b2eacb7accfd809f5f5a658526aed6f2 100644 (file)
@@ -39,12 +39,12 @@ class Undislike extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Item::performActivity($item['id'], 'undislike', $uid);
index 6b88b84ef3fac571fc365743abdfbd1e8888cda8..fcf443056deb4e0a9701b55ae38210ad5c541b10 100644 (file)
@@ -40,20 +40,20 @@ class Accounts extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!empty($this->parameters['id'])) {
                        $id = $this->parameters['id'];
                        if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                } else {
                        $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]);
                        if (!empty($contact['id'])) {
                                $id = $contact['id'];
                        } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
index 1582f3299c18d5a21cad7ccb23320a928c5f7af7..f6970336d5133e82b631b53fc6b9628f624cee4f 100644 (file)
@@ -38,7 +38,7 @@ class Block extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Contact\User::setBlocked($this->parameters['id'], $uid, true);
index 272b989ee4e50e070815bda3cad4349696b87e8e..0f565d580cfadf780096e398f84fbab760cd1feb 100644 (file)
@@ -37,7 +37,7 @@ class Follow extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $request = $this->getRequest([
index 19f2a438838041540f6c833854255f87d754502b..0ad6f9667cf2060dfd7fd34b42f528aac3b367f6 100644 (file)
@@ -41,12 +41,12 @@ class Followers extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $request = $this->getRequest([
index 061e22663d81ab01a81561c7fc68d83d9fdcb11c..bd88328603bf5221699d32bd6b6c1e5d0b63e747 100644 (file)
@@ -41,12 +41,12 @@ class Following extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $request = $this->getRequest([
index 8fdcade664213803406c123b7052d3d58bd43be1..750ebd6810c2642d096f89735d304e43cf30cd47 100644 (file)
@@ -41,12 +41,12 @@ class Lists extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $lists = [];
index ea8d0ce30954156565169c5fb6ccf82a310ddaf5..4602b18caa60e4be4b6772a40b9b8f530f734e37 100644 (file)
@@ -37,7 +37,7 @@ class Mute extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Contact\User::setIgnored($this->parameters['id'], $uid, true);
index 72a7e0838d35fb79025204b3e80419ce59920baf..9f360093199aa7b7d12873edf9c39afde9a2a4a7 100644 (file)
@@ -38,7 +38,7 @@ class Note extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $request = $this->getRequest([
@@ -47,7 +47,7 @@ class Note extends BaseApi
 
                $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
                if (empty($cdata['user'])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
index f757151724d419d294ec77e36b01404767673418..8c630d72390ced50a8ae0602488f376bc0cdaf01 100644 (file)
@@ -44,7 +44,7 @@ class Relationships extends BaseApi
                ], $request);
 
                if (empty($request['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!is_array($request['id'])) {
index fd8fbcdab1ccb00483d9adf39f669392f2d69a96..b4e09b613e7dcc02bfb88c46a7a618b578d41d74 100644 (file)
@@ -47,12 +47,12 @@ class Statuses extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $request = $this->getRequest([
index f2e2f2e411ba10ca74340daa5014144a1cd22bc3..0d44c52d1d31f72038292734a41b9657c49933fa 100644 (file)
@@ -37,7 +37,7 @@ class Unblock extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Contact\User::setBlocked($this->parameters['id'], $uid, false);
index 6a3c68cb3263c151c58cc946a45c7d57c10fda96..6a19267b3fe1ff9f4af3c3c6e0c9d12a19bed50d 100644 (file)
@@ -37,12 +37,12 @@ class Unfollow extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
                if (empty($cdata['user'])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $contact = Contact::getById($cdata['user']);
index 651233daed361b95c6f28d30af39342fc1039294..689398d10f9ad16ef749698ae6ac9b1702a5ed13 100644 (file)
@@ -37,7 +37,7 @@ class Unmute extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Contact\User::setIgnored($this->parameters['id'], $uid, false);
index 5ebe3e2aba84efe0ebc7e7255b645ee2226ab18d..012a2b1c27004e0ea8fd56eb278fae98ea3bcecb 100644 (file)
@@ -70,7 +70,7 @@ class Apps extends BaseApi
                }
 
                if (empty($request['client_name']) || empty($request['redirect_uris'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters')));
                }
 
                $client_id     = bin2hex(random_bytes(32));
@@ -92,7 +92,7 @@ class Apps extends BaseApi
                }
 
                if (!DBA::insert('application', $fields)) {
-                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
+                       $this->logAndJsonError(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray());
index 69d470306a41d1792c5a16548456c3306ac1068e..42e8111e77cd86557ff94f56d23be9feae686189 100644 (file)
@@ -36,7 +36,7 @@ class VerifyCredentials extends BaseApi
                $application = self::getCurrentApplication();
 
                if (empty($application['id'])) {
-                       $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized());
+                       $this->logAndJsonError(401, $this->errorFactory->Unauthorized());
                }
 
                $this->jsonExit(DI::mstdnApplication()->createFromApplicationId($application['id']));
index 532db4bcda95f0c2784b5c47cfc445c255193064..1814922c79840a6dff56e56df8af82135696c192 100644 (file)
@@ -38,7 +38,7 @@ class Conversations extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (!empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
@@ -90,7 +90,7 @@ class Conversations extends BaseApi
                                $conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']);
                        }
                } catch (NotFoundException $e) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                DBA::close($convs);
index 2e876fcb5d3abaf1c05c06ff8ff80af968ea9b02..b78fdf8eda07fd78653a261691f9efb12bf54f88 100644 (file)
@@ -38,7 +38,7 @@ class Read extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (!empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
@@ -46,7 +46,7 @@ class Read extends BaseApi
                try {
                        $this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray());
                } catch (NotFoundException $e) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
        }
 }
index 3e66b9d51e6aadd39c36fe2d3cc0e244b7867921..b9e52f159ddb14ef8146150d5fbbe70c8981fec9 100644 (file)
@@ -37,15 +37,15 @@ class Lists extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!Circle::exists($this->parameters['id'], $uid)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if (!Circle::remove($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
+                       $this->logAndJsonError(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit([]);
@@ -61,14 +61,14 @@ class Lists extends BaseApi
                ], $request);
 
                if (empty($request['title'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Circle::create($uid, $request['title']);
 
                $id = Circle::getIdByName($uid, $request['title']);
                if (!$id) {
-                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
+                       $this->logAndJsonError(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit(DI::mstdnList()->createFromCircleId($id));
@@ -82,7 +82,7 @@ class Lists extends BaseApi
                ], $request);
 
                if (empty($request['title']) || empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Circle::update($this->parameters['id'], $request['title']);
@@ -106,7 +106,7 @@ class Lists extends BaseApi
                        $id = $this->parameters['id'];
 
                        if (!Circle::exists($id, $uid)) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                        $lists = DI::mstdnList()->createFromCircleId($id);
                }
index f72f8cad82ebf7f73c646d9cfd630df1387e8321..4db6846a27943fd379afe4f5dfdfa7a35e06fa7f 100644 (file)
@@ -43,7 +43,7 @@ class Accounts extends BaseApi
                ], $request);
 
                if (empty($request['account_ids']) || empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                return Circle::removeMembers($this->parameters['id'], $request['account_ids']);
@@ -58,7 +58,7 @@ class Accounts extends BaseApi
                ], $request);
 
                if (empty($request['account_ids']) || empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Circle::addMembers($this->parameters['id'], $request['account_ids']);
@@ -73,12 +73,12 @@ class Accounts extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $request = $this->getRequest([
index 25b56d72ea0a5e6d6c6857447db26858f96d238a..4bd714c1173ce303d8f45c798d7feb3bf1ed7c12 100644 (file)
@@ -48,7 +48,7 @@ class Markers extends BaseApi
                }
 
                if (empty($timeline) || empty($last_read_id) || empty($application['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline];
index 738feab7c8fa011ac4c6256d714cda0547799598..1da6b3006b7095fd6acfdc8a8858fca29c1ac359 100644 (file)
@@ -48,12 +48,12 @@ class Media extends BaseApi
                Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]);
 
                if (empty($_FILES['file'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $media = Photo::upload($uid, $_FILES['file'], '', null, null, '', '', $request['description']);
                if (empty($media)) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                Logger::info('Uploaded photo', ['media' => $media]);
@@ -74,17 +74,17 @@ class Media extends BaseApi
                ], $request);
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]);
                if (empty($photo['resource-id'])) {
                        $media = Post\Media::getById($this->parameters['id']);
                        if (empty($media['uri-id'])) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                        if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                        Post\Media::updateById(['description' => $request['description']], $this->parameters['id']);
                        $this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id']));
@@ -104,12 +104,12 @@ class Media extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $this->jsonExit(DI::mstdnAttachment()->createFromPhoto($id));
index 6557b770b8470e87c10e1d309d522398ed445b35..b87da7f7b1036f564e8608579370f643ab7bc196 100644 (file)
@@ -40,12 +40,12 @@ class Mutes extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
                if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $request = $this->getRequest([
index 6045d246534eff6c94aec1c066ff56f7eece0ba7..b359113dc4eafcab441ad96de2f00a00fe2db5a2 100644 (file)
@@ -50,7 +50,7 @@ class Notifications extends BaseApi
                                $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
                                $this->jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes()));
                        } catch (\Exception $e) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
index cc8947972684548570b7c5d2d0282547cfc07dea..9771f1df6fd0aefbffee77f79eeecad8f2a9b7e6 100644 (file)
@@ -38,7 +38,7 @@ class Dismiss extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $condition = ['id' => $this->parameters['id']];
index a5e4fb33a1f721e40881c1cb087773fe47038d6c..51d46c45ba1d9b2c4eb3ea79b65f9b0064558bc6 100644 (file)
@@ -39,7 +39,7 @@ class Polls extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid));
index b91f8e7ba3db572574adc7d6c541c77327b5e009..5624a1de49c3bcc3c37b56c90ff40598f867b84e 100644 (file)
@@ -94,7 +94,7 @@ class PushSubscription extends BaseApi
                $subscription = Subscription::select($application['id'], $uid, ['id']);
                if (empty($subscription)) {
                        $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]);
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $fields = [
@@ -145,7 +145,7 @@ class PushSubscription extends BaseApi
 
                if (!Subscription::exists($application['id'], $uid)) {
                        $this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]);
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]);
index cedafb8ab7f2a9689db7adaa3632d081fbbaccea..18b5c31c41aa84fe1d1d95ea4c4fa0e2387f3ead 100644 (file)
@@ -47,11 +47,11 @@ class ScheduledStatuses extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Post\Delayed::deleteById($this->parameters['id']);
index fb222beff27e63c9aabc01950fed5aae31ac496b..75dc05e244bab455c1da4d540d25347ccf39e939 100644 (file)
@@ -60,7 +60,7 @@ class Search extends BaseApi
                ], $request);
 
                if (empty($request['q'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $limit = min($request['limit'], 40);
index 5b6f8550aa54b181172d7d168bd4af375785d575..dfd81c9d455c701066f69291891d18913ed71fcd 100644 (file)
@@ -297,7 +297,7 @@ class Statuses extends BaseApi
                        $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->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
+                               $this->logAndJsonError(500, $this->errorFactory->InternalError());
                        }
                        $this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray());
                }
@@ -310,7 +310,7 @@ class Statuses extends BaseApi
                        }
                }
 
-               $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
+               $this->logAndJsonError(500, $this->errorFactory->InternalError());
        }
 
        protected function delete(array $request = [])
@@ -319,16 +319,16 @@ class Statuses extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]);
                if (empty($item['id'])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if (!Item::markForDeletionById($item['id'])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $this->jsonExit([]);
@@ -342,7 +342,7 @@ class Statuses extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false));
index cdbdcb6e6baf8761997d443ecf40568c54b6baa7..35ebf28d73b9ac198d19a5ee293ce75dfbf59d49 100644 (file)
@@ -39,16 +39,16 @@ class Bookmark extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['gravity'] != Item::GRAVITY_PARENT) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked')));
                }
 
                if ($item['uid'] == 0) {
@@ -56,10 +56,10 @@ class Bookmark extends BaseApi
                        if (!empty($stored)) {
                                $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
                                if (!DBA::isResult($item)) {
-                                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                                }
                        } else {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
index ea5705186cec1acc9d4856293da1a20fbc40df92..ef38f66a8273825bba4e8b46579fb708ef16eff2 100644 (file)
@@ -40,7 +40,7 @@ class Card extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
index dbce15058cad1f1f415a6788c79bea51650d2ba5..6e35d717bf741d09bec7f51937beea1b1ff8edaa 100644 (file)
@@ -41,7 +41,7 @@ class Context extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $request = $this->getRequest([
@@ -116,7 +116,7 @@ class Context extends BaseApi
                                }
                                DBA::close($posts);
                        } else {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
index 103de86790da90af046c828cdf29414cda536971..04e4c6256c4d679147019e143d1fbcf1e1e6b09c 100644 (file)
@@ -39,12 +39,12 @@ class Favourite extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Item::performActivity($item['id'], 'like', $uid);
index d91eff0b803e1fb592eb724f9ce6743573d939f4..96c86dfb1a3dbaab8cc8b0b47ac5a67f1caf758f 100644 (file)
@@ -41,11 +41,11 @@ class FavouritedBy extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]);
index 0931cd733d8f4dd70b3d267b98e6725fb5e5f74e..fc6b642b4856321bdf578761bb9dd2668329f454 100644 (file)
@@ -39,16 +39,16 @@ class Mute extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['gravity'] != Item::GRAVITY_PARENT) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted')));
                }
 
                Post\ThreadUser::setIgnored($item['uri-id'], $uid, true);
index fbd2f00ceefa51fcb584017bce955e6700747764..b5c8f5c6e00f36165540c18db8d01fcdb562ac7f 100644 (file)
@@ -38,12 +38,12 @@ class Pin extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid);
index 54ada1d1f91b89387a2a7034c9140ce646f7b97c..cf35286b2cfae5fdd5113aa9ac146dec3986ef95 100644 (file)
@@ -42,18 +42,18 @@ class Reblog extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['network'] == Protocol::DIASPORA) {
                        Diaspora::performReshare($this->parameters['id'], $uid);
                } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) {
-                       $this->logErrorAndJsonExit(
+                       $this->logAndJsonError(
                                422,
                                $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network'])))
                        );
index eab40c665e20ac4a572948e4cf35680da60ae629..0c8376fd079efafa26f9aba82b14339ba5e7cadf 100644 (file)
@@ -41,11 +41,11 @@ class RebloggedBy extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
index 1e72f33a02516a6a8ee5284198d32ed9ffe734df..8810058d62ed6f8095793cd2ca77a1229901e089 100644 (file)
@@ -41,7 +41,7 @@ class Source extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $id = $this->parameters['id'];
index c64a6c8a775dc18474898e552df438d4354696ee..594cde4223f90411fb07f17cfef4a35d8eddd2b2 100644 (file)
@@ -39,16 +39,16 @@ class Unbookmark extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['gravity'] != Item::GRAVITY_PARENT) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked')));
                }
 
                if ($item['uid'] == 0) {
@@ -56,10 +56,10 @@ class Unbookmark extends BaseApi
                        if (!empty($stored)) {
                                $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
                                if (!DBA::isResult($item)) {
-                                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                                }
                        } else {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
index 78e9fb350f2e90aa75d84a2f752d752f0ffe13b5..631e18dda7c33152579d127bc3e36b1a33ffbf0c 100644 (file)
@@ -39,12 +39,12 @@ class Unfavourite extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Item::performActivity($item['id'], 'unlike', $uid);
index e54380dbe59754a2f51967daa907534b72c688fd..9fb05e8f6928a5292d1f8dc57bc10111fc636b97 100644 (file)
@@ -39,16 +39,16 @@ class Unmute extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['gravity'] != Item::GRAVITY_PARENT) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted')));
                }
 
                Post\ThreadUser::setIgnored($item['uri-id'], $uid, false);
index f04ff5306e1ac9e29792fa360fb44f9859c7f6ca..626e18d75c459167dee73aa9b2d0a8168a6a3640 100644 (file)
@@ -38,12 +38,12 @@ class Unpin extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid);
index 50931cecd7bf8ac7cca038ee0821be7f001636a6..2036bb1fb11a00480a1fd6cf573ba0f5ad59361d 100644 (file)
@@ -41,25 +41,25 @@ class Unreblog extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if ($item['network'] == Protocol::DIASPORA) {
                        $item = Post::selectFirstForUser($uid, ['id'], ['quote-uri-id' => $this->parameters['id'], 'body' => '', 'origin' => true, 'uid' => $uid]);
                        if (empty($item['id'])) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
 
                        if (!Item::markForDeletionById($item['id'])) {
-                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                               $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                        }
                } elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) {
-                       $this->logErrorAndJsonExit(
+                       $this->logAndJsonError(
                                422,
                                $this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network'])))
                        );
index d61ee88acf9c1b917ca038a2e0965150ce8ed8aa..00cbac0d918ce3547844f0db5aaf33143754cb47 100644 (file)
@@ -40,7 +40,7 @@ class Tags extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['hashtag'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $tag       = ltrim($this->parameters['hashtag'], '#');
index 03844a7ddccb9e751e2c0e2e31a1244c73807ee3..0fe6307ebcb1bf79bb796120cf6e277777d6b303 100644 (file)
@@ -37,7 +37,7 @@ class Follow extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['hashtag'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $fields = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')];
index 07b93d95a2dedc8c2cf3a4feb752f5445f556235..31e2ade4ea74a57b6cd70ae015bfac779dc2afb1 100644 (file)
@@ -37,7 +37,7 @@ class Unfollow extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['hashtag'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $term = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')];
index 730b639104b4cb9bf9cbbc143bbe57e5d3981a37..356a4fa94928a0965be023e294fb35449a34c61c 100644 (file)
@@ -83,7 +83,7 @@ class Direct extends BaseApi
                                $statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']);
                        }
                } catch (NotFoundException $e) {
-                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
+                       $this->logAndJsonError(404, $this->errorFactory->RecordNotFound());
                }
 
                if (!empty($request['min_id'])) {
index baed01e0ec5de318b5014928bb04274032bc03ce..4331fc321cfa2bda5f89217ab9b8938369227311 100644 (file)
@@ -45,7 +45,7 @@ class ListTimeline extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                $request = $this->getRequest([
index 60bdab837349b6934b32e28d18a877b91cbface3..e08453327c6039f8d8f88d9df58150e1759c0db4 100644 (file)
@@ -45,7 +45,7 @@ class Tag extends BaseApi
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['hashtag'])) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                /**
index b2d729f286d5c84e786c5c82b0219d18596b6f5d..7d21d7a8d48c927a1b725e9d61a067cedcf7c198 100644 (file)
@@ -424,17 +424,17 @@ class BaseApi extends BaseModule
 
                if (empty($token)) {
                        $this->logger->notice('Empty application token');
-                       $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden());
+                       $this->logAndJsonError(403, $this->errorFactory->Forbidden());
                }
 
                if (!isset($token[$scope])) {
                        $this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]);
-                       $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden());
+                       $this->logAndJsonError(403, $this->errorFactory->Forbidden());
                }
 
                if (empty($token[$scope])) {
                        $this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]);
-                       $this->logErrorAndJsonExit(403, $this->errorFactory->Forbidden());
+                       $this->logAndJsonError(403, $this->errorFactory->Forbidden());
                }
        }
 
@@ -526,7 +526,7 @@ class BaseApi extends BaseModule
         * @return void
         * @throws HTTPException\InternalServerErrorException
         */
-       protected function logErrorAndJsonExit(int $errorno, Error $error)
+       protected function logAndJsonError(int $errorno, Error $error)
        {
                $this->logger->info('API Error', ['no' => $errorno, 'error' => $error->toArray(), 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
                $this->jsonError(403, $error->toArray());
index e9ef07c62fbc0ceff41927ad09c6a1a7e2c6658c..31db02b01713958737ea2e2183699a23bf99ce30 100644 (file)
@@ -51,17 +51,17 @@ class Authorize extends BaseApi
 
                if ($request['response_type'] != 'code') {
                        Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type')));
                }
 
                if (empty($request['client_id']) || empty($request['redirect_uri'])) {
                        Logger::warning('Incomplete request data', ['request' => $_REQUEST]);
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
                }
 
                $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
                if (empty($application)) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                // @todo Compare the application scope and requested scope
@@ -87,7 +87,7 @@ class Authorize extends BaseApi
 
                $token = OAuth::createTokenForUser($application, $uid, $request['scope']);
                if (!$token) {
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') {
index 979114434827dbe8c34765be3c51cc143f5a510c..a20482b22160bf4eb60ef0c70bd94688e32e1b3a 100644 (file)
@@ -51,7 +51,7 @@ class Revoke extends BaseApi
                $token = DBA::selectFirst('application-view', ['id'], $condition);
                if (empty($token['id'])) {
                        $this->logger->notice('Token not found', $condition);
-                       $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized());
+                       $this->logAndJsonError(401, $this->errorFactory->Unauthorized());
                }
 
                DBA::delete('application-token', ['application-id' => $token['id']]);
index 0186f285196affa54a41d8acc39faa2f108ac19b..7e22a88dabff6c588533c7a504d2309caa71e96e 100644 (file)
@@ -75,12 +75,12 @@ class Token extends BaseApi
 
                if (empty($request['client_id']) || empty($request['client_secret'])) {
                        $this->logger->warning('Incomplete request data', ['request' => $request]);
-                       $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));;
+                       $this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));;
                }
 
                $application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
                if (empty($application)) {
-                       $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client')));
+                       $this->logAndJsonError(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client')));
                }
 
                if ($request['grant_type'] == 'client_credentials') {
@@ -99,13 +99,13 @@ class Token extends BaseApi
                        $token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition);
                        if (!DBA::isResult($token)) {
                                $this->logger->notice('Token not found or outdated', $condition);
-                               $this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized());
+                               $this->logAndJsonError(401, $this->errorFactory->Unauthorized());
                        }
                        $owner = User::getOwnerDataById($token['uid']);
                        $me = $owner['url'];
                } else {
                        Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
-                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
+                       $this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
                }
 
                $object = new \Friendica\Object\Api\Mastodon\Token($token['access_token'], 'Bearer', $application['scopes'], $token['created_at'], $me);