feat: implement template editing functionality and revert approved templates to draft status
This commit is contained in:
@@ -204,11 +204,15 @@ class SmsController extends BaseController
|
||||
return $this->error(ErrorCodes::ERR_NOT_FOUND_001, 'تمپلیت یافت نشد', 404);
|
||||
}
|
||||
|
||||
if ($template->getStatus() === SmsTemplate::STATUS_APPROVED) {
|
||||
return $this->error(ErrorCodes::ERR_SMS_003, ErrorCodes::message(ErrorCodes::ERR_SMS_003), 422);
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
|
||||
// ویرایش محتوای یک قالبِ تأییدشده، آن را به پیشنویس برمیگرداند تا متن جدید
|
||||
// دوباره تأیید/ارسال شود (متن قبلی با سرویسدهنده هماهنگ بوده).
|
||||
$contentChanged = array_key_exists('name', $data) || array_key_exists('body', $data) || array_key_exists('variables', $data);
|
||||
if ($template->getStatus() === SmsTemplate::STATUS_APPROVED && $contentChanged) {
|
||||
$template->revertToDraft();
|
||||
}
|
||||
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
if (array_key_exists('name', $data)) $template->setName($data['name']);
|
||||
if (array_key_exists('body', $data)) $template->setBody($data['body']);
|
||||
if (array_key_exists('variables', $data)) $template->setVariables($data['variables']);
|
||||
|
||||
Reference in New Issue
Block a user