8000 Implement v2 journalist API by legoktm · Pull Request #7604 · freedomofpress/securedrop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement v2 journalist API #7604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

Implement v2 journalist API #7604

wants to merge 2 commits into from

Conversation

legoktm
Copy link
Member
@legoktm legoktm commented Jul 3, 2025

Fixes #

Test plan

Checklist

This change accounts for:

  • any required additional documentation
  • any necessary AppArmor changes (added or removed application files)
  • any impact on new SecureDrop installs and upgrades
  • our dependency update policy

@legoktm
Copy link
Member Author
legoktm commented Jul 3, 2025

Some notable changes compared to Cory's spec:

  • Having models inherit from VersionedItem and sqlalchemy mixes metaclasses and it blows up. So for now I'm just duck typing the necessary methods.
  • I renamed the existing to_json() methods to to_json_v1() and added in new to_json_v2() methods, and slimmed the responses where possible.
  • I didn't implement VersionedCollection...I'm not super sure where Cory intended for it to be used. I included all the collection metadata inside the source metadata so it's part of the version, maybe that's wrong?

Some very rough numbers against my dev instance w/ 750 sources, keep in mind that I've done zero optimizations so far and this is all in Qubes so the timing is pretty variable and unoptimized:

  • index: 63.93s
  • index2: 37.35s (checking if-none-match behavior)
  • sources: 38.03s (requesting metadata for all 750 sources at once)

I think getting it down to 1-2s w/ 1k+ sources is pretty doable.

I think the API code, minus caching and prefix search, is basically done? I stuck with using flask_smorest, et al. for the initial implementation, but if this is what the API ends up being, I would probably get drop it and handwrite the like two validation routines. If we want an OpenAPI spec, I think an LLM would be able to generate it pretty easily from a sample response.

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.

2 participants
0