use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Model\Verb;
+use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\ExpectationFailedException;
*/
function api_user()
{
+ $user = BaseApi::getCurrentUserID(true);
+ if (!empty($user)) {
+ return $user;
+ }
+
if (!empty($_SESSION['allow_api'])) {
return local_user();
}
*
* @return int User ID
*/
- protected static function getCurrentUserID()
+ public static function getCurrentUserID(bool $nologin = false)
{
if (empty(self::$current_user_id)) {
self::$current_token = self::getTokenByBearer();
} else {
self::$current_user_id = 0;
}
+ }
+ if ($nologin) {
+ return (int)self::$current_user_id;
}
if (empty(self::$current_user_id)) {