Merge remote-tracking branch 'upstream/2021.12-rc' into remove-obsolete
This commit is contained in:
@@ -221,6 +221,16 @@ class ApiResponse extends Response
|
||||
$this->addContent($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around exit() for JSON only responses
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function exitWithJson(array $data)
|
||||
{
|
||||
$this->exit('content', ['content' => $data], static::TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quit execution with the message that the endpoint isn't implemented
|
||||
*
|
||||
|
||||
@@ -81,7 +81,7 @@ class Followers extends BaseApi
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($accounts);
|
||||
$accounts = array_reverse($accounts);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -81,7 +81,7 @@ class Following extends BaseApi
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($accounts);
|
||||
$accounts = array_reverse($accounts);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -113,7 +113,7 @@ class Statuses extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
|
||||
|
||||
// @todo Support the source property,
|
||||
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
|
||||
System::jsonExit($account);
|
||||
$this->response->exitWithJson($account->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class Blocks extends BaseApi
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($accounts);
|
||||
$accounts = array_reverse($accounts);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -77,7 +77,7 @@ class Bookmarks extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -91,7 +91,7 @@ class Conversations extends BaseApi
|
||||
DBA::close($convs);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($conversations);
|
||||
$conversations = array_reverse($conversations);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -73,7 +73,7 @@ class Favourited extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -100,7 +100,7 @@ class Accounts extends BaseApi
|
||||
DBA::close($members);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($accounts);
|
||||
$accounts = array_reverse($accounts);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -81,7 +81,7 @@ class Mutes extends BaseApi
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($accounts);
|
||||
$accounts = array_reverse($accounts);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -105,7 +105,7 @@ class ScheduledStatuses extends BaseApi
|
||||
DBA::close($posts);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -167,7 +167,7 @@ class Search extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -75,7 +75,7 @@ class Direct extends BaseApi
|
||||
}
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -98,7 +98,7 @@ class Home extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -103,7 +103,7 @@ class ListTimeline extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -109,7 +109,7 @@ class PublicTimeline extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -112,7 +112,7 @@ class Tag extends BaseApi
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
$statuses = array_reverse($statuses);
|
||||
}
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
@@ -39,22 +39,22 @@ class UpdateProfile extends BaseApi
|
||||
|
||||
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();
|
||||
|
||||
if (!empty($_POST['name'])) {
|
||||
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
|
||||
if (!empty($request['name'])) {
|
||||
DBA::update('profile', ['name' => $request['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $request['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $request['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $request['name']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
if (isset($_POST['description'])) {
|
||||
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
|
||||
if (isset($request['description'])) {
|
||||
DBA::update('profile', ['about' => $request['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $request['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $request['description']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
Profile::publishUpdate($uid);
|
||||
|
||||
$skip_status = $_REQUEST['skip_status'] ?? false;
|
||||
$skip_status = $request['skip_status'] ?? false;
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class Ids extends ContactEndpoint
|
||||
DBA::close($contacts);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
|
||||
|
||||
@@ -80,13 +80,13 @@ class Lists extends ContactEndpoint
|
||||
DBA::close($contacts);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class Ids extends ContactEndpoint
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
|
||||
|
||||
@@ -85,13 +85,13 @@ class Lists extends ContactEndpoint
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class Ids extends ContactEndpoint
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
|
||||
|
||||
@@ -85,13 +85,13 @@ class Lists extends ContactEndpoint
|
||||
DBA::close($followers);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ class Incoming extends ContactEndpoint
|
||||
DBA::close($contacts);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
array_reverse($ids);
|
||||
$ids = array_reverse($ids);
|
||||
}
|
||||
|
||||
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
|
||||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('incoming', ['incoming' => $return]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,23 +40,23 @@ class Statuses extends BaseApi
|
||||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
if (empty($_REQUEST['list_id'])) {
|
||||
if (empty($request['list_id'])) {
|
||||
throw new BadRequestException('list_id not specified');
|
||||
}
|
||||
|
||||
// params
|
||||
$count = $_REQUEST['count'] ?? 20;
|
||||
$page = $_REQUEST['page'] ?? 1;
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
$exclude_replies = (!empty($_REQUEST['exclude_replies']) ? 1 : 0);
|
||||
$conversation_id = $_REQUEST['conversation_id'] ?? 0;
|
||||
$count = $request['count'] ?? 20;
|
||||
$page = $request['page'] ?? 1;
|
||||
$since_id = $request['since_id'] ?? 0;
|
||||
$max_id = $request['max_id'] ?? 0;
|
||||
$exclude_replies = (!empty($request['exclude_replies']) ? 1 : 0);
|
||||
$conversation_id = $request['conversation_id'] ?? 0;
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => 1]);
|
||||
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids];
|
||||
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
@@ -75,7 +75,7 @@ class Statuses extends BaseApi
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
|
||||
$items = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
||||
@@ -437,6 +437,13 @@ class Transmitter
|
||||
return [];
|
||||
}
|
||||
|
||||
$permissions = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'bto' => [],
|
||||
'bcc' => [],
|
||||
];
|
||||
|
||||
$activity = json_decode($conversation['source'], true);
|
||||
|
||||
$actor = JsonLD::fetchElement($activity, 'actor', 'id');
|
||||
|
||||
Reference in New Issue
Block a user