feat(121+122): smsplanet conversation, notifications, default footer
Phase 121 — SMSPLANET Conversation + Notifications:
- migration 20260512_000110 adds smsplanet conversation + notifications tables
- src/Modules/Sms (SmsConversationService, SmsMessageRepository, SmsplanetWebhookController)
- src/Modules/Notifications (Repository, Controller, ApiController)
- order SMS tab, notification center, sender mode, inbound webhook
- public notifications.js + layouts/app.php integration
Phase 122 — SMSPLANET Default SMS Footer:
- migration 20260512_000111 adds smsplanet_integration_settings.default_footer
- footer appended to test SMS and order SMS, validated against 918 char limit
- settings textarea + compact order SMS note when footer configured
Bundled (could not split per-phase without hunk staging):
- routes/web.php (also carries Phase 118 fakturownia redirects)
- DOCS/{ARCHITECTURE,DB_SCHEMA,TECH_CHANGELOG}.md (118 + 121 + 122 entries)
- .paul/codebase/{architecture,db_schema,tech_changelog}.md (118 + 121 + 122)
- .paul/STATE.md, ROADMAP.md, changelog/2026-05-12.md (UNIFY closure)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
SET @smsplanet_sender_mode_exists = (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'smsplanet_integration_settings'
|
||||
AND COLUMN_NAME = 'sender_mode'
|
||||
);
|
||||
SET @sql = IF(@smsplanet_sender_mode_exists = 0,
|
||||
'ALTER TABLE smsplanet_integration_settings ADD COLUMN sender_mode VARCHAR(16) NOT NULL DEFAULT ''text'' AFTER sender',
|
||||
'SELECT ''sender_mode already exists''');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @smsplanet_sender_phone_exists = (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'smsplanet_integration_settings'
|
||||
AND COLUMN_NAME = 'sender_phone'
|
||||
);
|
||||
SET @sql = IF(@smsplanet_sender_phone_exists = 0,
|
||||
'ALTER TABLE smsplanet_integration_settings ADD COLUMN sender_phone VARCHAR(32) NULL AFTER sender_mode',
|
||||
'SELECT ''sender_phone already exists''');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sms_messages (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
direction VARCHAR(16) NOT NULL,
|
||||
provider VARCHAR(32) NOT NULL DEFAULT 'smsplanet',
|
||||
order_id BIGINT UNSIGNED NULL,
|
||||
from_phone VARCHAR(64) NOT NULL,
|
||||
from_phone_normalized VARCHAR(32) NOT NULL,
|
||||
to_phone VARCHAR(64) NOT NULL,
|
||||
to_phone_normalized VARCHAR(32) NOT NULL,
|
||||
body TEXT NOT NULL,
|
||||
message_id VARCHAR(128) NULL,
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'received',
|
||||
raw_payload_json JSON NULL,
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
KEY sms_messages_order_created_idx (order_id, created_at),
|
||||
KEY sms_messages_from_normalized_idx (from_phone_normalized),
|
||||
KEY sms_messages_to_normalized_idx (to_phone_normalized),
|
||||
KEY sms_messages_provider_message_idx (provider, message_id),
|
||||
CONSTRAINT sms_messages_order_fk
|
||||
FOREIGN KEY (order_id) REFERENCES orders(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT sms_messages_user_fk
|
||||
FOREIGN KEY (created_by) REFERENCES users(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS notifications (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
type VARCHAR(64) NOT NULL,
|
||||
title VARCHAR(190) NOT NULL,
|
||||
body VARCHAR(500) NOT NULL,
|
||||
target_url VARCHAR(500) NULL,
|
||||
related_order_id BIGINT UNSIGNED NULL,
|
||||
related_sms_message_id BIGINT UNSIGNED NULL,
|
||||
read_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
KEY notifications_unread_created_idx (read_at, created_at),
|
||||
KEY notifications_order_idx (related_order_id),
|
||||
KEY notifications_sms_message_idx (related_sms_message_id),
|
||||
CONSTRAINT notifications_order_fk
|
||||
FOREIGN KEY (related_order_id) REFERENCES orders(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT notifications_sms_message_fk
|
||||
FOREIGN KEY (related_sms_message_id) REFERENCES sms_messages(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
Reference in New Issue
Block a user