Skip to content

Commit 93988d2

Browse files
authored
Added missing Structure name. (#106)
* CorpAppNewMsg.php * Update StructureWentLowPower.php Added information with structure name Update StructureWentLowPower.php StructureWentLowPower.php Update StructureWentLowPower.php StructureWentLowPower.php StructureWentLowPower.php StructureWentLowPower.php * StructureLostShields.php Added message with structure name Update StructureLostShields.php StructureLostShields.php StructureLostShields.php StructureLostShields.php StructureLostShields.php * StructureLostArmor.php Added information with structure name Update StructureLostArmor.php StructureLostArmor.php StructureLostArmor.php StructureLostArmor.php StructureLostArmor.php * StructureFuelAlert.php squash StructureFuelAlert.php squash StyleCI StructureFuelAlert.php StructureFuelAlert.php null added StructureFuelAlert.php StructureFuelAlert.php Update StructureFuelAlert.php Added information name of the structure that is running low on fuel. * StructureWentHighPower.php squash StructureWentHighPower.php squash StyleCI StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php StructureWentHighPower.php Added information with structure name
1 parent ab52490 commit 93988d2

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

src/Notifications/Corporations/Discord/CorpAppNewMsg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)
7373

7474
$embed->field(function (DiscordEmbedField $field) {
7575
$field
76-
->name('Character Name')
76+
->name('Corporation Name')
7777
->long();
7878

7979
$entity = UniverseName::find($this->notification->text['corpID']);

src/Notifications/Structures/Discord/StructureFuelAlert.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Seat\Eveapi\Models\Character\CharacterNotification;
2626
use Seat\Eveapi\Models\Sde\InvType;
2727
use Seat\Eveapi\Models\Sde\MapDenormalize;
28+
use Seat\Eveapi\Models\Universe\UniverseStructure;
2829
use Seat\Notifications\Notifications\AbstractDiscordNotification;
2930
use Seat\Notifications\Services\Discord\Messages\DiscordEmbed;
3031
use Seat\Notifications\Services\Discord\Messages\DiscordEmbedField;
@@ -70,10 +71,26 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
7071
});
7172

7273
$embed->field(function (DiscordEmbedField $field) {
74+
// Find the structure by its ID from the notification data.
75+
// If the structure ID exists in the notification, retrieve it from the UniverseStructure model.
76+
$structure = UniverseStructure::find($this->notification->text['structureID']);
77+
78+
// Retrieve the structure's type information using the structureShowInfoData from the notification.
79+
// The second index ([1]) contains the type ID which is used to look up the structure type from the InvType model.
7380
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);
7481

75-
$field->name('Structure')
76-
->value($type->typeName);
82+
// Initialize a default title for the structure field as 'Structure'.
83+
$title = 'Structure';
84+
85+
// If a structure is found (i.e., it's not null), set the title to the name of the structure.
86+
if (! is_null($structure)) {
87+
$title = $structure->name;
88+
}
89+
90+
// Set the field's name to the title (either 'Structure' or the structure's actual name).
91+
// Set the field's value to a zKillboard link, formatted for Discord. This uses the structure's type ID and name.
92+
$field->name($title)
93+
->value($this->zKillBoardToDiscordLink('ship', $type->typeID, $type->typeName));
7794
});
7895
})
7996
->embed(function (DiscordEmbed $embed) {

src/Notifications/Structures/Discord/StructureWentHighPower.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Seat\Eveapi\Models\Character\CharacterNotification;
2626
use Seat\Eveapi\Models\Sde\InvType;
2727
use Seat\Eveapi\Models\Sde\MapDenormalize;
28+
use Seat\Eveapi\Models\Universe\UniverseStructure;
2829
use Seat\Notifications\Notifications\AbstractDiscordNotification;
2930
use Seat\Notifications\Services\Discord\Messages\DiscordEmbed;
3031
use Seat\Notifications\Services\Discord\Messages\DiscordEmbedField;
@@ -74,12 +75,25 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
7475
});
7576

7677
$embed->field(function (DiscordEmbedField $field) {
77-
$type = InvType::firstOrNew(
78-
['typeID' => $this->notification->text['structureTypeID']],
79-
['typeName' => trans('web::seat.unknown')]
80-
);
78+
// Find the structure by its ID from the notification data.
79+
// If the structure ID exists in the notification, retrieve it from the UniverseStructure model.
80+
$structure = UniverseStructure::find($this->notification->text['structureID']);
81+
82+
// Retrieve the structure's type information using the structureShowInfoData from the notification.
83+
// The second index ([1]) contains the type ID which is used to look up the structure type from the InvType model.
84+
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);
85+
86+
// Initialize a default title for the structure field as 'Structure'.
87+
$title = 'Structure';
88+
89+
// If a structure is found (i.e., it's not null), set the title to the name of the structure.
90+
if (! is_null($structure)) {
91+
$title = $structure->name;
92+
}
8193

82-
$field->name('Structure')
94+
// Set the field's name to the title (either 'Structure' or the structure's actual name).
95+
// Set the field's value to a zKillboard link, formatted for Discord. This uses the structure's type ID and name.
96+
$field->name($title)
8397
->value($this->zKillBoardToDiscordLink('ship', $type->typeID, $type->typeName));
8498
});
8599
});

0 commit comments

Comments
 (0)