Skip to content

Commit 6b97ced

Browse files
committed
refactor: remove ecfmp webhook code
1 parent 3a5bc36 commit 6b97ced

10 files changed

Lines changed: 22 additions & 608 deletions

File tree

app/Discord/FlowMeasure/Webhook/WebhookMapper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Discord\FlowMeasure\Webhook;
44

55
use App\Discord\FlowMeasure\Webhook\Filter\FilterInterface;
6-
use App\Discord\Webhook\EcfmpWebhook;
76
use App\Discord\Webhook\WebhookInterface;
87
use App\Models\FlightInformationRegion;
98
use App\Models\FlowMeasure;
@@ -12,17 +11,15 @@
1211
class WebhookMapper implements MapperInterface
1312
{
1413
private readonly FilterInterface $filter;
15-
private readonly EcfmpWebhook $ecfmpWebhook;
1614

17-
public function __construct(FilterInterface $filter, EcfmpWebhook $ecfmpWebhook)
15+
public function __construct(FilterInterface $filter)
1816
{
1917
$this->filter = $filter;
20-
$this->ecfmpWebhook = $ecfmpWebhook;
2118
}
2219

2320
public function mapToWebhooks(FlowMeasure $measure): Collection
2421
{
25-
return Collection::make([$this->ecfmpWebhook])
22+
return Collection::make()
2623
->merge(
2724
$measure->notifiedFlightInformationRegions->map(
2825
fn (FlightInformationRegion $fir) => $fir->divisionDiscordWebhooks

app/Discord/Webhook/EcfmpWebhook.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/Providers/DiscordServiceProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use App\Discord\FlowMeasure\Webhook\Filter\WithdrawnWebhookFilter;
2222
use App\Discord\FlowMeasure\Webhook\WebhookMapper;
2323
use App\Discord\Message\Sender\DivisionWebhookSender;
24-
use App\Discord\Webhook\EcfmpWebhook;
2524
use App\Repository\FlowMeasureNotification\ActiveRepository;
2625
use App\Repository\FlowMeasureNotification\ExpiredRepository;
2726
use App\Repository\FlowMeasureNotification\NotifiedRepository;
@@ -43,7 +42,6 @@ public function register(): void
4342
$this->app->singleton(DiscordWebhookInterface::class, function () {
4443
return new DiscordWebhookSender();
4544
});
46-
$this->app->singleton(EcfmpWebhook::class);
4745
$this->app->singleton(
4846
DivisionWebhookSender::class,
4947
fn () => new DivisionWebhookSender(

tests/Discord/FlowMeasure/Helper/NotificationReissuerTest.php

Lines changed: 19 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Tests\Discord\FlowMeasure\Helper;
44

55
use App\Discord\FlowMeasure\Helper\NotificationReissuer;
6-
use App\Discord\Webhook\EcfmpWebhook;
76
use App\Enums\DiscordNotificationType as DiscordNotificationTypeEnum;
87
use App\Models\DivisionDiscordNotification;
98
use App\Models\DiscordNotificationType;
@@ -14,11 +13,14 @@
1413
class NotificationReissuerTest extends TestCase
1514
{
1615
private readonly FlowMeasure $flowMeasure;
16+
private readonly DivisionDiscordWebhook $webhook;
1717

1818
public function setUp(): void
1919
{
2020
parent::setUp();
2121
$this->flowMeasure = FlowMeasure::factory()->create();
22+
$this->webhook = DivisionDiscordWebhook::factory()
23+
->create();
2224
}
2325

2426
public function testItHasAType()
@@ -29,7 +31,7 @@ public function testItHasAType()
2931
new NotificationReissuer(
3032
$this->flowMeasure,
3133
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
32-
new EcfmpWebhook()
34+
$this->webhook
3335
)
3436
)->type()
3537
);
@@ -43,7 +45,7 @@ public function testItHasAFlowMeasure()
4345
new NotificationReissuer(
4446
$this->flowMeasure,
4547
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
46-
new EcfmpWebhook()
48+
$this->webhook
4749
)
4850
)->measure()
4951
);
@@ -68,7 +70,7 @@ public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged()
6870
new NotificationReissuer(
6971
$this->flowMeasure,
7072
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
71-
new EcfmpWebhook()
73+
$this->webhook
7274
)
7375
)->isReissuedNotification()
7476
);
@@ -93,7 +95,7 @@ public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged()
9395
new NotificationReissuer(
9496
$this->flowMeasure,
9597
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
96-
new EcfmpWebhook()
98+
$this->webhook
9799
)
98100
)->isReissuedNotification()
99101
);
@@ -118,45 +120,7 @@ public function testItsAReissueIfItWasNotifiedAndTheIdentifierHasChangedForActiv
118120
new NotificationReissuer(
119121
$this->flowMeasure,
120122
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
121-
new EcfmpWebhook()
122-
)
123-
)->isReissuedNotification()
124-
);
125-
}
126-
127-
public function testItsAReissueIfItsNotifiedOnAEcfmpWebhook()
128-
{
129-
$previousNotificationEcfmp = DivisionDiscordNotification::factory()
130-
->create();
131-
132-
$divisionWebhook = DivisionDiscordWebhook::factory()->create();
133-
$previousDivisionNotification = DivisionDiscordNotification::factory()
134-
->toDivisionWebhook($divisionWebhook)
135-
->create();
136-
137-
$this->flowMeasure->divisionDiscordNotifications()->sync(
138-
[
139-
$previousNotificationEcfmp->id => [
140-
'discord_notification_type_id' => DiscordNotificationType::idFromEnum(
141-
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
142-
),
143-
'notified_as' => 'notthis',
144-
],
145-
$previousDivisionNotification->id => [
146-
'discord_notification_type_id' => DiscordNotificationType::idFromEnum(
147-
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
148-
),
149-
'notified_as' => $this->flowMeasure->identifier,
150-
],
151-
]
152-
);
153-
154-
$this->assertTrue(
155-
(
156-
new NotificationReissuer(
157-
$this->flowMeasure,
158-
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
159-
new EcfmpWebhook()
123+
$this->webhook
160124
)
161125
)->isReissuedNotification()
162126
);
@@ -169,9 +133,8 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
169133
->toDivisionWebhook($otherDivisionWebhook)
170134
->create();
171135

172-
$divisionWebhook = DivisionDiscordWebhook::factory()->create();
173136
$previousDivisionNotification = DivisionDiscordNotification::factory()
174-
->toDivisionWebhook($divisionWebhook)
137+
->toDivisionWebhook($this->webhook)
175138
->create();
176139

177140
$this->flowMeasure->divisionDiscordNotifications()->sync(
@@ -196,7 +159,7 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
196159
new NotificationReissuer(
197160
$this->flowMeasure,
198161
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
199-
$divisionWebhook
162+
$this->webhook
200163
)
201164
)->isReissuedNotification()
202165
);
@@ -209,9 +172,8 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
209172
->toDivisionWebhook($otherDivisionWebhook)
210173
->create();
211174

212-
$divisionWebhook = DivisionDiscordWebhook::factory()->create();
213175
$previousDivisionNotification = DivisionDiscordNotification::factory()
214-
->toDivisionWebhook($divisionWebhook)
176+
->toDivisionWebhook($this->webhook)
215177
->create();
216178

217179
$this->flowMeasure->divisionDiscordNotifications()->sync(
@@ -236,34 +198,7 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
236198
new NotificationReissuer(
237199
$this->flowMeasure,
238200
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
239-
$divisionWebhook
240-
)
241-
)->isReissuedNotification()
242-
);
243-
}
244-
245-
public function testItsAReissueIfItsActivatedOnAEcfmpWebhook()
246-
{
247-
$previousNotification = DivisionDiscordNotification::factory()
248-
->create();
249-
250-
$this->flowMeasure->divisionDiscordNotifications()->sync(
251-
[
252-
$previousNotification->id => [
253-
'discord_notification_type_id' => DiscordNotificationType::idFromEnum(
254-
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
255-
),
256-
'notified_as' => 'nothis',
257-
],
258-
]
259-
);
260-
261-
$this->assertTrue(
262-
(
263-
new NotificationReissuer(
264-
$this->flowMeasure,
265-
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
266-
new EcfmpWebhook()
201+
$this->webhook
267202
)
268203
)->isReissuedNotification()
269204
);
@@ -288,7 +223,7 @@ public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged()
288223
new NotificationReissuer(
289224
$this->flowMeasure,
290225
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
291-
new EcfmpWebhook()
226+
$this->webhook
292227
)
293228
)->isReissuedNotification()
294229
);
@@ -313,7 +248,7 @@ public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged()
313248
new NotificationReissuer(
314249
$this->flowMeasure,
315250
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
316-
new EcfmpWebhook()
251+
$this->webhook
317252
)
318253
)->isReissuedNotification()
319254
);
@@ -338,7 +273,7 @@ public function testItIsNotAReissueIfItsNotifiedAndThenActivatedTheIdentifierHas
338273
new NotificationReissuer(
339274
$this->flowMeasure,
340275
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
341-
new EcfmpWebhook()
276+
$this->webhook
342277
)
343278
)->isReissuedNotification()
344279
);
@@ -351,7 +286,7 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenNotified()
351286
new NotificationReissuer(
352287
$this->flowMeasure,
353288
DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED,
354-
new EcfmpWebhook()
289+
$this->webhook
355290
)
356291
)->isReissuedNotification()
357292
);
@@ -364,7 +299,7 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenActivated()
364299
new NotificationReissuer(
365300
$this->flowMeasure,
366301
DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED,
367-
new EcfmpWebhook()
302+
$this->webhook
368303
)
369304
)->isReissuedNotification()
370305
);
@@ -389,7 +324,7 @@ public function testItIsNotAReissueIfItsWithdrawn()
389324
new NotificationReissuer(
390325
$this->flowMeasure,
391326
DiscordNotificationTypeEnum::FLOW_MEASURE_WITHDRAWN,
392-
new EcfmpWebhook()
327+
$this->webhook
393328
)
394329
)->isReissuedNotification()
395330
);
@@ -414,7 +349,7 @@ public function testItIsNotAReissueIfItsExpired()
414349
new NotificationReissuer(
415350
$this->flowMeasure,
416351
DiscordNotificationTypeEnum::FLOW_MEASURE_EXPIRED,
417-
new EcfmpWebhook()
352+
$this->webhook
418353
)
419354
)->isReissuedNotification()
420355
);

0 commit comments

Comments
 (0)