Skip to content

feat(gists): expose is_active, report_count and GET /v1/moderator endpoint - #1063

Merged
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
kike-alt:feature/expose-moderation-and-gist-status-1038
Aug 21, 2026
Merged

feat(gists): expose is_active, report_count and GET /v1/moderator endpoint#1063
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
kike-alt:feature/expose-moderation-and-gist-status-1038

Conversation

@kike-alt

Copy link
Copy Markdown
Contributor

Summary

Exposes gist status (is_active, report_count) in Gist API responses and adds the GET /v1/moderator endpoint.

Changes

  • Added report_count and is_active fields to Gist entity and controller responses.
  • Added GET /v1/moderator endpoint.
  • Added Swagger documentation and unit tests in gists.controller.spec.ts.

Closes #1038

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kike-alt
kike-alt force-pushed the feature/expose-moderation-and-gist-status-1038 branch from 62acb75 to d941333 Compare August 20, 2026 12:45

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@kike-alt
kike-alt force-pushed the feature/expose-moderation-and-gist-status-1038 branch from d941333 to cbcffdd Compare August 21, 2026 15:11

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed and re-tested locally against the updated branch.

  • Migration AddGistIsActiveAndReportCountColumns1750000000004.ts added, matches the existing pattern (ADD COLUMN IF NOT EXISTS, proper down()).
  • getAdmin() now calls the real contract in live mode (contract.call('get_admin') via simulateTransaction, wrapped in withRetry like 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.

@BigBen-7
BigBen-7 merged commit a4faa5e into PinSpace-Org:main Aug 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose is_active, report_count and moderator address over the API

2 participants