queue umstellen

This commit is contained in:
JM 2026-05-06 17:33:07 +02:00
parent d99ec99fea
commit d0b1141648
2 changed files with 11 additions and 18 deletions

View File

@ -18,20 +18,12 @@ class SendTeamsActivityNotificationJob implements ShouldQueue
use InteractsWithQueue;
use SerializesModels;
/**
* Wie oft darf der Job retryen?
*/
public string $queue = 'teams';
public int $tries = 5;
/**
* Backoff in Sekunden (gestaffelt).
*/
public array $backoff = [10, 30, 60, 120, 300];
/**
* Hard timeout für den Worker (Sekunden).
*/
public int $timeout = 30;
public int $maxExceptions = 3;
public function __construct(
protected User $user,
@ -44,15 +36,17 @@ class SendTeamsActivityNotificationJob implements ShouldQueue
try {
$notifier->notify($this->user, $this->blueprint);
} catch (Throwable $e) {
// Loggen für Diagnose; danach rethrow -> Queue retry
$logger->error('Teams activity notification job failed', [
$logger->error('Teams activity notification failed', [
'extension' => 'sbp-jm/flarum-msteams-webhook',
'user_id' => $this->user->id,
'notification_type' => $this->blueprint::getType(),
'exception' => $e,
'queue' => $this->queue,
'attempt' => method_exists($this, 'attempts') ? $this->attempts() : null,
'exception_class' => get_class($e),
'message' => $e->getMessage(),
]);
throw $e;
}
}
}
}

View File

@ -26,15 +26,14 @@ class TeamsNotificationDriver implements NotificationDriverInterface
continue;
}
// notify_<type>_teams
$prefKey = User::getNotificationPreferenceKey($type, 'teams');
if (! $user->getPreference($prefKey)) {
continue;
}
// Queue wie bei Driver-Konzept vorgesehen
$this->queue->push(new SendTeamsActivityNotificationJob($user, $blueprint));
// ✅ explizit auf Queue "teams"
$this->queue->pushOn('teams', new SendTeamsActivityNotificationJob($user, $blueprint));
}
}