remove mailing list
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
9e00eed6c1
commit
07839767c4
|
@ -12,6 +12,7 @@ class DestroyAction
|
||||||
|
|
||||||
public function handle(Maildispatcher $maildispatcher): void
|
public function handle(Maildispatcher $maildispatcher): void
|
||||||
{
|
{
|
||||||
|
$maildispatcher->gateway->type->deleteList($maildispatcher->name, $maildispatcher->gateway->domain);
|
||||||
$maildispatcher->delete();
|
$maildispatcher->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,6 @@ class Maildispatcher extends Model
|
||||||
'filter' => 'json',
|
'filter' => 'json',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function booted(): void
|
|
||||||
{
|
|
||||||
static::deleting(function ($dispatcher) {
|
|
||||||
foreach ($dispatcher->gateway->type->list($dispatcher->name, $dispatcher->gateway->domain) as $email) {
|
|
||||||
$dispatcher->gateway->type->remove($dispatcher->name, $dispatcher->gateway->domain, $email->email);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Mailgateway, self>
|
* @return BelongsTo<Mailgateway, self>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -57,6 +57,10 @@ class LocalType extends Type
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteList(string $name, string $domain): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function remove(string $name, string $domain, string $email): void
|
public function remove(string $name, string $domain, string $email): void
|
||||||
{
|
{
|
||||||
Localmaildispatcher::where('from', "{$name}@{$domain}")->where('to', $email)->delete();
|
Localmaildispatcher::where('from', "{$name}@{$domain}")->where('to', $email)->delete();
|
||||||
|
|
|
@ -113,6 +113,11 @@ class MailmanType extends Type
|
||||||
$this->service()->createList("{$name}@{$domain}");
|
$this->service()->createList("{$name}@{$domain}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteList(string $name, string $domain): void
|
||||||
|
{
|
||||||
|
$this->service()->deleteList("{$name}@{$domain}");
|
||||||
|
}
|
||||||
|
|
||||||
private function getList(string $name, string $domain): MailingList
|
private function getList(string $name, string $domain): MailingList
|
||||||
{
|
{
|
||||||
$list = $this->service()->getLists()->first(fn ($list) => $list->fqdnListname === "{$name}@{$domain}");
|
$list = $this->service()->getLists()->first(fn ($list) => $list->fqdnListname === "{$name}@{$domain}");
|
||||||
|
|
|
@ -22,6 +22,8 @@ abstract class Type
|
||||||
|
|
||||||
abstract public function createList(string $name, string $domain): void;
|
abstract public function createList(string $name, string $domain): void;
|
||||||
|
|
||||||
|
abstract public function deleteList(string $name, string $domain): void;
|
||||||
|
|
||||||
abstract public function remove(string $name, string $domain, string $email): void;
|
abstract public function remove(string $name, string $domain, string $email): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,6 +59,13 @@ class MailmanService
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteList(string $mailAddress): void
|
||||||
|
{
|
||||||
|
$list = $this->getLists()->first(fn ($list) => $list->fqdnListname === $mailAddress);
|
||||||
|
$response = $this->http()->delete("/lists/{$list->listId}");
|
||||||
|
throw_unless(204 === $response->status(), MailmanServiceException::class, 'Deleting list failed');
|
||||||
|
}
|
||||||
|
|
||||||
public function check(): bool
|
public function check(): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue