LINE OA Lookup by Hash
Overview
This is the first endpoint client-web calls on every LIFF page. It converts the hash in the URL — of the form /{hash}/... — into a lineLiffId so the web app can call liff.init(), and returns the public OA information the page needs: the OA name, its @-id, and its cover image.
The route was designed with the explicit understanding that it is unauthenticated, so it returns only genuinely safe fields — every one of them already appears on the OA's public LINE page. No credential of any kind may be added to this response.
Business Flow
- Take
:hashfrom the path and queryline_oawithstatus NOT IN ('delete') AND deleted_date IS NULL. Note that this condition is looser than the one inliff.Service, which requiresstatus='active': an inactive OA can still resolve its hash, but token verification will fail at the next step. - If no row matches, return 400 with the message
APP_007(parity with the source'sErrorResponse.APP_007). - Assemble the response:
lineLiffIdandformLiffIdare read from the jsonbline_login_info. An empty value or a missing key becomes JSONnull(parity withvalue || null).botBasicIdis the public@-id, which the form thank-you page needs to buildhttps://line.me/R/ti/p/<id>for theoa_chataction when opened in an external browser.namecomes fromline_oa_nameand is used as the page's document title.imageUrlresolvesline_oa.cover— a storage path — into a public URL for use as og:image. An empty path yieldsnullrather than a URL pointing at the bucket root, a path that is already an absolute URL is passed through unchanged, and a missing storage configuration yieldsnullwithout panicking.
Key Files & Functions
| Item | Value |
|---|---|
| Route | GET /api/line-oa/get-by-hash/:hash |
| Register | internal/lineoa/register.go → Register(r, deps) |
| Handler | internal/lineoa/handler.go → (*Handler).GetByHash |
| Service | internal/lineoa/service.go → (*Service).GetByHash, findByHash, resolveCover, emptyToNil |
| Repository | internal/lineoa/repository.go → FindByHash, FindActiveByID |
| Entity | internal/lineoa/entity.go → LineOa, LineLoginInfo |
| Response | GetByHashResponse with lineLiffId, formLiffId, botBasicId, name, imageUrl |
Connections to Other Services
- The
line_oatable, usingline_oa_hash,line_oa_name,bot_basic_id,cover, and the jsonbline_login_info. internal/storagexforGetPublicURL, which is allowed to be nil — in that case no image is returned.lineoa.Repositoryis reused by LIFF Token Verification throughFindActiveByID, and by the bulletin and loyalty domains through their ownFindOaByHashhelpers.- The related client-web feature is
line-oa-hash-routing, which owns the/{hash}/...URL structure and OA-level OG metadata.