mirror of
https://github.com/friendica/friendica
synced 2025-04-19 07:10:11 +00:00
API: Fix profile_url handling / missing constant
This commit is contained in:
parent
dbcaf51923
commit
fb47389c69
12 changed files with 83 additions and 110 deletions
|
@ -36,6 +36,8 @@ use Friendica\Util\HTTPInputData;
|
|||
|
||||
class BaseApi extends BaseModule
|
||||
{
|
||||
const LOG_PREFIX = 'API {action} - ';
|
||||
|
||||
const SCOPE_READ = 'read';
|
||||
const SCOPE_WRITE = 'write';
|
||||
const SCOPE_FOLLOW = 'follow';
|
||||
|
@ -293,25 +295,31 @@ class BaseApi extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
public static function getContactIDForSearchterm(string $screen_name = null, int $cid = null, int $uid)
|
||||
public static function getContactIDForSearchterm(string $screen_name = null, int $cid = null, string $profileurl = null, int $uid)
|
||||
{
|
||||
if (!empty($cid)) {
|
||||
return $cid;
|
||||
}
|
||||
|
||||
if (strpos($screen_name, '@') !== false) {
|
||||
$cid = Contact::getIdForURL($screen_name, 0, false);
|
||||
} else {
|
||||
if (!empty($profileurl)) {
|
||||
return Contact::getIdForURL($profileurl);
|
||||
}
|
||||
|
||||
if (empty($cid) && !empty($screen_name)) {
|
||||
if (strpos($screen_name, '@') !== false) {
|
||||
return Contact::getIdForURL($screen_name, 0, false);
|
||||
}
|
||||
|
||||
$user = User::getByNickname($screen_name, ['uid']);
|
||||
if (!empty($user['uid'])) {
|
||||
$cid = Contact::getPublicIdByUserId($user['uid']);
|
||||
return Contact::getPublicIdByUserId($user['uid']);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cid) && ($uid != 0)) {
|
||||
$cid = Contact::getPublicIdByUserId($uid);
|
||||
if ($uid != 0) {
|
||||
return Contact::getPublicIdByUserId($uid);
|
||||
}
|
||||
|
||||
return $cid;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue