feat(gists): expose is_active, report_count and GET /v1/moderator endpoint - #1063
Conversation
BigBen-7
left a comment
There was a problem hiding this comment.
Thanks kike-alt — the is_active/report_count response mapping and the new GET /v1/moderator route are well done, and I confirmed the route registration order is correct (moderator before :id, same pattern as the existing count route). Once reconciled, build and the full suite pass (15 suites, 131 passed, 0 failures).
Three things needed before merge:
1. Merge conflict with #1066 (now on main). Trivial adjacency in soroban.service.ts — your getAdmin() landed right next to #1066's new getLatestLedger(). Both are independent and coexist fine; just needs a rebase.
2. getAdmin() doesn't query the actual deployed contract. Right now it reads a MODERATOR_ADDRESS config value (which also isn't in .env.example) instead of calling the live GistRegistry contract's get_admin() on-chain method. The whole point of this endpoint is to expose the real on-chain moderator — as written, it could silently drift from what's actually set on-chain (e.g. if the config value is never updated after a moderator change via initialize), which defeats the purpose. Could you implement it the same way isActive/listGistsByCell call the contract (a simulateTransaction read call to get_admin), with mock mode falling back to a config/default value the way those methods do?
3. Coordination note on is_active/report_count. I've asked Ibinola (#1036/#1064) to add the migration + entity columns for these, since that PR is the one writing them via the indexer. Your entity changes here duplicate that — once #1064's migration lands on main, you'll likely need another quick rebase to avoid a duplicate column declaration. Not blocking now, just a heads-up so it doesn't surprise you.
Once #1 and #2 are addressed, this is close to ready — I'll flag #3 again if it becomes a real conflict once #1064 lands.
62acb75 to
d941333
Compare
BigBen-7
left a comment
There was a problem hiding this comment.
Tested locally (checked out the branch, ran npx jest src/gists — 18/19 passing, 1 todo, all green). The logic itself is fine, but I found two things that will break outside of the mocked test environment:
1. Missing migration for the new columns
report_count and is_active are added to Gist (Backend/src/gists/entities/gist.entity.ts) but there's no accompanying TypeORM migration. This repo runs with synchronize: false (both data-source.ts and database.module.ts), and every prior column addition — hidden, expires_at, author_address — shipped with its own migration file under Backend/src/database/migrations/. Without one here, report_count/is_active simply won't exist in any real Postgres database, so GET /v1/gists/:id and the new /v1/gists/moderator decoration will throw "column does not exist" as soon as they hit a live DB. Unit tests don't catch this because GistsService/GistRepository are fully mocked.
Could you add a migration analogous to AddGistHiddenColumn1750000000003.ts?
2. getAdmin() doesn't read the actual on-chain moderator
In Backend/src/soroban/soroban.service.ts, getAdmin() — in both mock and live mode — just returns the MODERATOR_ADDRESS env var. It never calls the contract. The GistRegistry contract already exposes get_admin() on-chain (contracts/src/lib.rs:255), and the existing live-mode pattern for reads (getGistLive, isActive — see contract.call('get_gist', ...) / contract.call('is_active', ...) via simulateTransaction) is right there to follow. As written, GET /v1/gists/moderator can't actually reflect the real on-chain moderator — it just echoes back whatever's in config, which defeats the point of issue #1038 and will drift silently if the two ever disagree.
Happy to re-review once these are addressed — everything else (controller wiring, DTO shape, tests) looks solid.
…point - Expose is_active and report_count in GET /v1/gists/:id responses. - Add GET /v1/moderator endpoint returning the current moderator address. - Add Swagger documentation and unit tests for new endpoint and response shape. Closes PinSpace-Org#1038
d941333 to
cbcffdd
Compare
BigBen-7
left a comment
There was a problem hiding this comment.
Re-reviewed and re-tested locally against the updated branch.
- Migration
AddGistIsActiveAndReportCountColumns1750000000004.tsadded, matches the existing pattern (ADD COLUMN IF NOT EXISTS, properdown()). getAdmin()now calls the real contract in live mode (contract.call('get_admin')viasimulateTransaction, wrapped inwithRetrylike the other live methods), and mock mode is unchanged — both concerns from the previous review are resolved.npx jest src/gists→ 18/19 passing (1 pre-existing todo), same as before.
Approving and merging.
Summary
Exposes gist status (
is_active,report_count) in Gist API responses and adds theGET /v1/moderatorendpoint.Changes
report_countandis_activefields toGistentity and controller responses.GET /v1/moderatorendpoint.gists.controller.spec.ts.Closes #1038