API: Fix profile_url handling / missing constant

This commit is contained in:
Michael 2021-11-26 07:55:02 +00:00
parent dbcaf51923
commit fb47389c69
12 changed files with 83 additions and 110 deletions

View file

@ -44,7 +44,7 @@ class Index extends BaseApi
public function rawContent()
{
echo api_call(DI::app());
echo api_call(DI::args()->getCommand(), $this->parameters['extension'] ?? 'json');
exit();
}
}

View file

@ -52,7 +52,7 @@ class Conversation extends BaseApi
$id = $_REQUEST['id'] ?? 0;
}
Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
// try to fetch the item for the local user - or the public item, if there is no local one
$item = Post::selectFirst(['parent-uri-id'], ['id' => $id]);

View file

@ -42,7 +42,7 @@ class Favorites extends BaseApi
// in friendica starred item are private
// return favorites only for self
Logger::info(API_LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
Logger::info(BaseApi::LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites']);
// params
$since_id = $_REQUEST['since_id'] ?? 0;

View file

@ -39,6 +39,7 @@ class Ids extends ContactEndpoint
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);
$screen_name = filter_input(INPUT_GET, 'screen_name');
$profile_url = filter_input(INPUT_GET, 'profile_url');
$cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]);
$stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
$count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
@ -51,7 +52,7 @@ class Ids extends ContactEndpoint
$max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT);
$min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $contact_id, $uid);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid);
$params = ['order' => ['relation-cid' => true], 'limit' => $count];

View file

@ -39,6 +39,7 @@ class Lists extends ContactEndpoint
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);
$screen_name = filter_input(INPUT_GET, 'screen_name');
$profile_url = filter_input(INPUT_GET, 'profile_url');
$cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]);
$skip_status = filter_input(INPUT_GET, 'skip_status' , FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
$include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
@ -52,7 +53,7 @@ class Lists extends ContactEndpoint
$max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT);
$min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $contact_id, $uid);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid);
$params = ['order' => ['relation-cid' => true], 'limit' => $count];

View file

@ -39,6 +39,7 @@ class Ids extends ContactEndpoint
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);
$screen_name = filter_input(INPUT_GET, 'screen_name');
$profile_url = filter_input(INPUT_GET, 'profile_url');
$cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]);
$stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
$count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
@ -51,7 +52,7 @@ class Ids extends ContactEndpoint
$max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT);
$min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $contact_id, $uid);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid);
$params = ['order' => ['cid' => true], 'limit' => $count];

View file

@ -39,6 +39,7 @@ class Lists extends ContactEndpoint
// Expected value for user_id parameter: public/user contact id
$contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT);
$screen_name = filter_input(INPUT_GET, 'screen_name');
$profile_url = filter_input(INPUT_GET, 'profile_url');
$cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]);
$skip_status = filter_input(INPUT_GET, 'skip_status' , FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
$include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]);
@ -52,7 +53,7 @@ class Lists extends ContactEndpoint
$max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT);
$min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $contact_id, $uid);
$cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid);
$params = ['order' => ['cid' => true], 'limit' => $count];

View file

@ -42,7 +42,7 @@ class UserTimeline extends BaseApi
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $_REQUEST]);
$cid = BaseApi::getContactIDForSearchterm($_REQUEST['screen_name'] ?? '', $_REQUEST['user_id'] ?? 0, $uid);
$cid = BaseApi::getContactIDForSearchterm($_REQUEST['screen_name'] ?? '', $_REQUEST['profileurl'] ?? '', $_REQUEST['user_id'] ?? 0, $uid);
$since_id = $_REQUEST['since_id'] ?? 0;
$max_id = $_REQUEST['max_id'] ?? 0;
$exclude_replies = !empty($_REQUEST['exclude_replies']);

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Twitter\Users;
use Friendica\Module\BaseApi;
use Friendica\DI;
use Friendica\Model\Contact;
/**
* Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
@ -38,7 +39,7 @@ class Show extends BaseApi
$uid = BaseApi::getCurrentUserID();
if (empty($this->parameters['id'])) {
$cid = BaseApi::getContactIDForSearchterm($_REQUEST['screen_name'] ?? '', $_REQUEST['user_id'] ?? 0, $uid);
$cid = BaseApi::getContactIDForSearchterm($_REQUEST['screen_name'] ?? '', $_REQUEST['profileurl'] ?? '', $_REQUEST['user_id'] ?? 0, $uid);
} else {
$cid = (int)$this->parameters['id'];
}