Skip to content

Commit

Permalink
Non privileged users are now allowed to list the admins
Browse files Browse the repository at this point in the history
  • Loading branch information
PeeHaa committed Apr 3, 2016
1 parent 4856d89 commit 9664b42
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Chat/Plugin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ private function validMessage(Message $message): bool {
}

private function execute(Message $message): \Generator {
if ($message->getParameters()[0] === "list") {
yield from $this->getList();

return;
}

if (!yield from $this->storage->isAdmin($message->getMessage()->getUserId())) {
yield from $this->chatClient->postMessage(
sprintf(":%d I'm sorry Dave, I'm afraid I can't do that", $message->getOrigin())
Expand All @@ -47,9 +53,7 @@ private function execute(Message $message): \Generator {
return;
}

if ($message->getParameters()[0] === "list") {
yield from $this->getList();
} elseif ($message->getParameters()[0] === "add") {
if ($message->getParameters()[0] === "add") {
yield from $this->add((int) $message->getParameters()[1]);
} elseif ($message->getParameters()[0] === "remove") {
yield from $this->remove((int) $message->getParameters()[1]);
Expand Down

0 comments on commit 9664b42

Please sign in to comment.