Switch static::$parameters to $this->parameters

This commit is contained in:
Philipp 2021-11-14 23:19:25 +01:00
parent 489cd0884a
commit 5879535822
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
116 changed files with 321 additions and 314 deletions

View file

@ -39,20 +39,20 @@ class Accounts extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id']) && empty(static::$parameters['name'])) {
if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!empty(static::$parameters['id'])) {
$id = static::$parameters['id'];
if (!empty($this->parameters['id'])) {
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
} else {
$contact = Contact::selectFirst(['id'], ['nick' => static::$parameters['name'], 'uid' => 0]);
$contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]);
if (!empty($contact['id'])) {
$id = $contact['id'];
} elseif (!($id = Contact::getIdForURL(static::$parameters['name'], 0, false))) {
} elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
DI::mstdnError()->RecordNotFound();
}
}

View file

@ -37,7 +37,7 @@ class Block extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -46,7 +46,7 @@ class Block extends BaseApi
DI::mstdnError()->Forbidden();
}
$cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid);
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
if (empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound();
}
@ -62,6 +62,6 @@ class Block extends BaseApi
Contact::terminateFriendship($owner, $contact);
Contact::revokeFollow($contact);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -36,11 +36,11 @@ class Follow extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$cid = Contact::follow(static::$parameters['id'], $uid);
$cid = Contact::follow($this->parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
}

View file

@ -39,11 +39,11 @@ class Followers extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -72,7 +72,7 @@ class Followers extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, static::$parameters);
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $this->parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['relation-cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid);

View file

@ -39,11 +39,11 @@ class Following extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -72,7 +72,7 @@ class Following extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['cid'], $condition, static::$parameters);
$followers = DBA::select('contact-relation', ['cid'], $condition, $this->parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -40,11 +40,11 @@ class Lists extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -36,12 +36,12 @@ class Mute extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored(static::$parameters['id'], $uid, true);
Contact\User::setIgnored($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -37,7 +37,7 @@ class Note extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -45,13 +45,13 @@ class Note extends BaseApi
'comment' => '',
]);
$cdata = Contact::getPublicAndUserContactID(static::$parameters['id'], $uid);
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
if (empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound();
}
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -43,11 +43,11 @@ class Statuses extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -36,12 +36,12 @@ class Unblock extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setBlocked(static::$parameters['id'], $uid, false);
Contact\User::setBlocked($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -36,12 +36,12 @@ class Unfollow extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact::unfollow(static::$parameters['id'], $uid);
Contact::unfollow($this->parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -36,12 +36,12 @@ class Unmute extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored(static::$parameters['id'], $uid, false);
Contact\User::setIgnored($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -39,11 +39,11 @@ class Blocks extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -72,7 +72,7 @@ class Blocks extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters);
$followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -36,12 +36,12 @@ class Conversations extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty(static::$parameters['id'])) {
if (!empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::delete('conv', ['id' => static::$parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => static::$parameters['id'], 'uid' => $uid]);
DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]);
System::jsonExit([]);
}

View file

@ -36,12 +36,12 @@ class Read extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty(static::$parameters['id'])) {
if (!empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::update('mail', ['seen' => true], ['convid' => static::$parameters['id'], 'uid' => $uid]);
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
System::jsonExit(DI::mstdnConversation()->CreateFromConvId(static::$parameters['id'])->toArray());
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($this->parameters['id'])->toArray());
}
}

View file

@ -47,11 +47,11 @@ class FollowRequests extends BaseApi
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
$introduction = DI::intro()->selectOneById(static::$parameters['id'], $uid);
$introduction = DI::intro()->selectOneById($this->parameters['id'], $uid);
$contactId = $introduction->cid;
switch (static::$parameters['action']) {
switch ($this->parameters['action']) {
case 'authorize':
Contact\Introduction::confirm($introduction);
$relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid);

View file

@ -36,15 +36,15 @@ class Lists extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!Group::exists(static::$parameters['id'], $uid)) {
if (!Group::exists($this->parameters['id'], $uid)) {
DI::mstdnError()->RecordNotFound();
}
if (!Group::remove(static::$parameters['id'])) {
if (!Group::remove($this->parameters['id'])) {
DI::mstdnError()->InternalError();
}
@ -81,11 +81,11 @@ class Lists extends BaseApi
'replies_policy' => '', // One of: "followed", "list", or "none".
]);
if (empty($request['title']) || empty(static::$parameters['id'])) {
if (empty($request['title']) || empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Group::update(static::$parameters['id'], $request['title']);
Group::update($this->parameters['id'], $request['title']);
}
/**
@ -96,7 +96,7 @@ class Lists extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
$lists = [];
$groups = Group::getByUserId($uid);
@ -105,7 +105,7 @@ class Lists extends BaseApi
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
}
} else {
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!Group::exists($id, $uid)) {
DI::mstdnError()->RecordNotFound();

View file

@ -53,11 +53,11 @@ class Accounts extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -65,18 +65,18 @@ class Media extends BaseApi
'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0
]);
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$photo = Photo::selectFirst(['resource-id'], ['id' => static::$parameters['id'], 'uid' => $uid]);
$photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]);
if (empty($photo['resource-id'])) {
DI::mstdnError()->RecordNotFound();
}
Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]);
System::jsonExit(DI::mstdnAttachment()->createFromPhoto(static::$parameters['id']));
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id']));
}
/**
@ -87,11 +87,11 @@ class Media extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -39,11 +39,11 @@ class Mutes extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -72,7 +72,7 @@ class Mutes extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, static::$parameters);
$followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters);
while ($follower = DBA::fetch($followers)) {
self::setBoundaries($follower['cid']);
$accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid);

View file

@ -45,8 +45,8 @@ class Notifications extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (!empty(static::$parameters['id'])) {
$id = static::$parameters['id'];
if (!empty($this->parameters['id'])) {
$id = $this->parameters['id'];
try {
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
System::jsonExit(DI::mstdnNotification()->createFromNotification($notification));

View file

@ -37,11 +37,11 @@ class Dismiss extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$Notification = DI::notification()->selectOneForUser($uid, static::$parameters['id']);
$Notification = DI::notification()->selectOneForUser($uid, $this->parameters['id']);
$Notification->setSeen();
DI::notification()->save($Notification);

View file

@ -47,15 +47,15 @@ class ScheduledStatuses extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!DBA::exists('delayed-post', ['id' => static::$parameters['id'], 'uid' => $uid])) {
if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}
Post\Delayed::deleteById(static::$parameters['id']);
Post\Delayed::deleteById($this->parameters['id']);
System::jsonExit([]);
}
@ -68,8 +68,8 @@ class ScheduledStatuses extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (isset(static::$parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId(static::$parameters['id'], $uid)->toArray());
if (isset($this->parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray());
}
$request = self::getRequest([

View file

@ -73,7 +73,7 @@ class Search extends BaseApi
$result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
}
if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) {
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], static::$parameters['version']);
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
}
System::jsonExit($result);

View file

@ -212,11 +212,11 @@ class Statuses extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => $uid]);
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]);
if (empty($item['id'])) {
DI::mstdnError()->RecordNotFound();
}
@ -235,10 +235,10 @@ class Statuses extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid));
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid));
}
}

View file

@ -38,11 +38,11 @@ class Bookmark extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -53,6 +53,6 @@ class Bookmark extends BaseApi
Item::update(['starred' => true], ['id' => $item['id']]);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -39,11 +39,11 @@ class Card extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $id . ' not found' . ($uid ? ' for user ' . $uid : '.'));

View file

@ -39,7 +39,7 @@ class Context extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -47,7 +47,7 @@ class Context extends BaseApi
'limit' => 40, // Maximum number of results to return. Defaults to 40.
]);
$id = static::$parameters['id'];
$id = $this->parameters['id'];
$parents = [];
$children = [];

View file

@ -38,17 +38,17 @@ class Favourite extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
Item::performActivity($item['id'], 'like', $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -39,11 +39,11 @@ class FavouritedBy extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -37,11 +37,11 @@ class Mute extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -50,8 +50,8 @@ class Mute extends BaseApi
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
}
Post\ThreadUser::setIgnored(static::$parameters['id'], $uid, true);
Post\ThreadUser::setIgnored($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -37,11 +37,11 @@ class Pin extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -50,8 +50,8 @@ class Pin extends BaseApi
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
}
Post\ThreadUser::setPinned(static::$parameters['id'], $uid, true);
Post\ThreadUser::setPinned($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -40,11 +40,11 @@ class Reblog extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -55,6 +55,6 @@ class Reblog extends BaseApi
Item::performActivity($item['id'], 'announce', $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -39,11 +39,11 @@ class RebloggedBy extends BaseApi
{
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = static::$parameters['id'];
$id = $this->parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -38,11 +38,11 @@ class Unbookmark extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -53,6 +53,6 @@ class Unbookmark extends BaseApi
Item::update(['starred' => false], ['id' => $item['id']]);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -38,17 +38,17 @@ class Unfavourite extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
Item::performActivity($item['id'], 'unlike', $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -37,11 +37,11 @@ class Unmute extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -50,8 +50,8 @@ class Unmute extends BaseApi
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
}
Post\ThreadUser::setIgnored(static::$parameters['id'], $uid, false);
Post\ThreadUser::setIgnored($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -37,11 +37,11 @@ class Unpin extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -50,8 +50,8 @@ class Unpin extends BaseApi
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned'));
}
Post\ThreadUser::setPinned(static::$parameters['id'], $uid, false);
Post\ThreadUser::setPinned($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -40,11 +40,11 @@ class Unreblog extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => static::$parameters['id'], 'uid' => [$uid, 0]]);
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound();
}
@ -55,6 +55,6 @@ class Unreblog extends BaseApi
Item::performActivity($item['id'], 'unannounce', $uid);
System::jsonExit(DI::mstdnStatus()->createFromUriId(static::$parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -41,7 +41,7 @@ class ListTimeline extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -60,7 +60,7 @@ class ListTimeline extends BaseApi
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)",
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, static::$parameters['id']];
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $this->parameters['id']];
if (!empty($request['max_id'])) {
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);

View file

@ -42,7 +42,7 @@ class Tag extends BaseApi
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty(static::$parameters['hashtag'])) {
if (empty($this->parameters['hashtag'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -69,7 +69,7 @@ class Tag extends BaseApi
$condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`))
AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))",
static::$parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0];
$this->parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0];
if ($request['local']) {
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);