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

ref(backend): Migrate shop message to blocks #108

Merged
merged 1 commit into from
Sep 5, 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
55 changes: 46 additions & 9 deletions src/Controller/Api/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,55 @@
$productsTable->saveOrFail($product);

if ($presentee !== null) {
$message = '<@' . $user->slack_user_id . '> did buy a nice little present for '
. '<@' . $presentee->slack_user_id . '> 🎁😊' . PHP_EOL;
$message .= PHP_EOL;
$message .= 'They got them *<' . Router::url(str_replace('.svg', '.png', $product->image_link), true)
. '|' . $product->name . '. >* 🚀' . PHP_EOL;
$message .= PHP_EOL;
$message .= '_"' . $this->request->getData('message') . '"_' . PHP_EOL;
$blocks = [
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "<@{$user->slack_user_id}> did buy a nice little present for "
. "<@{$presentee->slack_user_id}> 🎁😊",
],
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "They got them *{$product->name}* 🚀",
],
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => "_{$this->request->getData('message')}_",
],
],
[
'type' => 'divider',
],
[
'type' => 'section',
'text' => [
'type' => 'mrkdwn',
'text' => '<' . Router::url('/shop', true) . '|Gib a present to a fellow Sentaur yourself!>',
],
],
[
'type' => 'image',
'image_url' => Router::url(str_replace('.svg', '.png', $product->image_link), true),
'alt_text' => $product->name,
'title' => [
'type' => 'plain_text',
'text' => $product->name,
],
],

Check warning on line 159 in src/Controller/Api/ShopController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/Api/ShopController.php#L118-L159

Added lines #L118 - L159 were not covered by tests

];

Check warning on line 161 in src/Controller/Api/ShopController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/Api/ShopController.php#L161

Added line #L161 was not covered by tests

$slackClient = new SlackClient();
$slackClient->postMessage(
$slackClient->postBlocks(

Check warning on line 164 in src/Controller/Api/ShopController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/Api/ShopController.php#L164

Added line #L164 was not covered by tests
channel: env('POTATO_CHANNEL'),
text: $message,
blocks: json_encode($blocks),

Check warning on line 166 in src/Controller/Api/ShopController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/Api/ShopController.php#L166

Added line #L166 was not covered by tests
);
}

Expand Down
Loading