Skip to content

Commit

Permalink
Added missing Structure name. (#106)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MattFalahe authored Oct 25, 2024
1 parent ab52490 commit 93988d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Notifications/Corporations/Discord/CorpAppNewMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function populateMessage(DiscordMessage $message, $notifiable)

$embed->field(function (DiscordEmbedField $field) {
$field
->name('Character Name')
->name('Corporation Name')
->long();

$entity = UniverseName::find($this->notification->text['corpID']);
Expand Down
21 changes: 19 additions & 2 deletions src/Notifications/Structures/Discord/StructureFuelAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Seat\Eveapi\Models\Character\CharacterNotification;
use Seat\Eveapi\Models\Sde\InvType;
use Seat\Eveapi\Models\Sde\MapDenormalize;
use Seat\Eveapi\Models\Universe\UniverseStructure;
use Seat\Notifications\Notifications\AbstractDiscordNotification;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbed;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbedField;
Expand Down Expand Up @@ -70,10 +71,26 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
});

$embed->field(function (DiscordEmbedField $field) {
// Find the structure by its ID from the notification data.
// If the structure ID exists in the notification, retrieve it from the UniverseStructure model.
$structure = UniverseStructure::find($this->notification->text['structureID']);

// Retrieve the structure's type information using the structureShowInfoData from the notification.
// The second index ([1]) contains the type ID which is used to look up the structure type from the InvType model.
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);

$field->name('Structure')
->value($type->typeName);
// Initialize a default title for the structure field as 'Structure'.
$title = 'Structure';

// If a structure is found (i.e., it's not null), set the title to the name of the structure.
if (! is_null($structure)) {
$title = $structure->name;
}

// Set the field's name to the title (either 'Structure' or the structure's actual name).
// Set the field's value to a zKillboard link, formatted for Discord. This uses the structure's type ID and name.
$field->name($title)
->value($this->zKillBoardToDiscordLink('ship', $type->typeID, $type->typeName));
});
})
->embed(function (DiscordEmbed $embed) {
Expand Down
24 changes: 19 additions & 5 deletions src/Notifications/Structures/Discord/StructureWentHighPower.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Seat\Eveapi\Models\Character\CharacterNotification;
use Seat\Eveapi\Models\Sde\InvType;
use Seat\Eveapi\Models\Sde\MapDenormalize;
use Seat\Eveapi\Models\Universe\UniverseStructure;
use Seat\Notifications\Notifications\AbstractDiscordNotification;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbed;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbedField;
Expand Down Expand Up @@ -74,12 +75,25 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
});

$embed->field(function (DiscordEmbedField $field) {
$type = InvType::firstOrNew(
['typeID' => $this->notification->text['structureTypeID']],
['typeName' => trans('web::seat.unknown')]
);
// Find the structure by its ID from the notification data.
// If the structure ID exists in the notification, retrieve it from the UniverseStructure model.
$structure = UniverseStructure::find($this->notification->text['structureID']);

// Retrieve the structure's type information using the structureShowInfoData from the notification.
// The second index ([1]) contains the type ID which is used to look up the structure type from the InvType model.
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);

// Initialize a default title for the structure field as 'Structure'.
$title = 'Structure';

// If a structure is found (i.e., it's not null), set the title to the name of the structure.
if (! is_null($structure)) {
$title = $structure->name;
}

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

0 comments on commit 93988d2

Please sign in to comment.