Skip to content

Rewrite NostrApiExamples #239

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

Merged
merged 1 commit into from
Jul 31, 2025
Merged

Conversation

tcheeric
Copy link
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

Copy link
Contributor

@Copilot Copilot AI left a comment

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();

@@ -246,9 +150,8 @@ private static void reactionEvent() {
var nip25 = new NIP25(RECIPIENT);
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();
Copy link
Preview

Copilot AI Jul 31, 2025

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.

@@ -283,7 +186,7 @@ private static void internetIdMetadata() {
.send(RELAYS);
}

public static void filters() throws InterruptedException {
private static void filters() throws InterruptedException {
Copy link
Preview

Copilot AI Jul 31, 2025

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.

@@ -375,7 +278,7 @@ private static void logAccountsData() {
'\n' + "* PublicKey HEX: " + SENDER.getPublicKey().toString() +
'\n' + '\n' + "################################ ACCOUNTS END ################################";

log.info(msg);
System.out.println(msg);
Copy link
Preview

Copilot AI Jul 31, 2025

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.

1 participant