Foundry Module: Show pairing status #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
Now I understand the codebase. Let me look at how the module's settings and link flow work once more, then implement.
Now the tests for the new behaviour:
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(samesyncCampaigntoken check as the other sync routes, already covered by the/api/foundry/syncCORS rule) returns{campaign: {id, name}, worldId}; after a campaign unlinks the world the token hashes to nothing and it answersunauthorized, which is what flips the module back to "no longer linked".POST /foundry/link/completealso 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-Foundrynode:vmharness, 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'ssyncRequests()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 inAGENTS.md.The backend route itself is not covered by an automated test (this repo has no backend test setup — no Mongo,
backend/node_modulesis empty); it reuses the existingsyncCampaignhelper that every other sync route uses, and the module's handling of both its answers is tested.Implementation is ready for review: #18
The automated implementation stopped because of an internal error. Please check the worker logs for details.