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

Discord notification fixes #83

Merged
merged 46 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
02212af
feat: implement discord driver
warlof Nov 22, 2020
dc8592b
feat(notifications): implement discord notifications
warlof Nov 22, 2020
faefe0e
fix(l18n): add missing captions
warlof Nov 22, 2020
d6d6e2c
style(ci): apply change requests
warlof Nov 22, 2020
9376ddc
feat: use the new composer way to get installed version
warlof Nov 29, 2020
d0d810b
fix: prevent concurrent notifications to be dispatched
warlof Dec 6, 2020
b619abb
use rate limiting for contracts
recursivetree Apr 6, 2023
268c121
Merge remote-tracking branch 'upstream/5.0.x' into 5.0.x
recursivetree Apr 11, 2023
9552fd1
Merge remote-tracking branch 'upstream/5.0.x' into 5.0.x
recursivetree Apr 16, 2023
dfafe3b
Merge branch 'discord' into native-discord-5.0.x
recursivetree Jun 24, 2023
5631497
fix merge conflicts
recursivetree Jun 24, 2023
d7d89fe
refactor: remove AbstractsCharacterNotification
recursivetree Jun 24, 2023
60f3589
fix routes
recursivetree Jun 24, 2023
e45ba98
add test notification
recursivetree Jun 24, 2023
643fb83
styleci
recursivetree Jun 24, 2023
8ea79a0
message refactor infrastructure
recursivetree Jun 24, 2023
dc3c8bc
refactor to allow ping injection
recursivetree Jun 24, 2023
a32661f
move via() to AbstractXNotification
recursivetree Jun 24, 2023
0a7ce34
more styleci
recursivetree Jun 24, 2023
9ad1215
remove deprecated, unused notifications
recursivetree Jun 24, 2023
2d2f419
add populateMessage support for mail+slack
recursivetree Jun 24, 2023
f0a6a3c
mentions ui+model
recursivetree Jun 24, 2023
b0a864b
add discord ping types
recursivetree Jun 24, 2023
24b522d
introduce notification dispatch trait
recursivetree Jun 24, 2023
b1bf05e
more work on pings
recursivetree Jun 24, 2023
2fdff54
fix annoying things
recursivetree Jun 24, 2023
b70f9f4
connect mentions with discord
recursivetree Jun 24, 2023
3996781
fix routes
recursivetree Jun 24, 2023
5d1b473
add missing imports
recursivetree Jun 24, 2023
29cfdde
styleci
recursivetree Jun 24, 2023
71cc11e
remove debugging logger
recursivetree Jun 24, 2023
2dba086
Apply suggestions from code review
recursivetree Jun 25, 2023
7049a4c
styleci
recursivetree Jun 25, 2023
4ccd4f9
fix CorpAppNewMsg
recursivetree Jul 1, 2023
40e64ed
refactor name->label
recursivetree Jul 1, 2023
50d5921
fix null issue
recursivetree Jul 1, 2023
8cc45c0
fix embed fields
recursivetree Jul 1, 2023
d432899
fix timestamp conversion
recursivetree Jul 1, 2023
be5985d
fix job bugs
recursivetree Jul 1, 2023
0fc5d2b
Merge remote-tracking branch 'upstream/5.0.x' into 5.0.x
recursivetree Jul 1, 2023
f13928e
Merge branch '5.0.x' into clean-discord-fixes
recursivetree Jul 1, 2023
b6eab19
Revert "fix timestamp conversion"
recursivetree Jul 1, 2023
4c76d44
styleci
recursivetree Jul 1, 2023
47319c0
improve error handling
recursivetree Jul 2, 2023
9edfc21
remove null check
recursivetree Jul 2, 2023
9014c81
styleci
recursivetree Jul 2, 2023
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
13 changes: 6 additions & 7 deletions src/Jobs/AbstractNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Seat\Notifications\Jobs;

use DateTime;
use Illuminate\Queue\SerializesModels;

/**
Expand All @@ -38,13 +39,6 @@ abstract class AbstractNotification extends AbstractNotificationJob
*/
public $queue = 'notifications';

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 2;

public $mentions;

/**
Expand All @@ -55,6 +49,11 @@ abstract class AbstractNotification extends AbstractNotificationJob
*/
abstract public function via($notifiable);

public function retryUntil(): DateTime
{
return now()->addMinutes(10);
}

/**
* @return mixed
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/AbstractNotificationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function failed(Exception $exception)
->set('exf', 1)))->onQueue('default');

logger()->error(
sprintf('[Jobs][Notifications][%s] An error occurred while processing notification:', $this->job->getJobId()),
sprintf('[Jobs][Notifications][%s] An error occurred while processing notification:', $this->job?->getJobId()),
[
'error' => $exception->getMessage(),
'trace' => $exception->getTrace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('Capital has been modified! :white_sun_small_cloud:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamps);
$embed->timestamp(carbon($this->notification->timestamps));
$embed->author('SeAT Alliance Weather', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
6 changes: 3 additions & 3 deletions src/Notifications/Characters/Discord/Killmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class Killmail extends AbstractDiscordNotification
use NotificationTools;

/**
* @var \Seat\Eveapi\Models\Killmails\KillmailDetail
* @var KillmailDetail
*/
private $killmail;
private KillmailDetail $killmail;

/**
* Killmail constructor.
*
* @param \Seat\Eveapi\Models\Killmails\KillmailDetail $killmail
* @param KillmailDetail $killmail
*/
public function __construct(KillmailDetail $killmail)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A bill has been honored!')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT Corporation Accountant', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Corporations/Discord/CharLeftCorpMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A character has left corporation!')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author(
'SeAT Corporation Supervisor',
asset('web/img/favico/apple-icon-180x180.png'),
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Corporations/Discord/CorpAllBillMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A new corporation bill has been issued!')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT Corporation Accountant', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A sovereignty structure has been destroyed! :skull:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT Sovereignty Health', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A sovereignty structure has been reinforced! :broken_heart:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT Sovereignty Health', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Wars/Discord/AllWarDeclaredMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A new War has been declared ! :boom:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->color($this->notification->text['hostileState'] ? 13632027 : 16098851);
$embed->author('SeAT War Observer', asset('web/img/favico/apple-icon-180x180.png'));

Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Wars/Discord/AllWarInvalidatedMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A war has been invalidated! :boom:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT War Observer', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A new member has been enroll in a war! :boom:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT War Observer', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/Wars/Discord/AllyJoinedWarAllyMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A new member has been enroll in a war! :boom:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
$embed->author('SeAT War Observer', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
$message
->content('A new member has been enroll in a war! :boom:')
->embed(function (DiscordEmbed $embed) {
$embed->timestamp($this->notification->timestamp);
$embed->timestamp(carbon($this->notification->timestamp));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about casting the field with carbon in the model instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do that? If so, it's probably a good idea

$embed->author('SeAT War Observer', asset('web/img/favico/apple-icon-180x180.png'));

$embed->field(function (DiscordEmbedField $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Discord/Channels/DiscordWebhookChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function fields(DiscordEmbed $embed)
return $value->toArray();

return [
'title' => $title,
'name' => $title,
'value' => $value,
'inline' => true,
];
Expand Down