Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): Add welcome message #87

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ public function getOrCreateUser(string $slackUserId): ?User
],
]);

return $this->Users->saveOrFail($user);
$user = $this->Users->saveOrFail($user);

$this->sendWelcomeNotification($user);

return $user;
}

/**
* @param \App\Model\Entity\User $user The user.
* @return void
*/
protected function sendWelcomeNotification(User $user): void
{
$welcomeMessage = 'Hello there 👋' . PHP_EOL;
$welcomeMessage .= PHP_EOL;
$welcomeMessage .= '*Welcome to GibPotato!*' . PHP_EOL;
$welcomeMessage .= PHP_EOL;
$welcomeMessage .= ' - Every day, you get five 🥔' . PHP_EOL;
$welcomeMessage .= ' - You can gib them to people as a token of appreciation.'
. 'Simply @ mention them and add a 🥔 to your message.' . PHP_EOL;
$welcomeMessage .= ' - Alternatively, you can also react to a message with a 🥔. '
. 'They either go to the people mentioned in the message or, '
- 'if nobody was mentioned, to the author of the message.' . PHP_EOL;
$welcomeMessage .= PHP_EOL;
$welcomeMessage .= 'Hope you\'ll enjoy using GibPotato. '
. 'Make sure to join <#' . env('POTATO_CHANNEL') . '> as well.';

$this->slackClient->postMessage(
channel: $user->slack_user_id,
text: $welcomeMessage,
);
}
}