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 68ba7b1
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,27 @@ 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 68ba7b1

Please sign in to comment.