Skip to content

Rewrite NostrApiExamples - #239

Merged
tcheeric merged 1 commit into
developfrom
codex/rewrite-nostrapiexamples-class
Jul 31, 2025
Merged

tcheeric merged 1 commit into
developfrom
codex/rewrite-nostrapiexamples-class

Conversation

@tcheeric

Copy link
Copy Markdown
Owner

Summary

  • expand example to execute all event types
  • call metadata, note, DM, mentions, deletion, ephemeral, reaction and NIP28 events

Testing

  • mvn -q verify (fails: Docker environment not available)

https://chatgpt.com/codex/tasks/task_b_688abcf76dd48331b054ab3e55497eed

Copilot AI 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.

Pull Request Overview

This PR rewrites the NostrApiExamples class to execute all event types in a sequential manner instead of using a multi-threaded executor approach. The changes simplify the code structure while enabling comprehensive testing of all nostr-java API functionality including metadata, notes, direct messages, mentions, deletions, ephemeral events, reactions, and NIP28 channel operations.

Key changes:

  • Removed Spring Boot dependency and multi-threaded execution
  • Converted from ApplicationRunner to standalone main class with sequential execution
  • Uncommented and enabled all previously disabled event type examples
Comments suppressed due to low confidence (1)

nostr-java-examples/src/main/java/nostr/examples/NostrApiExamples.java:114

  • The unused variable tags was removed but the deletion event creation logic may be incomplete. Verify that the deletion event properly references the original event without explicit tag creation.
        var event = sendTextNoteEvent();

var reactionEvent = nip25.createReactionEvent(event.getEvent(), Reaction.LIKE, new Relay("localhost:5555"));
reactionEvent.signAndSend(RELAYS);
nip25.createReactionEvent(event.getEvent(), "💩", new Relay("localhost:5555")).signAndSend();
nip25.createReactionEvent(event.getEvent(), "\uD83D\uDCA9", new Relay("localhost:5555")).signAndSend();

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The Unicode escape sequence \uD83D\uDCA9 for the emoji is less readable than the original emoji character. Consider using the actual emoji character for better code readability.

Suggested change
nip25.createReactionEvent(event.getEvent(), "\uD83D\uDCA9", new Relay("localhost:5555")).signAndSend();
nip25.createReactionEvent(event.getEvent(), "💩", new Relay("localhost:5555")).signAndSend();

Copilot uses AI. Check for mistakes.
}

public static void filters() throws InterruptedException {
private static void filters() throws InterruptedException {

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

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

The filters() method visibility was changed from public to private, which may break external usage if this method was intended to be part of the public API for examples.

Suggested change
private static void filters() throws InterruptedException {
public static void filters() throws InterruptedException {

Copilot uses AI. Check for mistakes.
'\n' + '\n' + "################################ ACCOUNTS END ################################";

log.info(msg);
System.out.println(msg);

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Replacing structured logging (log.info) with System.out.println reduces the ability to control log levels and formatting. Consider using a simple logger or at least System.err for error cases.

Copilot uses AI. Check for mistakes.
@tcheeric
tcheeric merged commit 0ea0a82 into develop Jul 31, 2025
@tcheeric
tcheeric deleted the codex/rewrite-nostrapiexamples-class branch July 31, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants