Skip to content

Commit

Permalink
Add structure notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Sep 4, 2024
1 parent 0f43052 commit 5af2717
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/evebuddy/FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Website = "https://github.com/ErikKalkoken/evebuddy"
Icon = "icon.png"
Name = "EVE Buddy"
ID = "io.github.erikkalkoken.evebuddy"
Version = "0.1.0"
Version = "0.1.1"
Build = 1

[Release]
Expand Down
1 change: 1 addition & 0 deletions internal/app/evenotification/evenotification.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *EveNotificationService) RenderESI(ctx context.Context, type_, text stri
StructureDestroyed,
StructureFuelAlert,
StructureImpendingAbandonmentAssetsAtRisk,
StructureItemsMovedToSafety,
StructureLostArmor,
StructureLostShields,
StructureOnline,
Expand Down
1 change: 1 addition & 0 deletions internal/app/evenotification/evenotification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestRenderAllCharacterNotifications(t *testing.T) {
factory.CreateEveEntityInventoryType(app.EveEntity{ID: 46303})
factory.CreateEveEntityInventoryType(app.EveEntity{ID: 35894})
factory.CreateEveEntityInventoryType(app.EveEntity{ID: 35835})
factory.CreateEveEntity(app.EveEntity{ID: 60003760, Category: app.EveEntityStation})
notifTypes := set.NewFromSlice(evenotification.SupportedTypes())
typeTested := make(map[evenotification.Type]bool)
for _, n := range notifications {
Expand Down
14 changes: 14 additions & 0 deletions internal/app/evenotification/notification2/notificationtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ type StructureImpendingAbandonmentAssetsAtRisk struct {
StructureTypeID int32 `yaml:"structureTypeID"`
}

type StructureItemsMovedToSafety struct {
AssetSafetyDurationFull int64 `yaml:"assetSafetyDurationFull"`
AssetSafetyDurationMinimum int64 `yaml:"assetSafetyDurationMinimum"`
AssetSafetyFullTimestamp int64 `yaml:"assetSafetyFullTimestamp"`
AssetSafetyMinimumTimestamp int64 `yaml:"assetSafetyMinimumTimestamp"`
IsCorpOwned bool `yaml:"isCorpOwned"`
NewStationID int32 `yaml:"newStationID"`
SolarSystemID int32 `yaml:"solarsystemID"`
StructureID int64 `yaml:"structureID"`
StructureLink string `yaml:"structureLink"`
StructureShowInfoData []any `yaml:"structureShowInfoData"`
StructureTypeID int32 `yaml:"structureTypeID"`
}

type WarAdopted struct {
AgainstID int32 `yaml:"againstID"`
AllianceID int32 `yaml:"allianceID"`
Expand Down
31 changes: 31 additions & 0 deletions internal/app/evenotification/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func (s *EveNotificationService) renderStructure(ctx context.Context, type_ Type
return s.renderStructureFuelAlert(ctx, text)
case StructureImpendingAbandonmentAssetsAtRisk:
return s.renderStructureImpendingAbandonmentAssetsAtRisk(ctx, text)
case StructureItemsMovedToSafety:
return s.renderStructureItemsMovedToSafety(ctx, text)
case StructureLostArmor:
return s.renderStructureLostArmor(ctx, text)
case StructureLostShields:
Expand Down Expand Up @@ -193,6 +195,35 @@ func (s *EveNotificationService) renderStructureImpendingAbandonmentAssetsAtRisk
return title, body, nil
}

func (s *EveNotificationService) renderStructureItemsMovedToSafety(ctx context.Context, text string) (optional.Optional[string], optional.Optional[string], error) {
var title, body optional.Optional[string]
var data notification2.StructureItemsMovedToSafety
if err := yaml.Unmarshal([]byte(text), &data); err != nil {
return title, body, err
}
solarSystem, err := s.EveUniverseService.GetOrCreateEveSolarSystemESI(ctx, data.SolarSystemID)
if err != nil {
return title, body, err
}
station, err := s.EveUniverseService.GetOrCreateEveEntityESI(ctx, data.NewStationID)
if err != nil {
return title, body, err
}
name := evehtml.Strip(data.StructureLink)
title.Set(fmt.Sprintf("Your assets located in %s have been moved to asset safety", name))
body.Set(fmt.Sprintf(
"You assets located at **%s** in %s have been moved to asset safety.\n\n"+
"They can be moved to a location of your choosing earliest at %s.\n\n"+
"They will be moved automatically to %s by %s.",
name,
makeLocationLink(solarSystem),
fromLDAPTime(data.AssetSafetyMinimumTimestamp).Format(app.TimeDefaultFormat),
station.Name,
fromLDAPTime(data.AssetSafetyFullTimestamp).Format(app.TimeDefaultFormat),
))
return title, body, nil
}

func (s *EveNotificationService) renderStructureLostArmor(ctx context.Context, text string) (optional.Optional[string], optional.Optional[string], error) {
var title, body optional.Optional[string]
var data notification.StructureLostArmor
Expand Down
8 changes: 8 additions & 0 deletions internal/app/evenotification/testdata/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@
"timestamp": "2019-08-16T14:08:00Z",
"text": "daysUntilAbandon: 2\nisCorpOwned: true\nsolarsystemID: 30002537\nstructureID: &id001 1000000000001\nstructureLink: <a href=\"showinfo:35835//1000000000001\">Amamake - Alpha</a>\nstructureShowInfoData:\n- showinfo\n- 35835\n- *id001\nstructureTypeID: 35835"
},
{
"notification_id": 1000000517,
"type": "StructureItemsMovedToSafety",
"sender_id": 2901,
"sender_type": "corporation",
"timestamp": "2019-08-16T14:08:00Z",
"text": "assetSafetyDurationFull: 17280000000000\nassetSafetyDurationMinimum: 4320000000000\nassetSafetyFullTimestamp: 133575078174301831\nassetSafetyMinimumTimestamp: 133562118174301831\nisCorpOwned: false\nnewStationID: 60003760\nsolarsystemID: 30002537\nstructureID: &id001 1000000000001\nstructureLink: <a href=\"showinfo:35835//1035811287521\">Amamake - Alpha</a>\nstructureShowInfoData:\n- showinfo\n- 35835\n- *id001\nstructureTypeID: 35835"
},
{
"notification_id": 1000000601,
"type": "OrbitalAttacked",
Expand Down
3 changes: 2 additions & 1 deletion internal/app/evenotification/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ var supportedTypes = []Type{
StructureAnchoring,
StructureDestroyed,
StructureFuelAlert,
StructureImpendingAbandonmentAssetsAtRisk,
StructureItemsMovedToSafety,
StructureLostArmor,
StructureLostShields,
StructureImpendingAbandonmentAssetsAtRisk,
StructureOnline,
StructureServicesOffline,
StructuresReinforcementChanged,
Expand Down
4 changes: 2 additions & 2 deletions internal/app/ui/settingswindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ func (w *settingsWindow) makeNotificationPage() fyne.CanvasObject {
content.Add(form)
content.Add(container.NewPadded())

selectAll := widget.NewButton("Select All", func() {
selectAll := widget.NewButton("Enable all communication types", func() {
for _, cg := range groups {
cg.SetSelected(cg.Options)
}
})
unselectAll := widget.NewButton("Unselect All", func() {
unselectAll := widget.NewButton("Disable all communication types", func() {
for _, cg := range groups {
cg.SetSelected([]string{})
}
Expand Down

0 comments on commit 5af2717

Please sign in to comment.