Add more permissions
This commit is contained in:
+24
-2
@@ -33,6 +33,8 @@ public function __construct(
|
||||
public ?int $templateId = null,
|
||||
public ?int $clientCaseId = null,
|
||||
public ?int $userId = null,
|
||||
// If provided, update this activity on failure instead of creating a new one
|
||||
public ?int $activityId = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -86,8 +88,28 @@ public function handle(SmsService $sms): void
|
||||
clientReference: $this->clientReference,
|
||||
);
|
||||
}
|
||||
// If invoked from the case UI with a selected template, create an Activity
|
||||
if ($this->templateId && $this->clientCaseId && $log) {
|
||||
// Update an existing pre-created activity ONLY on failure when activityId is provided
|
||||
if ($this->activityId && $log && ($log->status === 'failed')) {
|
||||
try {
|
||||
$activity = \App\Models\Activity::find($this->activityId);
|
||||
if ($activity) {
|
||||
$note = (string) ($activity->note ?? '');
|
||||
$append = sprintf(
|
||||
' | Napaka: %s',
|
||||
'SMS ni bil poslan!'
|
||||
);
|
||||
$activity->update(['note' => $note.$append]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\Log::warning('SendSmsJob activity update failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'activity_id' => $this->activityId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// If no pre-created activity is provided and invoked from the case UI with a selected template, create an Activity
|
||||
if (!$this->activityId && $this->templateId && $this->clientCaseId && $log) {
|
||||
try {
|
||||
/** @var SmsTemplate|null $template */
|
||||
$template = SmsTemplate::find($this->templateId);
|
||||
|
||||
Reference in New Issue
Block a user