Replace getUsername with getUserIdentifier in activity checks

Updated activity checks in ListActivitiesByAccompanyingPeriodContext to use getUserIdentifier method instead of getUsername. This change corresponds to check for both activity users and work referrers. The getUserIdentifier method grants a more reliable way to identify users.
This commit is contained in:
Julien Fastré 2024-04-04 22:12:49 +02:00
parent 931c69eee4
commit 828304d983
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -122,13 +122,13 @@ class ListActivitiesByAccompanyingPeriodContext implements
function ($activity) use ($user) {
$u = $activity['user'];
if (null !== $u && $u['username'] === $user->getUsername()) {
if (null !== $u && $u['username'] === $user->getUserIdentifier()) {
return true;
}
$activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []);
return \in_array($user->getUsername(), $activityUsernames, true);
return \in_array($user->getUserIdentifier(), $activityUsernames, true);
}
)
);
@ -143,9 +143,9 @@ class ListActivitiesByAccompanyingPeriodContext implements
array_filter(
$works,
function ($work) use ($user) {
$workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []);
$workUsernames = array_map(static fn (User $user) => $user['username'], $work['referrers'] ?? []);
return \in_array($user->getUsername(), $workUsernames, true);
return \in_array($user->getUserIdentifier(), $workUsernames, true);
}
)
);