LINE Official Account Management
Overview
The LINE OA is the tenant unit of this system — nearly every table is scoped by line_oa_id,
which makes this module the backbone of the platform. It covers creating, updating, and deleting
OAs, storing channel credentials (channel id, channel secret, access token), managing webhook
URLs, configuring audience auto-refresh, configuring GA tracking, configuring inbound message
handling, and integrating with the external mbox (live chat) system.
Most routes sit on the public group alongside JwtLoginAuth, because they must be callable
before the token carries a lineOaId: the post-login OA picker has to fetch the list of OAs
first.
Business Flow
Connecting an OA
- The user enters the channel id, channel secret, and access token, then calls
POST /api/line-oa/get-oa-info. The system queries the LINE API to confirm the credentials work and pulls back the OA's name and picture for display. POST /api/line-oacreates the row inline_oa, checking themaxChannelsquota via plan limits and generating awebhook_idand aline_oa_hash.- The user copies the generated webhook URL into the LINE Developer Console.
GET /api/line-oa/webhook/:webhookIdprovides the reverse lookup from webhook id to OA. PUT /api/line-oa/:id/regenerate-webhookissues a fresh webhook id if the old one leaks.
Day-to-day use
GET /api/line-oareturns a paginated list shaped as{data, total, totalOverAll}.GET /api/line-oa/find-all-object, which has no guard at all, returns a dropdown, dropdown-group, or object shape depending on the?format=query parameter.PUT /api/line-oa/:idupdates the record andPUT /api/line-oa/:id/statusenables or disables it.DELETE /api/line-oa/:idsoft-deletes;DELETE /api/line-oa/:id/harddeletes permanently and requires a super admin plus the?confirm=parameter.
Specialised settings
- Audience auto-refresh via
GET /api/line-oa/:id/audience-refresh-settingsandPUT /api/line-oa/:id/audience-refresh-settings, which control how the cron that refreshes this OA's audiences behaves. - GA tracking via
GET /api/line-oa/:id/ga-tracking-settingsandPUT /api/line-oa/:id/ga-tracking-settings, storing the measurement id and API secret used to send events to Google Analytics. - Message handling via
PUT /api/line-oa/:id/message-handling, which selects whether inbound messages are picked up by auto-response, a workflow, or mbox. - mbox via
POST /api/line-oa/:id/mbox/test-connection(testing baseUrl, apiToken, and accountId) andGET /api/line-oa/:id/mbox/teams(fetching the team list to bind against).
OA access control, super admin only
GET /api/line-oa/:id/user-accessandPUT /api/line-oa/:id/user-accessdefine who may access this OA, writing touser_line_oa. Unlike the ported routes, this pair sits on theauthedgroup, because CLS must be populated beforeSuperAdmin()reads from it.
Key Files & Functions
The code lives in internal/modules/lineoa/, consisting of controller.go, service.go,
dto.go, responses.go, js.go, and user_access.go.
| Method | Route | Handler | Guard / Policy |
|---|---|---|---|
| GET | /api/line-oa | ct.findAll | JwtLogin + readAll line-oa |
| GET | /api/line-oa/find-all-object | ct.findAllObject | no guard |
| GET | /api/line-oa/:id | ct.findByID | JwtLogin + read |
| GET | /api/line-oa/webhook/:webhookId | ct.findByWebhookID | JwtLogin + read |
| POST | /api/line-oa | ct.create | JwtLogin + create |
| POST | /api/line-oa/get-oa-info | ct.getOaInfo | — |
| POST | /api/line-oa/validate-login | ct.validateLogin | — |
| PUT | /api/line-oa/:id | ct.update | JwtLogin + update |
| PUT | /api/line-oa/:id/status | ct.updateStatus | JwtLogin + update |
| PUT | /api/line-oa/:id/regenerate-webhook | ct.regenerateWebhook | JwtLogin + update |
| GET / PUT | /api/line-oa/:id/audience-refresh-settings | ct.getAudienceRefreshSettings / ct.updateAudienceRefreshSettings | JwtLogin + read/update |
| GET / PUT | /api/line-oa/:id/ga-tracking-settings | ct.getGaTrackingSettings / ct.updateGaTrackingSettings | JwtLogin + read/update |
| PUT | /api/line-oa/:id/message-handling | ct.updateMessageHandling | JwtLogin + update |
| POST | /api/line-oa/:id/mbox/test-connection | ct.testMboxConnection | JwtLogin + update |
| GET | /api/line-oa/:id/mbox/teams | ct.getMboxTeams | JwtLogin + read |
| DELETE | /api/line-oa/:id | ct.delete | JwtLogin + delete |
| DELETE | /api/line-oa/:id/hard | ct.hardDelete | auth.SuperAdmin() |
| GET / PUT | /api/line-oa/:id/user-access | ct.getUserAccess / ct.updateUserAccess | authed + auth.SuperAdmin() |
Connections to Other Services
- Permissions — the
PolicyModuleLineOametadata is not yet enforced; the guards that actually apply areauth.SuperAdmin()on hard delete and on user-access. - Tables —
line_oa,line_oa_app,user_line_oa,organization - Redis — caches OA records and LINE access tokens
- RabbitMQ — publishes to the
line_sync_follower_userqueue when a follower sync is requested - External — the LINE Messaging API through
internal/externals/lineapi, and the mbox system over HTTP - Cross-module —
planlimitsfor themaxChannelsquota, andauth.GenerateLineOaHash - Nearly every feature in the system depends on the
lineOaIdthis module produces.