Foundry Module: Show pairing status #17

Closed
opened 2026-10-14 12:36:09 +00:00 by Syndria98 · 5 comments
Owner

On the module settings in the foundry module, show the pairing status with an existing dragonroll campaign. A text should be displayed if the campaign is connected to a dragonroll campaign or not

On the module settings in the foundry module, show the pairing status with an existing dragonroll campaign. A text should be displayed if the campaign is connected to a dragonroll campaign or not
Syndria98 added the ai-ready label 2026-10-14 12:36:09 +00:00
Agent added the working label 2026-10-14 12:36:11 +00:00
Collaborator

Now I understand the codebase. Let me look at how the module's settings and link flow work once more, then implement.

Now I understand the codebase. Let me look at how the module's settings and link flow work once more, then implement.
Collaborator

Now the tests for the new behaviour:

Now the tests for the new behaviour:
Collaborator

Implemented. Summary of what changed and why:

dragonroll-foundry/scripts/api.js — new Dragonroll Pairing Status setting (pairingStatus, client scope, config: true) that shows up in the module settings right under the pairing code. Its text always states the pairing state:

  • Connected to the Dragonroll campaign "Curse of Strahd".
  • Connected to a Dragonroll campaign. (paired, not yet verified against Dragonroll)
  • Not connected yet: waiting for Dragonroll to accept this pairing code. (code pending, retry still running)
  • Not connected: Dragonroll did not accept that pairing code (The pairing code is invalid, expired, or already used.)
  • Not connected: this world is no longer linked to the Dragonroll campaign it was paired with. …
  • Not connected to a Dragonroll campaign. Paste a pairing code from that campaign's settings to link this world.

It is written by the module, not the GM: on world start, after every pairing attempt, and once a minute; anything typed into the field is replaced by the real status. A Dragonroll that is unreachable (or old enough to lack the status route) leaves the client-side status untouched rather than making it lie.

backend/src/routes/foundry-link.js — the status needs more than the local token, so:

  • GET /api/foundry/sync/status (same syncCampaign token check as the other sync routes, already covered by the /api/foundry/sync CORS rule) returns {campaign: {id, name}, worldId}; after a campaign unlinks the world the token hashes to nothing and it answers unauthorized, which is what flips the module back to "no longer linked".
  • POST /foundry/link/complete also returns the campaign, so the status names it the moment the world pairs.

Tests — tests/foundry-pairing-status.test.js (9 tests) drives the module in the same stubbed-Foundry node:vm harness, with each test choosing Dragonroll's answer: never paired, paired and named, campaign unlinked the world, Dragonroll without the status route, code rejected for good, code still retrying, redeeming a code, and hand-editing the status. The existing harness's syncRequests() now excludes the read-only status GET from "sync pushes". npm test: 19 tests, 19 pass, 0 fail.

Docs — pairing-status paragraph and the new route in dragonroll-foundry/README.md; route table entry plus a "the module writes this setting" rule in AGENTS.md.

The backend route itself is not covered by an automated test (this repo has no backend test setup — no Mongo, backend/node_modules is empty); it reuses the existing syncCampaign helper that every other sync route uses, and the module's handling of both its answers is tested.

Implemented. Summary of what changed and why: **`dragonroll-foundry/scripts/api.js`** — new **Dragonroll Pairing Status** setting (`pairingStatus`, client scope, `config: true`) that shows up in the module settings right under the pairing code. Its text always states the pairing state: - `Connected to the Dragonroll campaign "Curse of Strahd".` - `Connected to a Dragonroll campaign.` (paired, not yet verified against Dragonroll) - `Not connected yet: waiting for Dragonroll to accept this pairing code.` (code pending, retry still running) - `Not connected: Dragonroll did not accept that pairing code (The pairing code is invalid, expired, or already used.)` - `Not connected: this world is no longer linked to the Dragonroll campaign it was paired with. …` - `Not connected to a Dragonroll campaign. Paste a pairing code from that campaign's settings to link this world.` It is written by the module, not the GM: on world start, after every pairing attempt, and once a minute; anything typed into the field is replaced by the real status. A Dragonroll that is unreachable (or old enough to lack the status route) leaves the client-side status untouched rather than making it lie. **`backend/src/routes/foundry-link.js`** — the status needs more than the local token, so: - `GET /api/foundry/sync/status` (same `syncCampaign` token check as the other sync routes, already covered by the `/api/foundry/sync` CORS rule) returns `{campaign: {id, name}, worldId}`; after a campaign unlinks the world the token hashes to nothing and it answers `unauthorized`, which is what flips the module back to "no longer linked". - `POST /foundry/link/complete` also returns the campaign, so the status names it the moment the world pairs. **Tests** — `tests/foundry-pairing-status.test.js` (9 tests) drives the module in the same stubbed-Foundry `node:vm` harness, with each test choosing Dragonroll's answer: never paired, paired and named, campaign unlinked the world, Dragonroll without the status route, code rejected for good, code still retrying, redeeming a code, and hand-editing the status. The existing harness's `syncRequests()` now excludes the read-only status GET from "sync pushes". `npm test`: 19 tests, 19 pass, 0 fail. **Docs** — pairing-status paragraph and the new route in `dragonroll-foundry/README.md`; route table entry plus a "the module writes this setting" rule in `AGENTS.md`. The backend route itself is not covered by an automated test (this repo has no backend test setup — no Mongo, `backend/node_modules` is empty); it reuses the existing `syncCampaign` helper that every other sync route uses, and the module's handling of both its answers is tested.
Collaborator

Implementation is ready for review: #18

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/18
Collaborator

The automated implementation stopped because of an internal error. Please check the worker logs for details.

The automated implementation stopped because of an internal error. Please check the worker logs for details.
Agent removed the working label 2026-10-14 12:59:27 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#17