Skip to content

Commit

Permalink
fix(Chat): Add detailed typehints and return early
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Oct 10, 2023
1 parent 9463763 commit 4d88c6d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,26 @@ public function __construct(
parent::__construct($appName, $request);
}

/**
* @return list{0: Attendee::ACTOR_*, 1: string}
*/
protected function getActorInfo(string $actorDisplayName = ''): array {
if ($this->getRemoteAccessCloudId()) {
$actorType = Attendee::ACTOR_FEDERATED_USERS;
$actorId = $this->getRemoteAccessCloudId();
} elseif ($this->userId === null) {
$actorType = Attendee::ACTOR_GUESTS;
$actorId = $this->participant->getAttendee()->getActorId();
$remoteCloudId = $this->getRemoteAccessCloudId();
if ($remoteCloudId !== null) {
return [Attendee::ACTOR_FEDERATED_USERS, $remoteCloudId];
}
if ($this->userId === null) {

if ($actorDisplayName) {
$this->guestManager->updateName($this->room, $this->participant, $actorDisplayName);
}
} elseif ($this->userId === MatterbridgeManager::BRIDGE_BOT_USERID && $actorDisplayName) {
$actorType = Attendee::ACTOR_BRIDGED;
$actorId = str_replace(["/", "\""], "", $actorDisplayName);
} else {
$actorType = Attendee::ACTOR_USERS;
$actorId = $this->userId;
return [Attendee::ACTOR_GUESTS, $this->participant->getAttendee()->getActorId()];
}
if ($this->userId === MatterbridgeManager::BRIDGE_BOT_USERID && $actorDisplayName) {
return [Attendee::ACTOR_BRIDGED, str_replace(['/', '"'], '', $actorDisplayName)];
}

return [$actorType, $actorId];
return [Attendee::ACTOR_USERS, $this->userId];
}

/**
Expand Down

0 comments on commit 4d88c6d

Please sign in to comment.