Skip to content

Commit

Permalink
Switch to display name instead of username (except for Renamed event)
Browse files Browse the repository at this point in the history
Closes #25
  • Loading branch information
dsevillamartin committed Dec 27, 2020
1 parent a85bc41 commit 32775d3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Actions/User/Deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function listen($event)
{
return Response::build($event)
->setTitle(
$this->translate('user.deleted', $event->user->username)
$this->translate('user.deleted', $event->user->display_name)
)
->setAuthor($event->actor)
->setColor('4b7bec')
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/Discord/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public function send(string $url, Response $response)
*
* @return array
*/
public function toArray(Response $response)
public function toArray(Response $response): array
{
return [
'title' => substr($response->title, 0, 256),
'url' => $response->url,
'description' => $response->description ? substr($response->description, 0, 2048) : null,
'author' => isset($response->author) ? [
'name' => substr($response->author->username, 0, 256),
'name' => substr($response->author->display_name, 0, 256),
'url' => $response->getAuthorUrl(),
'icon_url' => $response->author->avatar_url,
] : null,
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/MicrosoftTeams/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function send(string $url, Response $response)
*
* @return array
*/
public function toArray(Response $response)
public function toArray(Response $response): array
{
$user = app(UrlGenerator::class)->to('forum')->route('user', ['username' => $response->author->username]);
$user = $response->getAuthorUrl();

return [
'title' => $response->title,
Expand Down
6 changes: 3 additions & 3 deletions src/Adapters/Slack/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public function send(string $url, Response $response)
*
* @return array
*/
public function toArray(Response $response)
public function toArray(Response $response): array
{
$data = [
'fallback' => $response->description.($response->author ? ' - '.$response->author->username : ''),
'fallback' => $response->description.($response->author ? ' - '.$response->author->display_name : ''),
'color' => $response->color,
'title' => $response->title,
'title_link' => $response->url,
Expand All @@ -75,7 +75,7 @@ public function toArray(Response $response)
];

if (isset($response->author)) {
$data['author_name'] = $response->author->username;
$data['author_name'] = $response->author->display_name;
$data['author_link'] = $response->getAuthorUrl();
$data['author_icon'] = $response->author->avatar_url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ protected function setWebhook(Webhook $webhook)

public function __toString()
{
return "Response{title=$this->title,url=$this->url,author={$this->author->username}}";
return "Response{title=$this->title,url=$this->url,author={$this->author->display_name}}";
}
}

0 comments on commit 32775d3

Please sign in to comment.