Merge remote-tracking branch 'upstream/develop' into api4

This commit is contained in:
Michael 2021-11-18 20:15:57 +00:00
commit b67c10812a
272 changed files with 989 additions and 963 deletions

View file

@ -40,7 +40,7 @@ use Friendica\Module\BaseApi;
*/
class Activity extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -49,17 +49,17 @@ class Activity extends BaseApi
'id' => 0, // Id of the post
]);
$res = Item::performActivity($request['id'], $parameters['verb'], $uid);
$res = Item::performActivity($request['id'], $this->parameters['verb'], $uid);
if ($res) {
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
$ok = 'true';
} else {
$ok = 'ok';
}
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
} else {
DI::apiResponse()->error(500, 'Error adding activity', '', $parameters['extension'] ?? null);
DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null);
}
}
}

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class Setseen extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -42,13 +42,13 @@ class Setseen extends BaseApi
// return error if id is zero
if (empty($request['id'])) {
$answer = ['result' => 'error', 'message' => 'message id not specified'];
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
}
// error message if specified id is not in database
if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
}
// update seen indicator
@ -58,6 +58,6 @@ class Setseen extends BaseApi
$answer = ['result' => 'error', 'message' => 'unknown error'];
}
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null);
}
}

View file

@ -33,7 +33,7 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -70,6 +70,6 @@ class Index extends BaseApi
];
}
DI::apiResponse()->exit('events', ['events' => $items], $parameters['extension'] ?? null);
DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null);
}
}

View file

@ -22,6 +22,7 @@
namespace Friendica\Module\Api\Friendica\Group;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Group;
use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException\BadRequestException;
@ -31,7 +32,7 @@ use Friendica\Network\HTTPException\BadRequestException;
*/
class Delete extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -69,7 +70,7 @@ class Delete extends BaseApi
if ($ret) {
// return success
$success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []];
self::exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
DI::apiResponse()->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null);
} else {
throw new BadRequestException('other API error');
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Index extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
}
public static function rawContent(array $parameters = [])
public function rawContent()
{
echo api_call(DI::app());
exit();

View file

@ -31,7 +31,7 @@ use Friendica\Object\Api\Friendica\Notification as ApiNotification;
*/
class Notification extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -43,7 +43,7 @@ class Notification extends BaseApi
$notifications[] = new ApiNotification($Notify);
}
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
$xmlnotes = [];
foreach ($notifications as $notification) {
$xmlnotes[] = ['@attributes' => $notification->toArray()];
@ -56,6 +56,6 @@ class Notification extends BaseApi
$result = false;
}
DI::apiResponse()->exit('notes', ['note' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null);
}
}

View file

@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -64,7 +64,7 @@ class Delete extends BaseApi
Item::deleteForUser($condition, $uid);
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error on deleting photo from database table");
}

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Delete extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -67,7 +67,7 @@ class Delete extends BaseApi
// return success of deletion or error message
if ($result) {
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.'];
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error - deleting from database failed");
}

View file

@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
*/
class Update extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -59,7 +59,7 @@ class Update extends BaseApi
// return success of updating or error message
if ($result) {
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.'];
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $parameters['extension'] ?? null);
DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error - updating in database failed");
}

View file

@ -33,7 +33,7 @@ use Friendica\Network\HTTPException;
*/
class Show extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -48,7 +48,7 @@ class Show extends BaseApi
$profile = self::formatProfile($profile, $profileFields);
$profiles = [];
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
$profiles['0:profile'] = $profile;
} else {
$profiles[] = $profile;
@ -61,7 +61,7 @@ class Show extends BaseApi
'profiles' => $profiles
];
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null);
}
/**

View file

@ -31,7 +31,7 @@ use Friendica\Module\Register;
*/
class Config extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
$config = [
'site' => [
@ -61,6 +61,6 @@ class Config extends BaseApi
],
];
self::exit('config', ['config' => $config], $parameters['extension'] ?? null);
DI::apiResponse()->exit('config', ['config' => $config], $this->parameters['extension'] ?? null);
}
}

View file

@ -29,8 +29,8 @@ use Friendica\DI;
*/
class Version extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
DI::apiResponse()->exit('version', ['version' => '0.9.7'], $parameters['extension'] ?? null);
DI::apiResponse()->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null);
}
}

View file

@ -29,14 +29,14 @@ use Friendica\DI;
*/
class Test extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
$ok = 'true';
} else {
$ok = 'ok';
}
DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null);
}
}

View file

@ -33,27 +33,26 @@ use Friendica\Module\BaseApi;
class Accounts extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id']) && empty($parameters['name'])) {
if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!empty($parameters['id'])) {
$id = $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' => $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($parameters['name'], 0, false))) {
} elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
DI::mstdnError()->RecordNotFound();
}
}

View file

@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
*/
class Block extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -46,7 +46,7 @@ class Block extends BaseApi
DI::mstdnError()->Forbidden();
}
$cdata = Contact::getPublicAndUserContactID($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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class FeaturedTags extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -31,16 +31,16 @@ use Friendica\Module\BaseApi;
*/
class Follow extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$cid = Contact::follow($parameters['id'], $uid);
$cid = Contact::follow($this->parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
}

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Followers extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Followers extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['relation-cid'], $condition, $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

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Following extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Following extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('contact-relation', ['cid'], $condition, $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

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class IdentityProofs extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,19 +33,18 @@ use Friendica\Module\BaseApi;
class Lists extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Mute extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored($parameters['id'], $uid, true);
Contact\User::setIgnored($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,12 +32,12 @@ use Friendica\Module\BaseApi;
*/
class Note extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -45,13 +45,13 @@ class Note extends BaseApi
'comment' => '',
]);
$cdata = Contact::getPublicAndUserContactID($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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Relationships extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -35,10 +35,9 @@ use Friendica\Object\Search\ContactResult;
class Search extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -37,18 +37,17 @@ use Friendica\Protocol\Activity;
class Statuses extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unblock extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setBlocked($parameters['id'], $uid, false);
Contact\User::setBlocked($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unfollow extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact::unfollow($parameters['id'], $uid);
Contact::unfollow($this->parameters['id'], $uid);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Unmute extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Contact\User::setIgnored($parameters['id'], $uid, false);
Contact\User::setIgnored($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,7 +32,7 @@ use Friendica\Util\HTTPInputData;
*/
class UpdateCredentials extends BaseApi
{
public static function patch(array $parameters = [])
public function patch()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -33,10 +33,9 @@ use Friendica\Module\BaseApi;
class VerifyCredentials extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Announcements extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,10 +33,9 @@ use Friendica\Util\Network;
class Apps extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post(array $parameters = [])
public function post()
{
$request = self::getRequest([
'client_name' => '',

View file

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class VerifyCredentials extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$application = self::getCurrentApplication();

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Blocks extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Blocks extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, $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

@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
class Bookmarks extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,26 +31,25 @@ use Friendica\Module\BaseApi;
*/
class Conversations extends BaseApi
{
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
if (!empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::delete('conv', ['id' => $parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => $parameters['id'], 'uid' => $uid]);
DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]);
System::jsonExit([]);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,17 +31,17 @@ use Friendica\Module\BaseApi;
*/
class Read extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
if (!empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
DBA::update('mail', ['seen' => true], ['convid' => $parameters['id'], 'uid' => $uid]);
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($parameters['id'])->toArray());
System::jsonExit(DI::mstdnConversation()->CreateFromConvId($this->parameters['id'])->toArray());
}
}

View file

@ -33,12 +33,11 @@ use Friendica\Network\HTTPException;
class CustomEmojis extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList());

View file

@ -35,12 +35,11 @@ use Friendica\Network\HTTPException;
class Directory extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/instance/directory/
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$request = self::getRequest([
'offset' => 0, // How many accounts to skip before returning results. Default 0.

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Endorsements extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
System::jsonExit([]);
}

View file

@ -35,10 +35,9 @@ use Friendica\Protocol\Activity;
class Favourited extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Filters extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -39,10 +39,9 @@ class Filters extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -33,7 +33,6 @@ use Friendica\Network\HTTPException;
class FollowRequests extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\BadRequestException
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
@ -43,16 +42,16 @@ class FollowRequests extends BaseApi
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow
*/
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_FOLLOW);
$uid = self::getCurrentUserID();
$introduction = DI::intro()->selectOneById($parameters['id'], $uid);
$introduction = DI::intro()->selectOneById($this->parameters['id'], $uid);
$contactId = $introduction->cid;
switch ($parameters['action']) {
switch ($this->parameters['action']) {
case 'authorize':
Contact\Introduction::confirm($introduction);
$relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid);
@ -79,12 +78,11 @@ class FollowRequests extends BaseApi
}
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
* @see https://docs.joinmastodon.org/methods/accounts/follow_requests/
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -31,10 +31,9 @@ use Friendica\Object\Api\Mastodon\Instance as InstanceEntity;
class Instance extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
System::jsonExit(InstanceEntity::get());
}

View file

@ -34,10 +34,9 @@ use Friendica\Util\Network;
class Peers extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$return = [];

View file

@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
class Rules extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$rules = [];
$id = 0;

View file

@ -31,27 +31,27 @@ use Friendica\Model\Group;
*/
class Lists extends BaseApi
{
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!Group::exists($parameters['id'], $uid)) {
if (!Group::exists($this->parameters['id'], $uid)) {
DI::mstdnError()->RecordNotFound();
}
if (!Group::remove($parameters['id'])) {
if (!Group::remove($this->parameters['id'])) {
DI::mstdnError()->InternalError();
}
System::jsonExit([]);
}
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -74,30 +74,29 @@ class Lists extends BaseApi
System::jsonExit(DI::mstdnList()->createFromGroupId($id));
}
public static function put(array $parameters = [])
public function put()
{
$request = self::getRequest([
'title' => '', // The title of the list to be updated.
'replies_policy' => '', // One of: "followed", "list", or "none".
]);
if (empty($request['title']) || empty($parameters['id'])) {
if (empty($request['title']) || empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
Group::update($parameters['id'], $request['title']);
Group::update($this->parameters['id'], $request['title']);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
$lists = [];
$groups = Group::getByUserId($uid);
@ -106,7 +105,7 @@ class Lists extends BaseApi
$lists[] = DI::mstdnList()->createFromGroupId($group['id']);
}
} else {
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!Group::exists($id, $uid)) {
DI::mstdnError()->RecordNotFound();

View file

@ -35,30 +35,29 @@ use Friendica\Module\BaseApi;
*/
class Accounts extends BaseApi
{
public static function delete(array $parameters = [])
public function delete()
{
DI::apiResponse()->unsupported(Router::DELETE);
}
public static function post(array $parameters = [])
public function post()
{
DI::apiResponse()->unsupported(Router::POST);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class Markers extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
@ -39,10 +39,9 @@ class Markers extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);

View file

@ -32,7 +32,7 @@ use Friendica\Module\BaseApi;
*/
class Media extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -53,7 +53,7 @@ class Media extends BaseApi
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id']));
}
public static function put(array $parameters = [])
public function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -65,34 +65,33 @@ class Media extends BaseApi
'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0
]);
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$photo = Photo::selectFirst(['resource-id'], ['id' => $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($parameters['id']));
System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id']));
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -32,19 +32,18 @@ use Friendica\Module\BaseApi;
class Mutes extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
DI::mstdnError()->RecordNotFound();
}
@ -73,7 +72,7 @@ class Mutes extends BaseApi
$params['order'] = ['cid'];
}
$followers = DBA::select('user-contact', ['cid'], $condition, $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

@ -38,16 +38,15 @@ use Friendica\Protocol\Activity;
class Notifications extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (!empty($parameters['id'])) {
$id = $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

@ -30,7 +30,7 @@ use Friendica\Module\BaseApi;
*/
class Clear extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();

View file

@ -32,16 +32,16 @@ use Friendica\Network\HTTPException\ForbiddenException;
*/
class Dismiss extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$Notification = DI::notification()->selectOneForUser($uid, $parameters['id']);
$Notification = DI::notification()->selectOneForUser($uid, $this->parameters['id']);
$Notification->setSeen();
DI::notification()->save($Notification);

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Preferences extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -30,10 +30,9 @@ use Friendica\Module\BaseApi;
class Proofs extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
System::jsonError(404, ['error' => 'Record not found']);
}

View file

@ -33,7 +33,7 @@ use Friendica\Object\Api\Mastodon\Notification;
*/
class PushSubscription extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -66,7 +66,7 @@ class PushSubscription extends BaseApi
return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray();
}
public static function put(array $parameters = [])
public function put()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -99,7 +99,7 @@ class PushSubscription extends BaseApi
return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray();
}
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();
@ -112,7 +112,7 @@ class PushSubscription extends BaseApi
System::jsonExit([]);
}
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_PUSH);
$uid = self::getCurrentUserID();

View file

@ -34,7 +34,7 @@ use Friendica\Module\BaseApi;
*/
class ScheduledStatuses extends BaseApi
{
public static function put(array $parameters = [])
public function put()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -42,35 +42,34 @@ class ScheduledStatuses extends BaseApi
DI::apiResponse()->unsupported(Router::PUT);
}
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
if (!DBA::exists('delayed-post', ['id' => $parameters['id'], 'uid' => $uid])) {
if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) {
DI::mstdnError()->RecordNotFound();
}
Post\Delayed::deleteById($parameters['id']);
Post\Delayed::deleteById($this->parameters['id']);
System::jsonExit([]);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (isset($parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($parameters['id'], $uid)->toArray());
if (isset($this->parameters['id'])) {
System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray());
}
$request = self::getRequest([

View file

@ -38,10 +38,9 @@ use Friendica\Object\Search\ContactResult;
class Search extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -74,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'], $parameters['version']);
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
}
System::jsonExit($result);

View file

@ -41,7 +41,7 @@ use Friendica\Util\Images;
*/
class Statuses extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
@ -207,16 +207,16 @@ class Statuses extends BaseApi
DI::mstdnError()->InternalError();
}
public static function delete(array $parameters = [])
public function delete()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $parameters['id'], 'uid' => $uid]);
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]);
if (empty($item['id'])) {
DI::mstdnError()->RecordNotFound();
}
@ -229,17 +229,16 @@ class Statuses extends BaseApi
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid));
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid));
}
}

View file

@ -33,16 +33,16 @@ use Friendica\Module\BaseApi;
*/
class Bookmark extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -33,18 +33,17 @@ use Friendica\Network\HTTPException;
class Card extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $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

@ -33,14 +33,13 @@ use Friendica\Module\BaseApi;
class Context extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -48,7 +47,7 @@ class Context extends BaseApi
'limit' => 40, // Maximum number of results to return. Defaults to 40.
]);
$id = $parameters['id'];
$id = $this->parameters['id'];
$parents = [];
$children = [];

View file

@ -33,22 +33,22 @@ use Friendica\Module\BaseApi;
*/
class Favourite extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -33,18 +33,17 @@ use Friendica\Protocol\Activity;
class FavouritedBy extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -32,16 +32,16 @@ use Friendica\Module\BaseApi;
*/
class Mute extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid, true);
Post\ThreadUser::setIgnored($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,16 +32,16 @@ use Friendica\Module\BaseApi;
*/
class Pin extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid, true);
Post\ThreadUser::setPinned($this->parameters['id'], $uid, true);
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -35,16 +35,16 @@ use Friendica\Module\BaseApi;
*/
class Reblog extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -33,18 +33,17 @@ use Friendica\Protocol\Activity;
class RebloggedBy extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$id = $parameters['id'];
$id = $this->parameters['id'];
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
DI::mstdnError()->RecordNotFound();
}

View file

@ -33,16 +33,16 @@ use Friendica\Module\BaseApi;
*/
class Unbookmark extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -33,22 +33,22 @@ use Friendica\Module\BaseApi;
*/
class Unfavourite extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,16 +32,16 @@ use Friendica\Module\BaseApi;
*/
class Unmute extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid, false);
Post\ThreadUser::setIgnored($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,16 +32,16 @@ use Friendica\Module\BaseApi;
*/
class Unpin extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $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($parameters['id'], $uid, false);
Post\ThreadUser::setPinned($this->parameters['id'], $uid, false);
System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -35,16 +35,16 @@ use Friendica\Module\BaseApi;
*/
class Unreblog extends BaseApi
{
public static function post(array $parameters = [])
public function post()
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
$item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $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($parameters['id'], $uid)->toArray());
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
}
}

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Suggestions extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -33,10 +33,9 @@ use Friendica\Network\HTTPException;
class Direct extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -34,10 +34,9 @@ use Friendica\Network\HTTPException;
class Home extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();

View file

@ -34,15 +34,14 @@ use Friendica\Network\HTTPException;
class ListTimeline extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['id'])) {
if (empty($this->parameters['id'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -61,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, $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

@ -37,10 +37,9 @@ use Friendica\Network\HTTPException;
class PublicTimeline extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$uid = self::getCurrentUserID();

View file

@ -35,15 +35,14 @@ use Friendica\Network\HTTPException;
class Tag extends BaseApi
{
/**
* @param array $parameters
* @throws HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
if (empty($parameters['hashtag'])) {
if (empty($this->parameters['hashtag'])) {
DI::mstdnError()->UnprocessableEntity();
}
@ -70,7 +69,7 @@ class Tag extends BaseApi
$condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`))
AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))",
$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`)"]);

View file

@ -32,10 +32,9 @@ use Friendica\Module\BaseApi;
class Trends extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
$request = self::getRequest([
'limit' => 20, // Maximum number of results to return. Defaults to 10.

View file

@ -31,46 +31,41 @@ use Friendica\Module\BaseApi;
class Unimplemented extends BaseApi
{
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete(array $parameters = [])
public function delete()
{
DI::apiResponse()->unsupported(Router::DELETE);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function patch(array $parameters = [])
public function patch()
{
DI::apiResponse()->unsupported(Router::PATCH);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function post(array $parameters = [])
public function post()
{
DI::apiResponse()->unsupported(Router::POST);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function put(array $parameters = [])
public function put()
{
DI::apiResponse()->unsupported(Router::PUT);
}
/**
* @param array $parameters
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function rawContent(array $parameters = [])
public function rawContent()
{
DI::apiResponse()->unsupported(Router::GET);
}

View file

@ -30,9 +30,9 @@ use Friendica\Util\DateTimeFormat;
*/
class RateLimitStatus extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) {
if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) {
$hash = [
'remaining-hits' => '150',
'@attributes' => ["type" => "integer"],
@ -52,6 +52,6 @@ class RateLimitStatus extends BaseApi
];
}
DI::apiResponse()->exit('hash', ['hash' => $hash], $parameters['extension'] ?? null);
DI::apiResponse()->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null);
}
}

View file

@ -35,9 +35,9 @@ abstract class ContactEndpoint extends BaseApi
const DEFAULT_COUNT = 20;
const MAX_COUNT = 200;
public static function init(array $parameters = [])
public function init()
{
parent::init($parameters);
parent::init();
self::checkAllowedScope(self::SCOPE_READ);
}

View file

@ -30,7 +30,7 @@ use Friendica\Module\Api\Twitter\ContactEndpoint;
*/
class FollowersIds extends ContactEndpoint
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);

View file

@ -30,7 +30,7 @@ use Friendica\Module\Api\Twitter\ContactEndpoint;
*/
class FollowersList extends ContactEndpoint
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);

View file

@ -30,7 +30,7 @@ use Friendica\Module\Api\Twitter\ContactEndpoint;
*/
class Ids extends ContactEndpoint
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);

View file

@ -30,7 +30,7 @@ use Friendica\Module\Api\Twitter\ContactEndpoint;
*/
class Lists extends ContactEndpoint
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);

View file

@ -31,7 +31,7 @@ use Friendica\Module\BaseApi;
*/
class SavedSearches extends BaseApi
{
public static function rawContent(array $parameters = [])
public function rawContent()
{
self::checkAllowedScope(self::SCOPE_READ);
$uid = self::getCurrentUserID();
@ -45,6 +45,6 @@ class SavedSearches extends BaseApi
DBA::close($terms);
DI::apiResponse()->exit('terms', ['terms' => $result], $parameters['extension'] ?? null);
DI::apiResponse()->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null);
}
}