Skip to content

Commit e03549f

Browse files
committed
Fix error if user has no discord avatar or email address
1 parent 6913efa commit e03549f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

app/Http/Controllers/SeatingPlanController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function show(Request $request, Event $event, ?Ticket $ticket = null)
8989
}
9090
}
9191
}
92-
92+
9393
$responsibleTickets = array_unique($responsibleTickets);
9494
$responsibleSeats = array_unique($responsibleSeats);
9595

app/Models/User.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ public function avatarUrl(): string
7272
return $acc->avatar_url;
7373
}
7474
}
75-
return 'https://gravatar.com/avatar/' . hash('sha256', $this->primaryEmail->email) . '?d=retro';
75+
if ($this->primaryEmail) {
76+
$toHash = $this->primaryEmail->email;
77+
} else {
78+
$toHash = $this->nickname;
79+
}
80+
$hash = hash('sha256', $toHash);
81+
return "https://gravatar.com/avatar/{$hash}?d=retro";
7682
}
7783

7884
public function syncTickets(bool $sync = false, bool $force = false): void

0 commit comments

Comments
 (0)