feat(message_bizppurio): 검수 모드 라벨 통일 + 발송 payload 저장 + 알림톡 URL 프로토콜 중복 방지
발송 이력 화면의 "테스트 모드" 표기를 "검수 모드"로 통일하고, 검수 모드 발송 건은 상태 라벨 대신 "검수" 라벨로 표시한다. 설정 미완료 상태에서도 검수 모드 안내가 함께 표시되도록 배너 노출 조건을 수정한다. 발송 요청 payload가 어디에도 저장되지 않아 실패 원인을 사후 재구성할 수 없던 문제를 해결한다. bizppurio_dispatches.request_payload 컬럼을 신설해 발송 시점(성공/실패 무관)에 실제 비즈뿌리오 전송 payload를 저장하되, 다른 컬럼과 중복되는 개인식별 정보(수신번호·치환된 본문 텍스트)는 제외하고 저장한다. 카카오 알림톡 버튼 URL과 완전한 URL 변수(action_url 등, 항상 프로토콜 포함)가 결합될 때 프로토콜이 중복(https://https://...)되어 잘못된 링크로 발송되던 문제를 방지한다. 플러그인 제거 후 재설치 시 sms·alimtalk 채널 템플릿이 재생성되지 않던 문제를 해결한다. 리스너 등록 이력 캐시가 재활성화 후에도 남아있어 재등록이 조용히 스킵되던 것으로, 코어 수정 없이 플러그인 내부에서 리플렉션으로 우회한다.
This commit is contained in:
1 parent
a8a85ac0cf
commit
4e77d25926
26 files changed
+808
-24
No files matched your search
+68
-2
@@ -7,6 +7,7 @@ use App\Models\User;
|
||||
use App\Notifications\GenericNotification;
|
||||
use App\Notifications\GuestNotifiable;
|
||||
use App\Services\NotificationTemplateService;
|
||||
use App\Services\PluginSettingsService;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Mockery;
|
||||
@@ -47,20 +48,30 @@ class SmsChannelDriverTest extends PluginTestCase
|
||||
* 템플릿 resolve 결과를 지정한 driver 를 만듭니다.
|
||||
*
|
||||
* @param NotificationTemplate|null $template resolve 반환값
|
||||
* @param bool $isTestMode 검수 모드 설정값 (이력 스냅샷 검증용)
|
||||
*/
|
||||
private function makeDriver(?NotificationTemplate $template, ?MessagePayloadBuilder $builder = null): SmsChannelDriver
|
||||
{
|
||||
private function makeDriver(
|
||||
?NotificationTemplate $template,
|
||||
?MessagePayloadBuilder $builder = null,
|
||||
bool $isTestMode = true,
|
||||
): SmsChannelDriver {
|
||||
$templateService = Mockery::mock(NotificationTemplateService::class);
|
||||
$templateService->shouldReceive('resolve')
|
||||
->with(Mockery::any(), 'sms')
|
||||
->andReturn($template);
|
||||
|
||||
$pluginSettings = Mockery::mock(PluginSettingsService::class);
|
||||
$pluginSettings->shouldReceive('get')
|
||||
->with('sirsoft-message_bizppurio', 'is_test_mode', true)
|
||||
->andReturn($isTestMode);
|
||||
|
||||
return new SmsChannelDriver(
|
||||
$templateService,
|
||||
new SmsTypeResolver,
|
||||
$builder ?? $this->spyBuilder(),
|
||||
new BizppurioDispatchRepository,
|
||||
new DispatchLinkContext,
|
||||
$pluginSettings,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,6 +171,41 @@ class SmsChannelDriverTest extends PluginTestCase
|
||||
$this->assertNull($dispatch->to_user_id, '비회원 발송은 to_user_id 가 null 이어야 한다.');
|
||||
}
|
||||
|
||||
public function test_발송_시_실제_전송_payload가_이력에_저장된다(): void
|
||||
{
|
||||
Bus::fake();
|
||||
$member = User::factory()->create(['mobile' => '010-1234-5678']);
|
||||
$builder = $this->spyBuilder();
|
||||
|
||||
$this->makeDriver($this->fakeTemplate(), $builder)->send($member, $this->notification());
|
||||
|
||||
$dispatch = BizppurioDispatch::first();
|
||||
$this->assertNotNull($dispatch->request_payload, '결함① — 실제 비즈뿌리오 전송 payload 가 이력에 저장돼야 한다.');
|
||||
$this->assertArrayNotHasKey('to', $dispatch->request_payload, 'to 는 to_number 컬럼과 중복이라 제외돼야 한다.');
|
||||
}
|
||||
|
||||
public function test_이력_저장_payload에서_개인식별_정보는_제외된다(): void
|
||||
{
|
||||
Bus::fake();
|
||||
$member = User::factory()->create(['mobile' => '010-1234-5678']);
|
||||
|
||||
// 실제 MessagePayloadBuilder(스파이 아님)로 진짜 조립 로직을 태워야 forHistory() 제외
|
||||
// 규칙(to/refkey/type/message 제거)을 검증할 수 있다.
|
||||
$pluginSettings = Mockery::mock(PluginSettingsService::class);
|
||||
$pluginSettings->shouldReceive('get')->andReturn('');
|
||||
$realBuilder = new MessagePayloadBuilder($pluginSettings);
|
||||
|
||||
$this->makeDriver($this->fakeTemplate(), $realBuilder)->send($member, $this->notification());
|
||||
|
||||
$dispatch = BizppurioDispatch::first();
|
||||
$payload = $dispatch->request_payload;
|
||||
|
||||
$this->assertArrayNotHasKey('to', $payload, 'to 는 to_number 컬럼과 중복이라 제외돼야 한다.');
|
||||
$this->assertArrayNotHasKey('refkey', $payload, 'refkey 는 refkey 컬럼과 중복이라 제외돼야 한다.');
|
||||
$this->assertArrayNotHasKey('type', $payload, 'type 은 channel 컬럼과 중복이라 제외돼야 한다.');
|
||||
$this->assertArrayNotHasKey('message', $payload['content']['sms'] ?? [], 'message 는 content 컬럼과 중복이라 제외돼야 한다.');
|
||||
}
|
||||
|
||||
public function test_발송하지_않으면_이력도_생성하지_않는다(): void
|
||||
{
|
||||
Bus::fake();
|
||||
@@ -236,4 +282,24 @@ class SmsChannelDriverTest extends PluginTestCase
|
||||
Bus::assertDispatched(SendMessageJob::class);
|
||||
$this->assertDatabaseCount('bizppurio_dispatches', 1);
|
||||
}
|
||||
|
||||
public function test_검수_모드_설정값이_이력에_스냅샷으로_기록된다(): void
|
||||
{
|
||||
Bus::fake();
|
||||
$member = User::factory()->create(['mobile' => '010-1234-5678']);
|
||||
|
||||
$this->makeDriver($this->fakeTemplate(), isTestMode: true)->send($member, $this->notification());
|
||||
|
||||
$this->assertTrue(BizppurioDispatch::first()->is_test_mode);
|
||||
}
|
||||
|
||||
public function test_운영_모드_설정값도_이력에_스냅샷으로_기록된다(): void
|
||||
{
|
||||
Bus::fake();
|
||||
$member = User::factory()->create(['mobile' => '010-1234-5678']);
|
||||
|
||||
$this->makeDriver($this->fakeTemplate(), isTestMode: false)->send($member, $this->notification());
|
||||
|
||||
$this->assertFalse(BizppurioDispatch::first()->is_test_mode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user