1
0
Fork 0

Merge pull request #8944 from annando/signed-requests

AP: Always sign HTTP requests
This commit is contained in:
Hypolite Petovan 2020-07-30 17:09:22 -04:00 committed by GitHub
commit 7aa43dc2f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 29 deletions

View file

@ -3705,8 +3705,10 @@ class Item
*/
public static function fetchByLink(string $uri, int $uid = 0)
{
Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]);
$item_id = self::searchByLink($uri, $uid);
if (!empty($item_id)) {
Logger::info('Link found', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
return $item_id;
}
@ -3717,9 +3719,11 @@ class Item
}
if (!empty($item_id)) {
Logger::info('Link fetched', ['uid' => $uid, 'uri' => $uri, 'id' => $item_id]);
return $item_id;
}
Logger::info('Link not found', ['uid' => $uid, 'uri' => $uri]);
return 0;
}

View file

@ -185,6 +185,24 @@ class User
return DBA::selectFirst('user', $fields, ['email' => $email]);
}
/**
* Fetch the user array of the administrator. The first one if there are several.
*
* @param array $fields
* @return array user
*/
public static function getFirstAdmin(array $fields = [])
{
if (!empty(DI::config()->get('config', 'admin_nickname'))) {
return self::getByNickname(DI::config()->get('config', 'admin_nickname'), $fields);
} elseif (!empty(DI::config()->get('config', 'admin_email'))) {
$adminList = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
return self::getByEmail($adminList[0], $fields);
} else {
return [];
}
}
/**
* Get owner data by user id
*