Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arduinomaster22 committed Jan 13, 2025
1 parent 980fcab commit 3270404
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
20 changes: 20 additions & 0 deletions src/Events/MailUnsuppressed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Vormkracht10\Mails\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Vormkracht10\Mails\Models\MailEvent;

class MailUnsuppressed
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(
public MailEvent $mailEvent
) {}
}
11 changes: 11 additions & 0 deletions src/Listeners/UnsuppressEmailAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Vormkracht10\Mails\Listeners;

class UnsupsressEmailAddress
{
public function handle(MailUnsuppressed $event): void

Check failure on line 7 in src/Listeners/UnsuppressEmailAddress.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter $event of method Vormkracht10\Mails\Listeners\UnsupsressEmailAddress::handle() has invalid type Vormkracht10\Mails\Listeners\MailUnsuppressed.
{
$event->mailEvent->update('unsuppressed_at', now());

Check failure on line 9 in src/Listeners/UnsuppressEmailAddress.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to property $mailEvent on an unknown class Vormkracht10\Mails\Listeners\MailUnsuppressed.
}
}
15 changes: 7 additions & 8 deletions src/Models/MailEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Vormkracht10\Mails\Database\Factories\MailEventFactory;
use Vormkracht10\Mails\Enums\EventType;
use Vormkracht10\Mails\Events\MailEventLogged;
use Vormkracht10\Mails\Events\MailUnsuppressed;

/**
* @property Mail $mail
Expand Down Expand Up @@ -92,7 +93,7 @@ public function mail()

protected function getEventClassAttribute(): string
{
return 'Vormkracht10\Mails\Events\Mail'.Str::studly($this->type->value);
return 'Vormkracht10\Mails\Events\Mail' . Str::studly($this->type->value);
}

public function unSuppress()
Expand All @@ -105,7 +106,7 @@ public function unSuppress()
])
->baseUrl('https://api.postmarkapp.com/');

$response = $client->post('message-streams/'.config('mail.mailers.postmark.stream_id', 'broadcast').'/suppressions/delete', [
$response = $client->post('message-streams/' . config('mail.mailers.postmark.stream_id', 'broadcast') . '/suppressions/delete', [
'Suppressions' => [
[
'emailAddress' => key($this->mail->to),
Expand All @@ -114,11 +115,10 @@ public function unSuppress()
]);

if ($response->successful()) {

$this->update(['unsuppressed_at' => now()]);
event(MailUnsuppressed::class, $mailEvent);

Check failure on line 118 in src/Models/MailEvent.php

View workflow job for this annotation

GitHub Actions / phpstan

Undefined variable: $mailEvent
} else {

throw new \Exception('Failed to unsuppress email address due to '.$response);
throw new \Exception('Failed to unsuppress email address due to ' . $response);
}
}

Expand All @@ -129,11 +129,10 @@ public function unSuppress()
$response = $mailgun->suppressions()->unsubscribes()->delete(config('services.mailgun.domain'), key($this->mail->to));

if ($response) {

$this->update(['unsuppressed_at' => now()]);
event(MailUnsuppressed::class, $mailEvent);

Check failure on line 132 in src/Models/MailEvent.php

View workflow job for this annotation

GitHub Actions / phpstan

Undefined variable: $mailEvent
} else {

throw new \Exception('Failed to unsuppress email address due to '.$response);
throw new \Exception('Failed to unsuppress email address due to ' . $response);
}
}
}
Expand Down

0 comments on commit 3270404

Please sign in to comment.