$request = self::getRequest([
'id' => 0, // Id of the post
- ]);
+ ], $request);
$res = Item::performActivity($request['id'], $this->parameters['verb'], $uid);
$request = self::getRequest([
'id' => 0, // Id of the direct message
- ]);
+ ], $request);
// return error if id is zero
if (empty($request['id'])) {
$request = self::getRequest([
'since_id' => 0,
'count' => 0,
- ]);
+ ], $request);
$condition = ["`id` > ? AND `uid` = ?", $request['since_id'], $uid];
$params = ['limit' => $request['count']];
$request = self::getRequest([
'gid' => 0,
'name' => ''
- ]);
+ ], $request);
// params
$request = self::getRequest([
'photo_id' => null, // Photo id
- ]);
+ ], $request);
// do several checks on input parameters
// we do not allow calls without photo id
$request = self::getRequest([
'album' => '', // Album name
- ]);
+ ], $request);
// we do not allow calls without album string
if (empty($request['album'])) {
$request = self::getRequest([
'album' => '', // Current album name
'album_new' => '', // New album name
- ]);
+ ], $request);
// we do not allow calls without album string
if (empty($request['album'])) {
'since_id' => 0, // Return results newer than this id
'min_id' => 0, // Return results immediately newer than id
'limit' => 40, // Maximum number of results to return. Defaults to 40.
- ]);
+ ], $request);
$params = ['order' => ['relation-cid' => true], 'limit' => $request['limit']];
'since_id' => 0, // Return results newer than this id
'min_id' => 0, // Return results immediately newer than id
'limit' => 40, // Maximum number of results to return. Defaults to 40.
- ]);
+ ], $request);
$params = ['order' => ['cid' => true], 'limit' => $request['limit']];
$request = self::getRequest([
'comment' => '',
- ]);
+ ], $request);
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
if (empty($cdata['user'])) {
$request = self::getRequest([
'id' => [],
- ]);
+ ], $request);
if (empty($request['id'])) {
DI::mstdnError()->UnprocessableEntity();
'limit' => 40, // Maximum number of results. Defaults to 40.
'resolve' => false, // Attempt WebFinger lookup. Defaults to false. Use this when q is an exact address.
'following' => false, // Only who the user is following. Defaults to false.
- ]);
+ ], $request);
$accounts = [];
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
'exclude_reblogs' => false, // Undocumented parameter
'tagged' => false, // Undocumented parameter
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'redirect_uris' => '',
'scopes' => 'read',
'website' => '',
- ]);
+ ], $request);
// Workaround for AndStatus, see issue https://github.com/andstatus/andstatus/issues/538
$postdata = Network::postdata();
'since_id' => 0, // Return results newer than this id
'min_id' => 0, // Return results immediately newer than id
'limit' => 40, // Maximum number of results. Defaults to 40.
- ]);
+ ], $request);
$params = ['order' => ['cid' => true], 'limit' => $request['limit']];
'since_id' => 0, // Return results newer than id
'min_id' => 0, // Return results immediately newer than id
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'max_id' => 0, // Return results older than this ID. Use HTTP Link header to paginate.
'since_id' => 0, // Return results newer than this ID. Use HTTP Link header to paginate.
'min_id' => 0, // Return results immediately newer than this ID. Use HTTP Link header to paginate.
- ]);
+ ], $request);
$params = ['order' => ['id' => true], 'limit' => $request['limit']];
'limit' => 40, // How many accounts to load. Default 40.
'order' => 'active', // active to sort by most recently posted statuses (default) or new to sort by most recently created profiles.
'local' => false, // Only return local accounts.
- ]);
+ ], $request);
Logger::info('directory', ['offset' => $request['offset'], 'limit' => $request['limit'], 'order' => $request['order'], 'local' => $request['local']]);
'min_id' => 0, // Return results immediately newer than id
'max_id' => 0, // Return results older than id
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
- ]);
+ ], $request);
$params = ['order' => ['thr-parent-id' => true], 'limit' => $request['limit']];
'min_id' => 0,
'max_id' => 0,
'limit' => 40, // Maximum number of results to return. Defaults to 40. Paginate using the HTTP Link header.
- ]);
+ ], $request);
$introductions = DI::intro()->selectForUser($uid, $request['min_id'], $request['max_id'], $request['limit']);
$request = self::getRequest([
'title' => '',
- ]);
+ ], $request);
if (empty($request['title'])) {
DI::mstdnError()->UnprocessableEntity();
'since_id' => 0, // Return results newer than this id
'min_id' => 0, // Return results immediately newer than id
'limit' => 40, // Maximum number of results. Defaults to 40. Max 40. Set to 0 in order to get all accounts without pagination.
- ]);
+ ], $request);
$params = ['order' => ['contact-id' => true]];
'since_id' => 0, // Return results newer than this id
'min_id' => 0, // Return results immediately newer than id
'limit' => 40, // Maximum number of results. Defaults to 40.
- ]);
+ ], $request);
$params = ['order' => ['cid' => true], 'limit' => $request['limit']];
'account_id' => 0, // Return only notifications received from this account
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
'count' => 0, // Unknown parameter
- ]);
+ ], $request);
$params = ['order' => ['id' => true]];
$request = self::getRequest([
'subscription' => [],
'data' => [],
- ]);
+ ], $request);
$subscription = [
'application-id' => $application['id'],
'max_id' => 0, // Return results older than ID
'since_id' => 0, // Return results newer than ID
'min_id' => 0, // Return results immediately newer than ID
- ]);
+ ], $request);
$params = ['order' => ['id' => true], 'limit' => $request['limit']];
'limit' => 20, // Maximum number of results to load, per type. Defaults to 20. Max 40.
'offset' => 0, // Offset in search results. Used for pagination. Defaults to 0.
'following' => false, // Only include accounts that the user is following. Defaults to false.
- ]);
+ ], $request);
if (empty($request['q'])) {
DI::mstdnError()->UnprocessableEntity();
'visibility' => '', // Visibility of the posted status. One of: "public", "unlisted", "private" or "direct".
'scheduled_at' => '', // ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future.
'language' => '', // ISO 639 language code for this status.
- ]);
+ ], $request);
$owner = User::getOwnerDataById($uid);
$request = self::getRequest([
'limit' => 40, // Maximum number of results to return. Defaults to 40.
- ]);
+ ], $request);
$id = $this->parameters['id'];
$request = self::getRequest([
'limit' => 40, // Maximum number of results to return. Defaults to 40.
- ]);
+ ], $request);
$suggestions = Contact\Relation::getSuggestions($uid, 0, $request['limit']);
'since_id' => 0, // Return results newer than id
'min_id' => 0, // Return results immediately newer than id
'limit' => 20, // Maximum number of results to return. Defaults to 20.
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'only_media' => false, // Show only statuses with media attached? Defaults to false.
'remote' => false, // Show only remote statuses? Defaults to false.
'exclude_replies' => false, // Don't show comments
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'local' => false, // Show only local statuses? Defaults to false.
'remote' => false, // Show only remote statuses? Defaults to false.
'exclude_replies' => false, // Don't show comments
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'limit' => 20, // Maximum number of results to return. Defaults to 20.
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
'exclude_replies' => false, // Don't show comments
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
'limit' => 20, // Maximum number of results to return. Defaults to 20.
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
'exclude_replies' => false, // Don't show comments
- ]);
+ ], $request);
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
{
$request = self::getRequest([
'limit' => 20, // Maximum number of results to return. Defaults to 10.
- ]);
+ ], $request);
$trending = [];
$tags = Tag::getGlobalTrendingHashtags(24, 20);
/**
* Processes data from GET requests and sets defaults
*
+ * @param array $defaults Associative array of expected request keys and their default typed value. A null
+ * value will remove the request key from the resulting value array.
+ * @param array|null $request Custom REQUEST array, superglobal instead
* @return array request data
+ * @throws \Exception
*/
- public static function getRequest(array $defaults)
+ public static function getRequest(array $defaults, array $request = null): array
{
$httpinput = HTTPInputData::process();
- $input = array_merge($httpinput['variables'], $httpinput['files'], $_REQUEST);
+ $input = array_merge($httpinput['variables'], $httpinput['files'], $request ?? $_REQUEST);
self::$request = $input;
self::$boundaries = [];
'redirect_uri' => '', // Set a URI to redirect the user to. If this parameter is set to "urn:ietf:wg:oauth:2.0:oob" then the authorization code will be shown instead. Must match one of the redirect URIs declared during app registration.
'scope' => 'read', // List of requested OAuth scopes, separated by spaces (or by pluses, if using query parameters). Must be a subset of scopes declared during app registration. If not provided, defaults to "read".
'state' => '',
- ]);
+ ], $request);
if ($request['response_type'] != 'code') {
Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);
'client_id' => '', // Client ID, obtained during app registration
'client_secret' => '', // Client secret, obtained during app registration
'token' => '', // The previously obtained token, to be invalidated
- ]);
+ ], $request);
$condition = ['client_id' => $request['client_id'], 'client_secret' => $request['client_secret'], 'access_token' => $request['token']];
$token = DBA::selectFirst('application-view', ['id'], $condition);
'scope' => 'read', // List of requested OAuth scopes, separated by spaces. Must be a subset of scopes declared during app registration. If not provided, defaults to "read".
'code' => '', // A user authorization code, obtained via /oauth/authorize
'grant_type' => '', // Set equal to "authorization_code" if code is provided in order to gain user-level access. Otherwise, set equal to "client_credentials" to obtain app-level access only.
- ]);
+ ], $request);
// AndStatus transmits the client data in the AUTHORIZATION header field, see https://github.com/andstatus/andstatus/issues/530
$authorization = $_SERVER['HTTP_AUTHORIZATION'] ?? '';