Replace Logger with $this->logger in Module Twitter classes

This commit is contained in:
Art4 2025-01-13 11:55:30 +00:00
parent b0a5494a8f
commit d4873dbc6b
6 changed files with 9 additions and 16 deletions

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Api\Twitter;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Module\BaseApi;
@ -29,7 +28,7 @@ class Favorites extends BaseApi
// in friendica starred item are private
// return favorites only for self
Logger::info(BaseApi::LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
$this->logger->info(BaseApi::LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
// params
$count = $this->getRequestValue($request, 'count', 20, 1, 100);

View file

@ -12,7 +12,6 @@ use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\AppHelper;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Factory\Api\Twitter\User as TwitterUser;
use Friendica\Model\Contact;
use Friendica\Model\User;
@ -47,21 +46,21 @@ class Destroy extends ContactEndpoint
$owner = User::getOwnerDataById($uid);
if (!$owner) {
Logger::notice(BaseApi::LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
$this->logger->notice(BaseApi::LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
throw new HTTPException\NotFoundException('Error Processing Request');
}
$contact_id = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), 0);
if (empty($contact_id)) {
Logger::notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
$this->logger->notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
throw new HTTPException\BadRequestException('no user_id specified');
}
// Get Contact by given id
$ucid = Contact::getUserContactId($contact_id, $uid);
if (!$ucid) {
Logger::notice(BaseApi::LOG_PREFIX . 'Not following contact', ['module' => 'api', 'action' => 'friendships_destroy']);
$this->logger->notice(BaseApi::LOG_PREFIX . 'Not following contact', ['module' => 'api', 'action' => 'friendships_destroy']);
throw new HTTPException\NotFoundException('Not following Contact');
}
@ -71,7 +70,7 @@ class Destroy extends ContactEndpoint
try {
Contact::unfollow($contact);
} catch (Exception $e) {
Logger::error(BaseApi::LOG_PREFIX . $e->getMessage(), ['contact' => $contact]);
$this->logger->error(BaseApi::LOG_PREFIX . $e->getMessage(), ['contact' => $contact]);
throw new HTTPException\InternalServerErrorException('Unable to unfollow this contact, please contact your administrator');
}

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Api\Twitter\Media\Metadata;
use Friendica\Core\Logger;
use Friendica\Model\Photo;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException\BadRequestException;
@ -44,7 +43,7 @@ class Create extends BaseApi
throw new BadRequestException('No alt text.');
}
Logger::info('Updating metadata', ['media_id' => $data['media_id']]);
$this->logger->info('Updating metadata', ['media_id' => $data['media_id']]);
$condition = ['id' => $data['media_id'], 'uid' => $uid];

View file

@ -7,8 +7,6 @@
namespace Friendica\Module\Api\Twitter\Media;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException\BadRequestException;
@ -49,7 +47,7 @@ class Upload extends BaseApi
"friendica_preview_url" => $media["preview"]
];
Logger::info('Media uploaded', ['return' => $returndata]);
$this->logger->info('Media uploaded', ['return' => $returndata]);
$this->response->addFormattedContent('media', ['media' => $returndata], $this->parameters['extension'] ?? null);
}

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Module\BaseApi;
use Friendica\DI;
@ -34,7 +33,7 @@ class Show extends BaseApi
throw new BadRequestException('An id is missing.');
}
Logger::notice('API: api_statuses_show: ' . $id);
$this->logger->notice('API: api_statuses_show: ' . $id);
$conversation = !empty($request['conversation']);

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Api\Twitter\Statuses;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -27,7 +26,7 @@ class UserTimeline extends BaseApi
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
$this->logger->info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
$cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
$count = $this->getRequestValue($request, 'count', 20, 1, 100);