feat(moa): add Album (Moa) REST service - #214
Open
enkunkun wants to merge 1 commit into
Open
Conversation
Exposes the LINE Album subsystem as `client.base.moa`. Unlike Talk / Square,
Moa is a plain HTTP JSON API on top of the LEGY proxy — not Thrift — so this
service uses `client.fetch` directly with an `X-Line-ChannelToken` obtained
from `channel.approveChannelAndIssueChannelToken({channelId: "1375220249"})`.
- packages/linejs/base/service/moa/mod.ts: MoaService with
getAlbumChannelToken() — memoised channel-token issuance for 1375220249
getAlbums({cursor, orderBy, include}) — paginated album list
getPhotos({chatId, albumId, cursor, pageSize, ...}) — paginated photos
downloadPhoto({chatId, albumId, oid, prefix?}) — original bytes (Uint8Array)
All requests override the linejs default headers with
`accept: application/json` and `content-type: application/json; charset=UTF-8`,
otherwise LEGY replies with
`{"code":102001,"message":"一時的なエラーが発生しました。"}` at HTTP 200.
buildMoaUrl is exported as a pure helper so users writing custom Moa calls
can reuse the URL encoding.
- packages/linejs/base/service/moa/mod.test.ts: 5 tests covering buildMoaUrl
edge cases (endpoint, encoding, undefined skipping, custom host).
- packages/linejs/base/service/mod.ts: re-export MoaService.
- packages/linejs/base/core/mod.ts: register `client.moa = new MoaService(this)`
alongside the other services.
- docs/docs/moa.md + config.mts sidebar entry: usage examples and the header
override note.
Verified end-to-end against a live LINE account: getAlbums returns 100
albums, getPhotos returns photo metadata with obsResourceId, and
downloadPhoto returns the original JPEG bytes (245 KB for a sample image).
enkunkun
force-pushed
the
feat/moa-album-service
branch
from
July 23, 2026 01:06
1b055f0 to
bdfe21a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
MoaService, wired up asclient.base.moa, exposing the LINE Album(Moa) subsystem. This subsystem was previously unreachable through LINEJS —
users had to hand-craft HTTP requests against the LEGY proxy to list albums
or download original photos.
Unlike Talk / Square, Moa is plain HTTP JSON on top of the LEGY proxy,
not Thrift, so this service uses
client.fetchdirectly with anX-Line-ChannelTokenissued viachannel.approveChannelAndIssueChannelToken({channelId: "1375220249"}).API
buildMoaUrlis exported as a pure helper for anyone wanting to hand-craftadditional Moa endpoints (the AB service in CHRLINE covers ~30 more).
Header override caveat
The Moa REST endpoints require
accept: application/json. The defaultclient.base.request.getHeader("GET")returnsaccept: application/x-thrift, which causes LEGY to reject Moa requestswith
{"code":102001,"message":"一時的なエラーが発生しました。"}at HTTP 200.MoaServicehandles this override internally.What changed
packages/linejs/base/service/moa/mod.ts(new) —MoaService+buildMoaUrlhelper + response type interfaces.packages/linejs/base/service/moa/mod.test.ts(new) — 5 testscovering
buildMoaUrledge cases (custom endpoint, encoding, undefinedskipping).
packages/linejs/base/service/mod.ts— re-exportMoaService.packages/linejs/base/core/mod.ts— registerclient.moa = new MoaService(this)alongside other services.docs/docs/moa.md(new) + sidebar entry — usage examples and theAccept-header caveat.
Verified end-to-end
Against a live LINE account:
getAlbums({})returned 100 albums (first page)getPhotos({chatId, albumId})returned photo metadata withobsResourceId,shotTime, etc.downloadPhoto({...oid})returned the original JPEG (245 KB) matchingthe LINE app's saved copy byte-for-byte
Checklist
MoaServiceverified against live LINE (list + list-photos + download)buildMoaUrl(5 cases)BaseClient