aa-structures 2.11.0__py3-none-any.whl → 2.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,12 @@ class NotificationType(models.TextChoices):
23
23
  )
24
24
  STRUCTURE_LOST_ARMOR = "StructureLostArmor", _("Upwell structure lost armor")
25
25
  STRUCTURE_LOST_SHIELD = "StructureLostShields", _("Upwell structure lost shields")
26
+ STRUCTURE_LOW_REAGENTS_ALERT = "StructureLowReagentsAlert", _(
27
+ "Structure low reagents alert"
28
+ )
29
+ STRUCTURE_NO_REAGENTS_ALERT = "StructureNoReagentsAlert", _(
30
+ "Structure no reagents alert"
31
+ )
26
32
  STRUCTURE_ONLINE = "StructureOnline", _("Upwell structure went online")
27
33
  STRUCTURE_REFUELED_EXTRA = "StructureRefueledExtra", _("Upwell structure refueled")
28
34
  STRUCTURE_REINFORCEMENT_CHANGED = "StructuresReinforcementChanged", _(
@@ -42,15 +48,22 @@ class NotificationType(models.TextChoices):
42
48
  "Upwell structure went low power"
43
49
  )
44
50
 
51
+ # Skyhook structures
52
+ SKYHOOK_DEPLOYED = "SkyhookDeployed", _("Skyhook deployed")
53
+ SKYHOOK_DESTROYED = "SkyhookDestroyed", _("Skyhook destroyed")
54
+ SKYHOOK_LOST_SHIELDS = "SkyhookLostShields", _("Skyhook lost shields")
55
+ SKYHOOK_ONLINE = "SkyhookOnline", _("Skyhook online")
56
+ SKYHOOK_UNDER_ATTACK = "SkyhookUnderAttack", _("Skyhook under attack")
57
+
45
58
  # customs offices
46
59
  ORBITAL_ATTACKED = "OrbitalAttacked", _("Customs office attacked")
47
60
  ORBITAL_REINFORCED = "OrbitalReinforced", _("Customs office reinforced")
48
61
 
49
62
  # starbases
50
63
  TOWER_ALERT_MSG = "TowerAlertMsg", _("Starbase attacked")
51
- TOWER_RESOURCE_ALERT_MSG = "TowerResourceAlertMsg", _("Starbase fuel alert")
52
64
  TOWER_REFUELED_EXTRA = "TowerRefueledExtra", _("Starbase refueled (BETA)")
53
65
  TOWER_REINFORCED_EXTRA = "TowerReinforcedExtra", _("Starbase reinforced (BETA)")
66
+ TOWER_RESOURCE_ALERT_MSG = "TowerResourceAlertMsg", _("Starbase fuel alert")
54
67
 
55
68
  # moon mining
56
69
  MOONMINING_AUTOMATIC_FRACTURE = "MoonminingAutomaticFracture", _(
@@ -121,7 +134,7 @@ class NotificationType(models.TextChoices):
121
134
  )
122
135
  WAR_OFFERED_SURRENDER = "OfferedSurrender", _("War offered surrender")
123
136
  WAR_OFFERED_TO_ALLY = "OfferedToAlly", _("War offered to become ally")
124
- WAR_WAR_ADOPTED = "WarAdopted", _("War adopted")
137
+ WAR_WAR_ADOPTED = "WarAdopted", _("War adopted") # FIXME: Should be "WarAdopted "
125
138
  WAR_WAR_DECLARED = "WarDeclared", _("War declared")
126
139
  WAR_WAR_INHERITED = "WarInherited", _("War inherited")
127
140
  WAR_WAR_RETRACTED_BY_CONCORD = "WarRetractedByConcord", _(
@@ -143,8 +156,8 @@ class NotificationType(models.TextChoices):
143
156
  CHAR_LEFT_CORP_MSG = "CharLeftCorpMsg", _("Character leaves corporation")
144
157
 
145
158
  # billing
146
- BILLING_CORP_ALL_BILL_MSG = "CorpAllBillMsg", _("Corp alliance billing message")
147
159
  BILLING_BILL_OUT_OF_MONEY_MSG = "BillOutOfMoneyMsg", _("Bill out of money")
160
+ BILLING_CORP_ALL_BILL_MSG = "CorpAllBillMsg", _("Corp alliance billing message")
148
161
  BILLING_I_HUB_BILL_ABOUT_TO_EXPIRE = (
149
162
  "InfrastructureHubBillAboutToExpire",
150
163
  _("I-HUB bill about to expire"),
@@ -173,34 +186,40 @@ class NotificationType(models.TextChoices):
173
186
  def webhook_defaults(cls) -> List["NotificationType"]:
174
187
  """List of default notifications for new webhooks."""
175
188
  return [
189
+ cls.ORBITAL_ATTACKED,
190
+ cls.ORBITAL_REINFORCED,
191
+ cls.SKYHOOK_DESTROYED,
192
+ cls.SKYHOOK_LOST_SHIELDS,
193
+ cls.SKYHOOK_ONLINE,
194
+ cls.SKYHOOK_UNDER_ATTACK,
195
+ cls.SOV_STRUCTURE_DESTROYED,
196
+ cls.SOV_STRUCTURE_REINFORCED,
176
197
  cls.STRUCTURE_ANCHORING,
177
198
  cls.STRUCTURE_DESTROYED,
178
199
  cls.STRUCTURE_FUEL_ALERT,
179
200
  cls.STRUCTURE_LOST_ARMOR,
180
201
  cls.STRUCTURE_LOST_SHIELD,
202
+ cls.STRUCTURE_LOW_REAGENTS_ALERT,
203
+ cls.STRUCTURE_NO_REAGENTS_ALERT,
181
204
  cls.STRUCTURE_ONLINE,
182
205
  cls.STRUCTURE_SERVICES_OFFLINE,
183
206
  cls.STRUCTURE_UNDER_ATTACK,
184
207
  cls.STRUCTURE_WENT_HIGH_POWER,
185
208
  cls.STRUCTURE_WENT_LOW_POWER,
186
- cls.ORBITAL_ATTACKED,
187
- cls.ORBITAL_REINFORCED,
188
209
  cls.TOWER_ALERT_MSG,
189
210
  cls.TOWER_RESOURCE_ALERT_MSG,
190
- cls.SOV_STRUCTURE_REINFORCED,
191
- cls.SOV_STRUCTURE_DESTROYED,
192
211
  ]
193
212
 
194
213
  @classmethod
195
214
  def relevant_for_timerboard(cls) -> Set["NotificationType"]:
196
215
  """Notification types that can create timers."""
197
216
  return {
198
- cls.STRUCTURE_LOST_SHIELD,
199
- cls.STRUCTURE_LOST_ARMOR,
200
- cls.ORBITAL_REINFORCED,
201
- cls.MOONMINING_EXTRACTION_STARTED,
202
217
  cls.MOONMINING_EXTRACTION_CANCELLED,
218
+ cls.MOONMINING_EXTRACTION_STARTED,
219
+ cls.ORBITAL_REINFORCED,
203
220
  cls.SOV_STRUCTURE_REINFORCED,
221
+ cls.STRUCTURE_LOST_ARMOR,
222
+ cls.STRUCTURE_LOST_SHIELD,
204
223
  cls.TOWER_REINFORCED_EXTRA,
205
224
  }
206
225
 
@@ -210,15 +229,15 @@ class NotificationType(models.TextChoices):
210
229
  return {
211
230
  # billing
212
231
  cls.BILLING_BILL_OUT_OF_MONEY_MSG,
213
- cls.BILLING_I_HUB_DESTROYED_BY_BILL_FAILURE,
214
232
  cls.BILLING_I_HUB_BILL_ABOUT_TO_EXPIRE,
233
+ cls.BILLING_I_HUB_DESTROYED_BY_BILL_FAILURE,
215
234
  # sov
216
- cls.SOV_ENTOSIS_CAPTURE_STARTED,
217
- cls.SOV_COMMAND_NODE_EVENT_STARTED,
218
235
  cls.SOV_ALL_CLAIM_ACQUIRED_MSG,
219
- cls.SOV_STRUCTURE_REINFORCED,
220
- cls.SOV_STRUCTURE_DESTROYED,
221
236
  cls.SOV_ALL_CLAIM_LOST_MSG,
237
+ cls.SOV_COMMAND_NODE_EVENT_STARTED,
238
+ cls.SOV_ENTOSIS_CAPTURE_STARTED,
239
+ cls.SOV_STRUCTURE_DESTROYED,
240
+ cls.SOV_STRUCTURE_REINFORCED,
222
241
  # cls.SOV_ALL_ANCHORING_MSG, # This notif is not broadcasted to all corporations
223
242
  # wars
224
243
  cls.WAR_ALLY_JOINED_WAR_AGGRESSOR_MSG,
@@ -238,43 +257,45 @@ class NotificationType(models.TextChoices):
238
257
  def relevant_for_moonmining(cls) -> Set["NotificationType"]:
239
258
  """Notification types about moon mining."""
240
259
  return {
241
- cls.MOONMINING_EXTRACTION_STARTED,
260
+ cls.MOONMINING_AUTOMATIC_FRACTURE,
242
261
  cls.MOONMINING_EXTRACTION_CANCELLED,
243
- cls.MOONMINING_LASER_FIRED,
244
262
  cls.MOONMINING_EXTRACTION_FINISHED,
245
- cls.MOONMINING_AUTOMATIC_FRACTURE,
263
+ cls.MOONMINING_EXTRACTION_STARTED,
264
+ cls.MOONMINING_LASER_FIRED,
246
265
  }
247
266
 
248
267
  @classmethod
249
268
  def structure_related(cls) -> Set["NotificationType"]:
250
269
  """Notification types that are related to a structure."""
251
270
  return {
252
- cls.STRUCTURE_ONLINE,
271
+ cls.MOONMINING_AUTOMATIC_FRACTURE,
272
+ cls.MOONMINING_EXTRACTION_CANCELLED,
273
+ cls.MOONMINING_EXTRACTION_FINISHED,
274
+ cls.MOONMINING_EXTRACTION_STARTED,
275
+ cls.MOONMINING_LASER_FIRED,
276
+ cls.ORBITAL_ATTACKED,
277
+ cls.ORBITAL_REINFORCED,
278
+ cls.OWNERSHIP_TRANSFERRED,
279
+ cls.STRUCTURE_ANCHORING,
280
+ cls.STRUCTURE_DESTROYED,
253
281
  cls.STRUCTURE_FUEL_ALERT,
254
282
  cls.STRUCTURE_JUMP_FUEL_ALERT,
283
+ cls.STRUCTURE_LOST_ARMOR,
284
+ cls.STRUCTURE_LOST_SHIELD,
285
+ cls.STRUCTURE_LOW_REAGENTS_ALERT,
286
+ cls.STRUCTURE_NO_REAGENTS_ALERT,
287
+ cls.STRUCTURE_ONLINE,
255
288
  cls.STRUCTURE_REFUELED_EXTRA,
289
+ cls.STRUCTURE_REINFORCEMENT_CHANGED,
256
290
  cls.STRUCTURE_SERVICES_OFFLINE,
257
- cls.STRUCTURE_WENT_LOW_POWER,
258
- cls.STRUCTURE_WENT_HIGH_POWER,
259
291
  cls.STRUCTURE_UNANCHORING,
260
292
  cls.STRUCTURE_UNDER_ATTACK,
261
- cls.STRUCTURE_LOST_SHIELD,
262
- cls.STRUCTURE_LOST_ARMOR,
263
- cls.STRUCTURE_DESTROYED,
264
- cls.OWNERSHIP_TRANSFERRED,
265
- cls.STRUCTURE_ANCHORING,
266
- cls.MOONMINING_EXTRACTION_STARTED,
267
- cls.MOONMINING_EXTRACTION_FINISHED,
268
- cls.MOONMINING_AUTOMATIC_FRACTURE,
269
- cls.MOONMINING_EXTRACTION_CANCELLED,
270
- cls.MOONMINING_LASER_FIRED,
271
- cls.STRUCTURE_REINFORCEMENT_CHANGED,
272
- cls.ORBITAL_ATTACKED,
273
- cls.ORBITAL_REINFORCED,
293
+ cls.STRUCTURE_WENT_HIGH_POWER,
294
+ cls.STRUCTURE_WENT_LOW_POWER,
274
295
  cls.TOWER_ALERT_MSG,
275
- cls.TOWER_RESOURCE_ALERT_MSG,
276
296
  cls.TOWER_REFUELED_EXTRA,
277
297
  cls.TOWER_REINFORCED_EXTRA,
298
+ cls.TOWER_RESOURCE_ALERT_MSG,
278
299
  }
279
300
 
280
301
  @classmethod
structures/managers.py CHANGED
@@ -237,7 +237,7 @@ class StructureQuerySet(models.QuerySet):
237
237
 
238
238
  def select_related_defaults(self) -> models.QuerySet:
239
239
  """returns a QuerySet with the default select_related"""
240
- return self.select_related(
240
+ return self.select_related( # pylint: disable=E1102
241
241
  "owner",
242
242
  "owner__corporation",
243
243
  "owner__corporation__alliance",
@@ -383,7 +383,9 @@ class StructureManagerBase(models.Manager):
383
383
  def update_or_create_from_dict(self, structure: dict, owner) -> Tuple[Any, bool]:
384
384
  """update or create structure from given dict"""
385
385
 
386
- eve_type, _ = EveType.objects.get_or_create_esi(id=structure["type_id"])
386
+ eve_type: EveType = EveType.objects.get_or_create_esi(id=structure["type_id"])[
387
+ 0
388
+ ]
387
389
  eve_solar_system, _ = EveSolarSystem.objects.get_or_create_esi(
388
390
  id=structure["system_id"]
389
391
  )
@@ -423,10 +425,11 @@ class StructureManagerBase(models.Manager):
423
425
  if old_obj:
424
426
  obj.handle_fuel_notifications(old_obj)
425
427
 
426
- # Make sure we have dogmas loaded for this type for fittings
427
- EveType.objects.get_or_create_esi(
428
- id=structure["type_id"], enabled_sections=[EveType.Section.DOGMAS]
429
- )
428
+ # Make sure we have dogmas loaded with all upwell structures for fittings
429
+ if eve_type.eve_group.eve_category_id == EveCategoryId.STRUCTURE:
430
+ EveType.objects.get_or_create_esi(
431
+ id=structure["type_id"], enabled_sections=[EveType.Section.DOGMAS]
432
+ )
430
433
 
431
434
  self._save_related_structure_services(structure, obj)
432
435
 
@@ -0,0 +1,149 @@
1
+ # Generated by Django 4.0.10 on 2024-08-19 14:25
2
+
3
+ import multiselectfield.db.fields
4
+
5
+ from django.db import migrations
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ("structures", "0006_add_ownercharacter_disabled"),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.AlterField(
16
+ model_name="webhook",
17
+ name="notification_types",
18
+ field=multiselectfield.db.fields.MultiSelectField(
19
+ choices=[
20
+ ("OwnershipTransferred", "Upwell structure ownership transferred"),
21
+ ("StructureAnchoring", "Upwell structure anchoring"),
22
+ ("StructureDestroyed", "Upwell structure destroyed"),
23
+ ("StructureFuelAlert", "Upwell structure fuel alert"),
24
+ ("StructureJumpFuelAlert", "Upwell structure jump fuel alert"),
25
+ ("StructureLostArmor", "Upwell structure lost armor"),
26
+ ("StructureLostShields", "Upwell structure lost shields"),
27
+ ("StructureLowReagentsAlert", "Structure low reagents alert"),
28
+ ("StructureNoReagentsAlert", "Structure no reagents alert"),
29
+ ("StructureOnline", "Upwell structure went online"),
30
+ ("StructureRefueledExtra", "Upwell structure refueled"),
31
+ (
32
+ "StructuresReinforcementChanged",
33
+ "Upwell structure reinforcement time changed",
34
+ ),
35
+ (
36
+ "StructureServicesOffline",
37
+ "Upwell structure services went offline",
38
+ ),
39
+ ("StructureUnanchoring", "Upwell structure unanchoring"),
40
+ ("StructureUnderAttack", "Upwell structure is under attack"),
41
+ ("StructureWentHighPower", "Upwell structure went high power"),
42
+ ("StructureWentLowPower", "Upwell structure went low power"),
43
+ ("SkyhookDeployed", "Skyhook deployed"),
44
+ ("SkyhookDestroyed", "Skyhook destroyed"),
45
+ ("SkyhookLostShields", "Skyhook lost shields"),
46
+ ("SkyhookOnline", "Skyhook online"),
47
+ ("SkyhookUnderAttack", "Skyhook under attack"),
48
+ ("OrbitalAttacked", "Customs office attacked"),
49
+ ("OrbitalReinforced", "Customs office reinforced"),
50
+ ("TowerAlertMsg", "Starbase attacked"),
51
+ ("TowerRefueledExtra", "Starbase refueled (BETA)"),
52
+ ("TowerReinforcedExtra", "Starbase reinforced (BETA)"),
53
+ ("TowerResourceAlertMsg", "Starbase fuel alert"),
54
+ (
55
+ "MoonminingAutomaticFracture",
56
+ "Moon mining automatic fracture triggered",
57
+ ),
58
+ (
59
+ "MoonminingExtractionCancelled",
60
+ "Moon mining extraction cancelled",
61
+ ),
62
+ ("MoonminingExtractionFinished", "Moon mining extraction finished"),
63
+ ("MoonminingExtractionStarted", "Moon mining extraction started"),
64
+ ("MoonminingLaserFired", "Moonmining laser fired"),
65
+ ("SovAllClaimAquiredMsg", "Sovereignty claim acknowledgment"),
66
+ ("SovAllClaimLostMsg", "Sovereignty lost"),
67
+ ("AllAnchoringMsg", "Structure anchoring in alliance space"),
68
+ ("EntosisCaptureStarted", "Sovereignty entosis capture started"),
69
+ ("SovStructureDestroyed", "Sovereignty structure destroyed"),
70
+ ("SovStructureReinforced", "Sovereignty structure reinforced"),
71
+ (
72
+ "SovCommandNodeEventStarted",
73
+ "Sovereignty command node event started",
74
+ ),
75
+ ("AcceptedAlly", "War accepted ally"),
76
+ (
77
+ "AllWarCorpJoinedAllianceMsg",
78
+ "Alliance war corporation joined alliance message",
79
+ ),
80
+ ("AllWarSurrenderMsg", "Alliance war surrender message"),
81
+ ("AllyJoinedWarAggressorMsg", "War ally joined aggressor"),
82
+ ("AllyJoinedWarAllyMsg", "War ally joined ally"),
83
+ ("AllyJoinedWarDefenderMsg", "War ally joined defender"),
84
+ ("CorpWarSurrenderMsg", "War party surrendered"),
85
+ ("CorpBecameWarEligible", "War corporation became eligible"),
86
+ ("CorpNoLongerWarEligible", "War corporation no longer eligible"),
87
+ ("DeclareWar", "War declared"),
88
+ ("WarHQRemovedFromSpace", "War HQ removed from space"),
89
+ ("WarInvalid", "War invalid"),
90
+ (
91
+ "MercOfferedNegotiationMsg",
92
+ "War mercenary offered negotiation message",
93
+ ),
94
+ ("MercOfferRetractedMsg", "War mercenary offer retracted message"),
95
+ ("OfferedSurrender", "War offered surrender"),
96
+ ("OfferedToAlly", "War offered to become ally"),
97
+ ("WarAdopted ", "War adopted"),
98
+ ("WarDeclared", "War declared"),
99
+ ("WarInherited", "War inherited"),
100
+ ("WarRetractedByConcord", "War retracted by Concord"),
101
+ ("WarSurrenderOfferMsg", "War surrender offered"),
102
+ ("CharAppAcceptMsg", "Character joins corporation"),
103
+ ("CorpAppInvitedMsg", "Character invited to join corporation"),
104
+ ("CorpAppNewMsg", "Character submitted application"),
105
+ ("CharAppRejectMsg", "Corp application rejected message"),
106
+ (
107
+ "CorpAppRejectCustomMsg",
108
+ "Corp application rejected custom message",
109
+ ),
110
+ ("CharAppWithdrawMsg", "Character withdrew application"),
111
+ ("CharLeftCorpMsg", "Character leaves corporation"),
112
+ ("BillOutOfMoneyMsg", "Bill out of money"),
113
+ ("CorpAllBillMsg", "Corp alliance billing message"),
114
+ (
115
+ "InfrastructureHubBillAboutToExpire",
116
+ "I-HUB bill about to expire",
117
+ ),
118
+ ("IHubDestroyedByBillFailure", "I_HUB destroyed by bill failure"),
119
+ ],
120
+ default=[
121
+ "OrbitalAttacked",
122
+ "OrbitalReinforced",
123
+ "SkyhookDestroyed",
124
+ "SkyhookLostShields",
125
+ "SkyhookOnline",
126
+ "SkyhookUnderAttack",
127
+ "SovStructureDestroyed",
128
+ "SovStructureReinforced",
129
+ "StructureAnchoring",
130
+ "StructureDestroyed",
131
+ "StructureFuelAlert",
132
+ "StructureLostArmor",
133
+ "StructureLostShields",
134
+ "StructureLowReagentsAlert",
135
+ "StructureNoReagentsAlert",
136
+ "StructureOnline",
137
+ "StructureServicesOffline",
138
+ "StructureUnderAttack",
139
+ "StructureWentHighPower",
140
+ "StructureWentLowPower",
141
+ "TowerAlertMsg",
142
+ "TowerResourceAlertMsg",
143
+ ],
144
+ help_text="Select which type of notifications should be forwarded to this webhook",
145
+ max_length=1475,
146
+ verbose_name="notification types",
147
+ ),
148
+ ),
149
+ ]
@@ -0,0 +1,149 @@
1
+ # Generated by Django 4.0.10 on 2024-08-19 18:59
2
+
3
+ import multiselectfield.db.fields
4
+
5
+ from django.db import migrations
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ("structures", "0007_add_notificationtypes_skyhook_metenox"),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.AlterField(
16
+ model_name="webhook",
17
+ name="notification_types",
18
+ field=multiselectfield.db.fields.MultiSelectField(
19
+ choices=[
20
+ ("OwnershipTransferred", "Upwell structure ownership transferred"),
21
+ ("StructureAnchoring", "Upwell structure anchoring"),
22
+ ("StructureDestroyed", "Upwell structure destroyed"),
23
+ ("StructureFuelAlert", "Upwell structure fuel alert"),
24
+ ("StructureJumpFuelAlert", "Upwell structure jump fuel alert"),
25
+ ("StructureLostArmor", "Upwell structure lost armor"),
26
+ ("StructureLostShields", "Upwell structure lost shields"),
27
+ ("StructureLowReagentsAlert", "Structure low reagents alert"),
28
+ ("StructureNoReagentsAlert", "Structure no reagents alert"),
29
+ ("StructureOnline", "Upwell structure went online"),
30
+ ("StructureRefueledExtra", "Upwell structure refueled"),
31
+ (
32
+ "StructuresReinforcementChanged",
33
+ "Upwell structure reinforcement time changed",
34
+ ),
35
+ (
36
+ "StructureServicesOffline",
37
+ "Upwell structure services went offline",
38
+ ),
39
+ ("StructureUnanchoring", "Upwell structure unanchoring"),
40
+ ("StructureUnderAttack", "Upwell structure is under attack"),
41
+ ("StructureWentHighPower", "Upwell structure went high power"),
42
+ ("StructureWentLowPower", "Upwell structure went low power"),
43
+ ("SkyhookDeployed", "Skyhook deployed"),
44
+ ("SkyhookDestroyed", "Skyhook destroyed"),
45
+ ("SkyhookLostShields", "Skyhook lost shields"),
46
+ ("SkyhookOnline", "Skyhook online"),
47
+ ("SkyhookUnderAttack", "Skyhook under attack"),
48
+ ("OrbitalAttacked", "Customs office attacked"),
49
+ ("OrbitalReinforced", "Customs office reinforced"),
50
+ ("TowerAlertMsg", "Starbase attacked"),
51
+ ("TowerRefueledExtra", "Starbase refueled (BETA)"),
52
+ ("TowerReinforcedExtra", "Starbase reinforced (BETA)"),
53
+ ("TowerResourceAlertMsg", "Starbase fuel alert"),
54
+ (
55
+ "MoonminingAutomaticFracture",
56
+ "Moon mining automatic fracture triggered",
57
+ ),
58
+ (
59
+ "MoonminingExtractionCancelled",
60
+ "Moon mining extraction cancelled",
61
+ ),
62
+ ("MoonminingExtractionFinished", "Moon mining extraction finished"),
63
+ ("MoonminingExtractionStarted", "Moon mining extraction started"),
64
+ ("MoonminingLaserFired", "Moonmining laser fired"),
65
+ ("SovAllClaimAquiredMsg", "Sovereignty claim acknowledgment"),
66
+ ("SovAllClaimLostMsg", "Sovereignty lost"),
67
+ ("AllAnchoringMsg", "Structure anchoring in alliance space"),
68
+ ("EntosisCaptureStarted", "Sovereignty entosis capture started"),
69
+ ("SovStructureDestroyed", "Sovereignty structure destroyed"),
70
+ ("SovStructureReinforced", "Sovereignty structure reinforced"),
71
+ (
72
+ "SovCommandNodeEventStarted",
73
+ "Sovereignty command node event started",
74
+ ),
75
+ ("AcceptedAlly", "War accepted ally"),
76
+ (
77
+ "AllWarCorpJoinedAllianceMsg",
78
+ "Alliance war corporation joined alliance message",
79
+ ),
80
+ ("AllWarSurrenderMsg", "Alliance war surrender message"),
81
+ ("AllyJoinedWarAggressorMsg", "War ally joined aggressor"),
82
+ ("AllyJoinedWarAllyMsg", "War ally joined ally"),
83
+ ("AllyJoinedWarDefenderMsg", "War ally joined defender"),
84
+ ("CorpWarSurrenderMsg", "War party surrendered"),
85
+ ("CorpBecameWarEligible", "War corporation became eligible"),
86
+ ("CorpNoLongerWarEligible", "War corporation no longer eligible"),
87
+ ("DeclareWar", "War declared"),
88
+ ("WarHQRemovedFromSpace", "War HQ removed from space"),
89
+ ("WarInvalid", "War invalid"),
90
+ (
91
+ "MercOfferedNegotiationMsg",
92
+ "War mercenary offered negotiation message",
93
+ ),
94
+ ("MercOfferRetractedMsg", "War mercenary offer retracted message"),
95
+ ("OfferedSurrender", "War offered surrender"),
96
+ ("OfferedToAlly", "War offered to become ally"),
97
+ ("WarAdopted", "War adopted"),
98
+ ("WarDeclared", "War declared"),
99
+ ("WarInherited", "War inherited"),
100
+ ("WarRetractedByConcord", "War retracted by Concord"),
101
+ ("WarSurrenderOfferMsg", "War surrender offered"),
102
+ ("CharAppAcceptMsg", "Character joins corporation"),
103
+ ("CorpAppInvitedMsg", "Character invited to join corporation"),
104
+ ("CorpAppNewMsg", "Character submitted application"),
105
+ ("CharAppRejectMsg", "Corp application rejected message"),
106
+ (
107
+ "CorpAppRejectCustomMsg",
108
+ "Corp application rejected custom message",
109
+ ),
110
+ ("CharAppWithdrawMsg", "Character withdrew application"),
111
+ ("CharLeftCorpMsg", "Character leaves corporation"),
112
+ ("BillOutOfMoneyMsg", "Bill out of money"),
113
+ ("CorpAllBillMsg", "Corp alliance billing message"),
114
+ (
115
+ "InfrastructureHubBillAboutToExpire",
116
+ "I-HUB bill about to expire",
117
+ ),
118
+ ("IHubDestroyedByBillFailure", "I_HUB destroyed by bill failure"),
119
+ ],
120
+ default=[
121
+ "OrbitalAttacked",
122
+ "OrbitalReinforced",
123
+ "SkyhookDestroyed",
124
+ "SkyhookLostShields",
125
+ "SkyhookOnline",
126
+ "SkyhookUnderAttack",
127
+ "SovStructureDestroyed",
128
+ "SovStructureReinforced",
129
+ "StructureAnchoring",
130
+ "StructureDestroyed",
131
+ "StructureFuelAlert",
132
+ "StructureLostArmor",
133
+ "StructureLostShields",
134
+ "StructureLowReagentsAlert",
135
+ "StructureNoReagentsAlert",
136
+ "StructureOnline",
137
+ "StructureServicesOffline",
138
+ "StructureUnderAttack",
139
+ "StructureWentHighPower",
140
+ "StructureWentLowPower",
141
+ "TowerAlertMsg",
142
+ "TowerResourceAlertMsg",
143
+ ],
144
+ help_text="Select which type of notifications should be forwarded to this webhook",
145
+ max_length=1474,
146
+ verbose_name="notification types",
147
+ ),
148
+ ),
149
+ ]
@@ -410,11 +410,15 @@ class NotificationBase(models.Model):
410
410
  try:
411
411
  embed, ping_type = self._generate_embed(webhook.language_code)
412
412
  except OSError as ex:
413
- logger.warning("%s: Failed to generate embed: %s", self, ex, exc_info=True)
413
+ logger.error("%s: Failed to generate embed: %s", self, ex, exc_info=True)
414
414
  return False
415
415
 
416
416
  content = self._create_content_with_pings(webhook, ping_type)
417
417
  content += self._add_discord_group_pings(webhook)
418
+ max_content = dhooks_lite.Webhook.MAX_CHARACTERS
419
+ if content and len(content) > max_content:
420
+ logger.error("%s: Content of notification is too long: %s", self, content)
421
+ return False
418
422
 
419
423
  username, avatar_url = self._gen_avatar()
420
424
  new_queue_size = webhook.send_message(
@@ -240,6 +240,26 @@ class TestNotificationEmbedsGenerate(TestCase):
240
240
  self.assertEqual(discord_embed.footer.text, "Structures")
241
241
  self.assertIn("structures_logo.png", discord_embed.footer.icon_url)
242
242
 
243
+ def test_should_not_break_with_too_large_description(self):
244
+ # given
245
+ notification = Notification.objects.get(notification_id=1000000403)
246
+ notification_embed = NotificationBaseEmbed.create(notification)
247
+ notification_embed._description = "x" * 2049
248
+ # when
249
+ discord_embed = notification_embed.generate_embed()
250
+ # then
251
+ self.assertIsInstance(discord_embed, dhooks_lite.Embed)
252
+
253
+ def test_should_not_break_with_too_large_title(self):
254
+ # given
255
+ notification = Notification.objects.get(notification_id=1000000403)
256
+ notification_embed = NotificationBaseEmbed.create(notification)
257
+ notification_embed._title = "x" * 257
258
+ # when
259
+ discord_embed = notification_embed.generate_embed()
260
+ # then
261
+ self.assertIsInstance(discord_embed, dhooks_lite.Embed)
262
+
243
263
 
244
264
  class TestNotificationEmbedsClasses(NoSocketsTestCase):
245
265
  @classmethod
@@ -118,6 +118,11 @@ class TestNotificationType(TestCase):
118
118
  "CorpWarInvalidatedMsg",
119
119
  "CorpWarRetractedMsg",
120
120
  "CorpWarSurrenderMsg",
121
+ "CorporationGoalClosed",
122
+ "CorporationGoalCompleted",
123
+ "CorporationGoalCreated",
124
+ "CorporationGoalNameChange",
125
+ "CorporationLeft",
121
126
  "CustomsMsg",
122
127
  "DeclareWar",
123
128
  "DistrictAttacked",
@@ -172,6 +177,7 @@ class TestNotificationType(TestCase):
172
177
  "KillRightUnavailable",
173
178
  "KillRightUnavailableOpen",
174
179
  "KillRightUsed",
180
+ "LPAutoRedeemed",
175
181
  "LocateCharMsg",
176
182
  "MadeWarMutual",
177
183
  "MercOfferRetractedMsg",
@@ -205,7 +211,14 @@ class TestNotificationType(TestCase):
205
211
  "ReimbursementMsg",
206
212
  "ResearchMissionAvailableMsg",
207
213
  "RetractsWar",
214
+ "SPAutoRedeemed",
208
215
  "SeasonalChallengeCompleted",
216
+ "SkinSequencingCompleted",
217
+ "SkyhookDeployed",
218
+ "SkyhookDestroyed",
219
+ "SkyhookLostShields",
220
+ "SkyhookOnline",
221
+ "SkyhookUnderAttack",
209
222
  "SovAllClaimAquiredMsg",
210
223
  "SovAllClaimLostMsg",
211
224
  "SovCommandNodeEventStarted",
@@ -237,7 +250,10 @@ class TestNotificationType(TestCase):
237
250
  "StructureItemsMovedToSafety",
238
251
  "StructureLostArmor",
239
252
  "StructureLostShields",
253
+ "StructureLowReagentsAlert",
254
+ "StructureNoReagentsAlert",
240
255
  "StructureOnline",
256
+ "StructurePaintPurchased",
241
257
  "StructureServicesOffline",
242
258
  "StructureUnanchoring",
243
259
  "StructureUnderAttack",
@@ -33,6 +33,7 @@ if "discord" in app_labels():
33
33
  super().setUpClass()
34
34
  load_eveuniverse()
35
35
  load_eve_entities()
36
+
36
37
  cls.group_1 = Group.objects.create(name="Dummy Group 1")
37
38
  cls.group_2 = Group.objects.create(name="Dummy Group 2")
38
39
  cls.owner = OwnerFactory()
@@ -140,3 +141,23 @@ if "discord" in app_labels():
140
141
  self.assertTrue(mock_import_discord.called)
141
142
  _, kwargs = mock_send_message.call_args
142
143
  self.assertFalse(re.search(r"(<@&\d+>)", kwargs["content"]))
144
+
145
+ def test_should_abort_when_content_is_too_large(
146
+ self, mock_send_message, mock_import_discord
147
+ ):
148
+ # given
149
+ mock_send_message.return_value = 1
150
+ mock_import_discord.return_value.objects.group_to_role.side_effect = (
151
+ self._my_group_to_role
152
+ )
153
+ webhook = WebhookFactory()
154
+ for i in range(286):
155
+ group = Group.objects.create(name=f"Group {i+1}")
156
+ webhook.ping_groups.add(group)
157
+ obj = clone_notification(
158
+ Notification.objects.get(notification_id=1000000509)
159
+ )
160
+ # when
161
+ result = obj.send_to_webhook(webhook)
162
+ # then
163
+ self.assertFalse(result)