Skip to content

Commit

Permalink
fix: Fixed Orbital Discord Notification (#101)
Browse files Browse the repository at this point in the history
* fix: Fixed if Orbital attacker is missing alliance the Discord payload becomes invalid.

* fix: Fixed StructureUnderAttack if missing Alliance
  • Loading branch information
moppa authored Sep 5, 2024
1 parent 96ffce2 commit 4d032d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
14 changes: 7 additions & 7 deletions src/Notifications/Structures/Discord/OrbitalAttacked.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
->name
)
);
})
->field(function (DiscordEmbedField $field) {
if (! array_key_exists('aggressorAllianceID', $this->notification->text) || is_null(
$this->notification->text['aggressorAllianceID']
)) {
return;
}
});

if (array_key_exists('aggressorAllianceID', $this->notification->text) && ! is_null(
$this->notification->text['aggressorAllianceID']
)) {
$embed->field(function (DiscordEmbedField $field) {

$field->name('Alliance')
->value(
Expand All @@ -90,6 +89,7 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
)
);
});
}
})
->embed(function (DiscordEmbed $embed) {
$embed->field(function (DiscordEmbedField $field) {
Expand Down
58 changes: 29 additions & 29 deletions src/Notifications/Structures/Discord/StructureUnderAttack.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,12 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
$this->notification->text['corpName']
)
);
})
->field(function (DiscordEmbedField $field) {
if (! array_key_exists('allianceID', $this->notification->text) || is_null(
$this->notification->text['allianceID']
)) {
return;
}
});

if (array_key_exists('aggressorAllianceID', $this->notification->text) && ! is_null(
$this->notification->text['aggressorAllianceID']
)) {
$embed->field(function (DiscordEmbedField $field) {
$field->name('Alliance')
->value(
$this->zKillBoardToDiscordLink(
Expand All @@ -82,33 +80,35 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
$this->notification->text['allianceName']
)
);
})
->field(function (DiscordEmbedField $field) {
$system = MapDenormalize::find($this->notification->text['solarsystemID']);
});
}

$field->name('System')
->value(
$this->zKillBoardToDiscordLink(
'system',
$system->itemID,
$system->itemName . ' (' . number_format($system->security, 2) . ')'
)
);
})
->field(function (DiscordEmbedField $field) {
$structure = UniverseStructure::find($this->notification->text['structureID']);
$embed->field(function (DiscordEmbedField $field) {
$system = MapDenormalize::find($this->notification->text['solarsystemID']);

$type = InvType::find($this->notification->text['structureShowInfoData'][1]);
$field->name('System')
->value(
$this->zKillBoardToDiscordLink(
'system',
$system->itemID,
$system->itemName . ' (' . number_format($system->security, 2) . ')'
)
);
})
->field(function (DiscordEmbedField $field) {
$structure = UniverseStructure::find($this->notification->text['structureID']);

$title = 'Structure';
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);

if (! is_null($structure)) {
$title = $structure->name;
}
$title = 'Structure';

$field->name($title)
->value($type->typeName);
});
if (! is_null($structure)) {
$title = $structure->name;
}

$field->name($title)
->value($type->typeName);
});
})
->embed(function (DiscordEmbed $embed) {
$embed->field(function (DiscordEmbedField $field) {
Expand Down

0 comments on commit 4d032d7

Please sign in to comment.