Skip to main content

LINE Friend Management (LINE User)

Overview

line_user is the follower database for each LINE OA, and it is the foundation everything else rests on — audiences, campaigns, reports, and triggers all query this table.

The module provides tools for searching friends, viewing individual records, inspecting a person's GA journey, syncing followers from LINE, importing friends from CSV, and editing custom attributes and profiles on a per-person basis.

Business Flow

Search and detail

  1. GET /api/line-users/search performs a paginated search driven by FilterGetLineUserDto, supporting queries by name, follow status, tag, and custom attributes, scoped to the lineOaId in CLS.
  2. GET /api/line-users/:id returns a single friend's details: profile, attributes, and history.
  3. GET /api/line-users/:id/ga-journey?days=30 retrieves the tracked usage path recorded in GA, defaulting to 30 days, for analysing individual behaviour.

Syncing from LINE

  1. POST /api/line-users/sync-follower-users requests a full follower pull from LINE by publishing a job to the RabbitMQ queue line_sync_follower_user for a worker to process in the background.
  2. GET /api/line-users/last-synced-follower-users-status lets cms-web poll the status of the most recent sync run.

Importing from CSV

  1. POST /api/line-users/import-all-friends accepts multipart/form-data for uploading a CSV of friends. The file is stored in object storage, rows are created in line_user_import and line_user_import_detail, and a job is published to the line_import_csv_user queue for a worker to process.
  2. Past import results can be reviewed at GET /api/report/import-history.

Editing individual records

  1. PUT /api/line-users/:id/custom-attribute updates custom attribute values, whose schema comes from the attribute master module.
  2. PUT /api/line-users/:id/profile updates the profile stored on our side.

Key Files & Functions

The code lives in internal/modules/lineuser/, consisting of controller.go, service.go, repository.go, csv.go, gajourney.go, lineoa.go, dto.go, and module.go.

All routes are registered on authed.Group("/line-users").

MethodRouteHandlerPolicy (metadata)
GET/api/line-users/searchsvc.searchHandlerreadAll line-user
GET/api/line-users/last-synced-follower-users-statussvc.lastSyncedFollowerUsersStatusHandlerread line-user
GET/api/line-users/:idsvc.getLineUserDetailHandlerread line-user
GET/api/line-users/:id/ga-journeysvc.getGaJourneyHandlerread line-user
POST/api/line-users/sync-follower-userssvc.syncFollowerUsersHandlerupdate line-user
POST/api/line-users/import-all-friendssvc.importLineUsersHandlercreate line-user
PUT/api/line-users/:id/custom-attributesvc.updateCustomAttributeHandlerupdate line-user
PUT/api/line-users/:id/profilesvc.updateProfileHandlerupdate line-user

Cross-module entry point: the report module reuses the lineuser service so both share the same query builder.

Connections to Other Services

  • Permissions — policy metadata PolicyModuleLineUser; because the routes sit on the authed group, the token must already carry a lineOaId.
  • Tablesline_user, line_user_import, line_user_import_detail, tracking_line_users, attribute_master, line_oa
  • RabbitMQ — the line_sync_follower_user and line_import_csv_user queues
  • Storage — CSV uploads go to MinIO/S3
  • External — the LINE Messaging API for follower ids and profiles, and Google Analytics for the GA journey
  • Consumers of this data — audience management, campaign management, the all-friend listing report, import mapping, and the dashboard