Make BaseApi->checkAllowedScope into an object method

- It isn't called from static contexts anymore
This commit is contained in:
Hypolite Petovan 2023-10-11 09:30:42 -04:00
parent f70a64891c
commit 9e71610711
131 changed files with 152 additions and 152 deletions

View file

@ -34,7 +34,7 @@ class UpdateProfile extends BaseApi
{
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();

View file

@ -35,7 +35,7 @@ class UpdateProfileImage extends BaseApi
{
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
// get mediadata from image or media (Twitter call api/account/update_profile_image provides image)

View file

@ -34,7 +34,7 @@ class VerifyCredentials extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$skip_status = $this->getRequestValue($request, 'skip_status', false);

View file

@ -33,7 +33,7 @@ class Ids extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -33,7 +33,7 @@ class Lists extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -42,7 +42,7 @@ abstract class ContactEndpoint extends BaseApi
{
parent::__construct($errorFactory, $app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
}
/**

View file

@ -31,7 +31,7 @@ class All extends DirectMessagesEndpoint
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$this->getMessages($request, $uid, []);

View file

@ -31,7 +31,7 @@ class Conversation extends DirectMessagesEndpoint
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$this->getMessages($request, $uid, ["`parent-uri` = ?", $this->getRequestValue($request, 'uri', '')]);

View file

@ -49,7 +49,7 @@ class Destroy extends BaseApi
}
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -34,7 +34,7 @@ class Inbox extends DirectMessagesEndpoint
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$pcid = Contact::getPublicIdByUserId($uid);

View file

@ -56,7 +56,7 @@ class NewDM extends BaseApi
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
if (empty($request['text']) || empty($request['screen_name']) && empty($request['user_id'])) {

View file

@ -34,7 +34,7 @@ class Sent extends DirectMessagesEndpoint
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$pcid = Contact::getPublicIdByUserId($uid);

View file

@ -38,7 +38,7 @@ class Favorites extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// in friendica starred item are private

View file

@ -34,7 +34,7 @@ class Create extends BaseApi
{
protected function post(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$this->checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -34,7 +34,7 @@ class Destroy extends BaseApi
{
protected function post(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$this->checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -34,7 +34,7 @@ class Ids extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -33,7 +33,7 @@ class Lists extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -34,7 +34,7 @@ class Ids extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -33,7 +33,7 @@ class Lists extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -54,7 +54,7 @@ class Destroy extends ContactEndpoint
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
$owner = User::getOwnerDataById($uid);

View file

@ -32,7 +32,7 @@ class Incoming extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id

View file

@ -35,7 +35,7 @@ class Show extends ContactEndpoint
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$source_cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'source_screen_name', ''), '', $this->getRequestValue($request, 'source_id', 0), $uid);

View file

@ -56,7 +56,7 @@ class Create extends BaseApi
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
// params

View file

@ -56,7 +56,7 @@ class Destroy extends BaseApi
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
// params

View file

@ -33,7 +33,7 @@ class Lists extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// This is a dummy endpoint

View file

@ -53,7 +53,7 @@ class Ownership extends BaseApi
}
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$circles = $this->dba->select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null]);

View file

@ -58,7 +58,7 @@ class Statuses extends BaseApi
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
if (empty($request['list_id'])) {

View file

@ -56,7 +56,7 @@ class Update extends BaseApi
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
// params

View file

@ -36,7 +36,7 @@ class Create extends BaseApi
{
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
$postdata = Network::postdata();

View file

@ -37,7 +37,7 @@ class Upload extends BaseApi
{
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
$this->checkAllowedScope(BaseApi::SCOPE_WRITE);
$uid = BaseApi::getCurrentUserID();
if (empty($_FILES['media'])) {

View file

@ -32,7 +32,7 @@ class SavedSearches extends BaseApi
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_READ);
$this->checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
$terms = DBA::select('search', ['id', 'term'], ['uid' => $uid]);

View file

@ -38,7 +38,7 @@ class Tweets extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
if (empty($request['q'])) {

View file

@ -37,7 +37,7 @@ class Destroy extends BaseApi
{
protected function post(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -37,7 +37,7 @@ class HomeTimeline extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// get last network messages

View file

@ -37,7 +37,7 @@ class Mentions extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// get last network messages

View file

@ -35,7 +35,7 @@ class NetworkPublicTimeline extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$count = $this->getRequestValue($request, 'count', 20, 1, 100);

View file

@ -35,7 +35,7 @@ class PublicTimeline extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
// get last network messages

View file

@ -41,7 +41,7 @@ class Retweet extends BaseApi
{
protected function post(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$this->checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -39,7 +39,7 @@ class Show extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$id = $this->getRequestValue($request, 'id', 0);

View file

@ -46,7 +46,7 @@ class Update extends BaseApi
{
public function post(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$this->checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
$owner = User::getOwnerDataById($uid);

View file

@ -38,7 +38,7 @@ class UserTimeline extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);

View file

@ -34,7 +34,7 @@ class Lookup extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$users = [];

View file

@ -37,7 +37,7 @@ class Search extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
$userlist = [];

View file

@ -34,7 +34,7 @@ class Show extends BaseApi
{
protected function rawContent(array $request = [])
{
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$this->checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID();
if (empty($this->parameters['id'])) {