Skip to content

Serve NodeInfo 2.0 and 2.1 while federation is on - #496

Merged
laffer1 merged 1 commit into
masterfrom
activitypub-nodeinfo
Nov 2, 2026
Merged

laffer1 merged 1 commit into
masterfrom
activitypub-nodeinfo

Conversation

@laffer1

@laffer1 laffer1 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fediverse servers and directories read NodeInfo to learn what software a site runs and how big it is. JustJournal had none, so it showed up as unknown software.

Endpoints

  • GET /.well-known/nodeinfo links the 2.0 and 2.1 documents, always over https.
  • GET /nodeinfo/2.0 and GET /nodeinfo/2.1 return the documents. The content type is application/json with the schema profile. 2.1 adds software.repository and software.homepage.
  • While activitypub.federation.enabled is off, all three return 404.
  • Responses carry Access-Control-Allow-Origin: *, as the figures are public.

What it reports

  • Software: name justjournal, with the version from Spring Boot build-info. This adds a build-info execution to spring-boot-maven-plugin; without build information, as in an IDE, the version is unknown.
  • Protocols: activitypub. Outbound services: atom1.0 and rss2.0.
  • openRegistrations: follows the existing userAllowNew setting, which sign-up already obeys. No new config.
  • Usage:
    • users.total counts every account, not only journals that federate (your choice). It is the same total the site statistics already publish.
    • activeMonth and activeHalfyear count users whose lastlogin is within 30 and 180 days.
    • localPosts counts public entries, as the site statistics do.
    • The counts are kept in memory for an hour.
  • metadata.nodeName: the site name, when it is set.

Testing

  • New: NodeInfoControllerTests (6) and NodeInfoServiceTests (2). They cover both documents, discovery, closed sign-up, missing build information, the 404s with federation off and unknown schema versions, and the hourly recount.
  • Full unit suite: 1839 tests, 0 failures. spring-boot:build-info writes build.version=3.2.1.
  • Not verified:
    • the derived countByLastLoginAfter query on MySQL 8;
    • a real crawler or directory reading the documents.

🤖 Generated with Claude Code

Summary by Sourcery

Expose standards-compliant NodeInfo metadata while federation is enabled.

New Features:

  • Add NodeInfo 2.0 and 2.1 discovery and document endpoints for federated site metadata and usage statistics.

Enhancements:

  • Expose cached account activity and public-entry counts for NodeInfo usage reporting.
  • Report application build versions through generated Spring Boot build information, with an unknown fallback when unavailable.

Build:

  • Configure the Spring Boot Maven plugin to generate build information.

Tests:

  • Add controller and service coverage for NodeInfo schemas, federation gating, metadata, build-version fallbacks, and hourly usage refreshes.

Fediverse servers and directories read /.well-known/nodeinfo to learn
what software a site runs and how big it is; without it JustJournal
shows up as unknown software. The figures count every account, the
accounts that logged in within 30 and 180 days, and public entries,
the same totals the site statistics already publish. They are counted
at most once an hour. openRegistrations follows userAllowNew, which
sign-up already obeys. The version comes from Spring Boot build-info.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Sorry @laffer1, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 hours and 27 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR adds federation-gated NodeInfo 2.0/2.1 discovery and documents, generating software version data from Maven build metadata and reporting cached site-wide usage statistics, with repository support and targeted controller/service tests.

Sequence diagram for federation-gated NodeInfo discovery and documents

sequenceDiagram
    participant Crawler
    participant NodeInfoController
    participant FederationPolicy
    participant NodeInfoService
    participant BuildProperties
    participant Settings

    Crawler->>NodeInfoController: GET /.well-known/nodeinfo
    NodeInfoController->>FederationPolicy: isEnabled()
    alt federation enabled
        NodeInfoController->>Settings: getBaseUri()
        NodeInfoController-->>Crawler: 200 JSON links for 2.0 and 2.1
        Crawler->>NodeInfoController: GET /nodeinfo/2.1
        NodeInfoController->>FederationPolicy: isEnabled()
        NodeInfoController->>BuildProperties: getIfAvailable()
        NodeInfoController->>NodeInfoService: usage()
        NodeInfoService-->>NodeInfoController: cached or recounted Usage
        NodeInfoController->>Settings: isUserAllowNew(), getSiteName()
        NodeInfoController-->>Crawler: 200 JSON with profile content type and CORS
    else federation disabled
        NodeInfoController-->>Crawler: 404 Not Found
    end
Loading

File-Level Changes

Change Details Files
Add federation-gated NodeInfo discovery and document endpoints for schemas 2.0 and 2.1.
  • Publish HTTPS discovery links for both supported schema versions.
  • Return schema-specific software, protocol, service, registration, usage, and metadata fields.
  • Set the JSON profile content type and permissive CORS header; reject requests when federation is disabled or the schema is unsupported.
src/main/java/com/justjournal/ctl/NodeInfoController.java
Implement cached site-usage metrics and login activity counts for NodeInfo.
  • Count all users, users active in the last 30 and 180 days, and public entries.
  • Cache calculated figures for one hour with an injectable clock and synchronized refresh.
  • Add the derived repository query for users whose last login is after a supplied date.
src/main/java/com/justjournal/services/activitypub/NodeInfoService.java
src/main/java/com/justjournal/repository/UserRepository.java
Expose the application build version to NodeInfo responses.
  • Configure Spring Boot to generate build-info metadata during Maven builds.
  • Fall back to unknown when build metadata is unavailable.
pom.xml
src/main/java/com/justjournal/ctl/NodeInfoController.java
Add focused coverage for endpoint behavior and usage-cache semantics.
  • Test discovery, both document versions, headers, registration and metadata variants, federation gating, unsupported versions, and missing build information.
  • Test metric calculation and recounting at the one-hour boundary.
src/test/java/com/justjournal/ctl/NodeInfoControllerTests.java
src/test/java/com/justjournal/services/activitypub/NodeInfoServiceTests.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@laffer1

laffer1 commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@deepsource-io

deepsource-io Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in 55c2ba5...deaf25b on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Nov 2, 2026 9:09p.m. Review ↗
Java Nov 2, 2026 9:09p.m. Review ↗
Shell Nov 2, 2026 9:09p.m. Review ↗
JavaScript Nov 2, 2026 9:09p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@laffer1
laffer1 merged commit 02414a2 into master Nov 2, 2026
10 of 11 checks passed
@laffer1
laffer1 deleted the activitypub-nodeinfo branch November 2, 2026 21:11
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.

1 participant