[Controller][Security] Fullname is not setup automatically upon registering anymore.

[ENTITY][Actor] Changes to accomodate fullname from potentially being null.
[ENTITY][Note] Changes to accomodate fullname from potentially being null.
This commit is contained in:
Eliseu Amaro 2021-10-29 22:05:10 +01:00
parent ac8513741d
commit 91dd6e1428
No known key found for this signature in database
GPG Key ID: 96DA09D4B97BC2D5
4 changed files with 9 additions and 6 deletions

View File

@ -135,7 +135,7 @@ class Security extends Controller
try {
// This already checks if the nickname is being used
$actor = Actor::create(['nickname' => $sanitized_nickname, 'fullname' => $sanitized_nickname]);
$actor = Actor::create(['nickname' => $sanitized_nickname]);
$user = LocalUser::create([
'nickname' => $sanitized_nickname,
'outgoing_email' => $data['email'],

View File

@ -54,7 +54,7 @@ class Actor extends Entity
// @codeCoverageIgnoreStart
private int $id;
private string $nickname;
private string $fullname;
private ?string $fullname = null;
private int $roles = 4;
private ?string $homepage;
private ?string $bio;
@ -95,8 +95,11 @@ class Actor extends Entity
return $this;
}
public function getFullname(): string
public function getFullname(): ?string
{
if (is_null($this->fullname)) {
return null;
}
return $this->fullname;
}
@ -244,7 +247,7 @@ class Actor extends Entity
return Cache::get('actor-nickname-id-' . $id, fn () => self::getById($id)->getNickname());
}
public static function getFullnameById(int $id): string
public static function getFullnameById(int $id): ?string
{
return Cache::get('actor-fullname-id-' . $id, fn () => self::getById($id)->getFullname());
}

View File

@ -241,7 +241,7 @@ class Note extends Entity
return Actor::getNicknameById($this->actor_id);
}
public function getActorFullname(): string
public function getActorFullname(): ?string
{
return Actor::getFullnameById($this->actor_id);
}

View File

@ -60,7 +60,7 @@
{# Microformat's h-card properties indicates a face icon is a "u-logo" #}
<a href="{{ actor_url }}" class="note-author u-url">
<strong class="note-author-fullname">
{% if fullname is defined %}
{% if fullname is not null %}
{{ fullname }}
{% else %}
{{ nickname }}