Browse Community Interaction

beta · guide · 0.1.0

Embed a read-only Comment thread

The Project Backend first verifies its own browser session, Project Membership, and visibility of one exact opaque resource. It then uses a server-side Project Credential with resource-grants:write to issue a Browser Resource Grant containing comments:read, the current Platform Account, exact resource, and a registered Project Client Browser Origin. The Project Client itself must also allow comments:read. Include reactions:read in that same grant only when the component should show aggregate reaction counts; the Project Client must allow that scope too.

Never expose the Project Credential. Return only the resulting five-minute, single-use grant and public Project Client/resource values to the page, then submit them from the registered origin into the iframe:

Html example
<iframe name="minicenter-comment-thread" title="Comments"></iframe>
<form action="https://sandbox.minicenter.otus.tw/api/v1/community/comments/embed"
      method="post" target="minicenter-comment-thread">
  <input type="hidden" name="token" value="SERVER_ISSUED_SINGLE_USE_GRANT">
  <input type="hidden" name="project_client_id" value="40000000-0000-4000-8000-000000000004">
  <input type="hidden" name="resource_type" value="article">
  <input type="hidden" name="resource_id" value="article-42">
  <button type="submit">Load comments</button>
</form>

Cross-origin form submission supplies the browser Origin; MiniCenter matches it with the registered origin and emits a frame-ancestors policy for that exact origin. Client, resource, comments:read, origin, expiry, and replay all fail closed. A failed or expired grant displays a generic unavailable state when the supplied client/origin pair is registered; request a fresh grant after any uncertain outcome.

The server-rendered component is keyboard and screen-reader accessible and escapes Comment text. It renders at most 100 top-level Comments and 500 direct replies total, grouped in accessible nested lists beneath visible parents. Reply loading uses the same consumed grant and one resource-scoped server query; it makes no per-parent browser request. Removed Comments or replies show Comment removed; restricted ones show Comment restricted; no retained body is exposed, and replies beneath a removed or restricted parent are omitted.

When the consumed grant also contains reactions:read, one batched resource-scoped query renders like, celebrate, insightful, and support counts for every visible rendered Comment and reply. A comments:read-only grant renders the thread without reaction data. Counts never enumerate Platform Accounts and are omitted for removed or restricted items; no additional token or browser request is used.

If either bound is reached, the component directs the reader to the Project Backend API for the remaining content. The beta has no recursive reply trees, reaction writes or actor history, browser writes, JavaScript dependency, Project Credential, account controls, or moderation controls. The Project Backend should keep its resource usable when MiniCenter is unavailable.