X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=bcd555a0ec11c46a8b1bbc6cc858074c22b67c62;hb=9c0342b907c279fe335676a1cbeacae8a5ac5c85;hp=af70c420e6b2b3baf49f7134fcca1769391c49cc;hpb=4b9cbac23ec0dbebbdef7d9cdde183000e0d20ef;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index af70c420e6..bcd555a0ec 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -41,6 +41,7 @@ use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; use Friendica\Util\Network; +use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Worker\Delivery; use ImagickException; @@ -106,7 +107,7 @@ class User * Returns the numeric account type by their string * * @param string $accounttype as string constant - * @return void + * @return int|null Numeric account type - or null when not set */ public static function getAccountTypeByString(string $accounttype) { @@ -144,6 +145,26 @@ class User $system['sprvkey'] = $system['uprvkey'] = $system['prvkey']; $system['spubkey'] = $system['upubkey'] = $system['pubkey']; $system['nickname'] = $system['nick']; + + // Ensure that the user contains data + $user = DBA::selectFirst('user', ['prvkey'], ['uid' => 0]); + if (empty($user['prvkey'])) { + $fields = [ + 'username' => $system['name'], + 'nickname' => $system['nick'], + 'register_date' => $system['created'], + 'pubkey' => $system['pubkey'], + 'prvkey' => $system['prvkey'], + 'spubkey' => $system['spubkey'], + 'sprvkey' => $system['sprvkey'], + 'verified' => true, + 'page-flags' => User::PAGE_FLAGS_SOAPBOX, + 'account-type' => User::ACCOUNT_TYPE_RELAY, + ]; + + DBA::update('user', $fields, ['uid' => 0]); + } + return $system; } @@ -172,11 +193,12 @@ class User $system['name'] = 'System Account'; $system['addr'] = $system_actor_name . '@' . DI::baseUrl()->getHostname(); $system['nick'] = $system_actor_name; - $system['avatar'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO; - $system['photo'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO; - $system['thumb'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_THUMB; - $system['micro'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_MICRO; $system['url'] = DI::baseUrl() . '/friendica'; + + $system['avatar'] = $system['photo'] = Contact::getDefaultAvatar($system, Proxy::SIZE_SMALL); + $system['thumb'] = Contact::getDefaultAvatar($system, Proxy::SIZE_THUMB); + $system['micro'] = Contact::getDefaultAvatar($system, Proxy::SIZE_MICRO); + $system['nurl'] = Strings::normaliseLink($system['url']); $system['pubkey'] = $keys['pubkey']; $system['prvkey'] = $keys['prvkey']; @@ -215,7 +237,7 @@ class User // List of possible actor names $possible_accounts = ['friendica', 'actor', 'system', 'internal']; foreach ($possible_accounts as $name) { - if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire']) && + if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire' => false]) && !DBA::exists('userd', ['username' => $name])) { DI::config()->set('system', 'actor_name', $name); return $name; @@ -244,7 +266,7 @@ class User */ public static function getById($uid, array $fields = []) { - return DBA::selectFirst('user', $fields, ['uid' => $uid]); + return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : []; } /** @@ -539,7 +561,7 @@ class User * @return array * @throws HTTPException\NotFoundException */ - private static function getAuthenticationInfo($user_info) + public static function getAuthenticationInfo($user_info) { $user = null; @@ -1002,7 +1024,7 @@ class User $photo_failure = false; $filename = basename($photo); - $curlResult = DI::httpRequest()->get($photo, true); + $curlResult = DI::httpRequest()->get($photo); if ($curlResult->isSuccess()) { $img_str = $curlResult->getBody(); $type = $curlResult->getContentType(); @@ -1511,7 +1533,9 @@ class User $condition['blocked'] = false; break; case 'blocked': + $condition['account_removed'] = false; $condition['blocked'] = true; + $condition['verified'] = true; break; case 'removed': $condition['account_removed'] = true;