Rich Messages
Overview
A rich message is the message payload that gets sent out. It can combine several blocks in one set: text, images, video, Flex Messages, buttons, and links. This module is the library where reusable rich messages are stored, and its main consumers are campaign management and auto-response.
It supports uploading images and video via multipart/form-data, and provides an endpoint that generates a thumbnail from a video.
Business Flow
GET /api/rich-messagereturns a paginated list shaped as{data, total}, scoped bylineOaId.GET /api/rich-message/find-all-objectreturns an object/dropdown shape and carries no policy annotation, matching the original TypeScript implementation.POST /api/rich-messageaccepts multipart/form-data to create a new entry:- Attachments are uploaded to object storage through the storage service.
- Flex Messages are sent to LINE for validation via
validateJsonFlexMessage; failure returns errorRMS_002(Failed to validate with LINE API). - A duplicate name returns error
RMS_001(Duplicate title).
POST /api/rich-message/gen-thumbnail-videoaccepts form-data to upload a video and request a thumbnail. This is used when configuring a video block, since LINE requires a preview image.GET /api/rich-message/:idreturns the detail view, andPUT /api/rich-message/:idupdates it, also as form-data.DELETE /api/rich-message/:idsoft-deletes, whileDELETE /api/rich-message/:id/hard?confirm=truedeletes permanently and is restricted to super admins.- When a campaign is due to send, it reads this rich message, assembles the payload, and publishes it to RabbitMQ.
Key Files & Functions
The code lives in internal/modules/richmessage/, consisting of controller.go, service.go,
responses.go, js.go, and dto.go.
| Method | Route | Handler | Policy (metadata) |
|---|---|---|---|
| GET | /api/rich-message | ct.findAll | readAll rich-message |
| GET | /api/rich-message/find-all-object | ct.findAllObject | — |
| GET | /api/rich-message/:id | ct.findByID | read rich-message |
| POST | /api/rich-message | ct.create | create rich-message |
| POST | /api/rich-message/gen-thumbnail-video | ct.genThumbnailVideo | read rich-message |
| PUT | /api/rich-message/:id | ct.update | update rich-message |
| DELETE | /api/rich-message/:id | ct.delete | delete rich-message |
| DELETE | /api/rich-message/:id/hard | ct.hardDelete | auth.SuperAdmin() |
Every route is wrapped in modulegate.ModuleGate(d, "rich-message").
Connections to Other Services
- Permissions —
ModuleGate("rich-message")is the guard that actually applies;PolicyModuleRichMessageis metadata only, and hard delete additionally requiresauth.SuperAdmin(). - Tables —
rich_message,line_oa - Redis — caches both the list and the detail views, with keys and TTLs matching the original TypeScript implementation
- Storage — holds images, video, and thumbnails
- External — the LINE API for Flex Message validation
- Consumers — campaign management, auto-response (which reads the
rich_messagetable directly), and message templates - Error codes —
RMS_001for a duplicate title,RMS_002when LINE validation fails