-
Notifications
You must be signed in to change notification settings - Fork 24
Java 21 et merge #190
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
Java 21 et merge #190
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…Factory added required arrayNode item "subscriptionId" to EventMessage encoder fixed CanonicalAuthenticationMessage decoder
…ance to use and since the client API doesn't directly support relay responses, i've added a small/simple/useful client implementation leveraging springframework WebSocketClient atop reactive-streams, composed of 4 parts: implementation: 1) dependencies added to nostr-java-api pom.xml: springframework dependencies: spring-websocket spring-webflux and reactor dependency: reactor-netty-http 2) small/simple WebSocketClient reference implementation, in files: nostr-java-client/src/main/java/nostr/client/springwebsocket/SpringWebSocketClient.java nostr-java-client/src/main/java/nostr/client/springwebsocket/WebSocketClient.java nostr-java-client/src/main/java/nostr/client/springwebsocket/WebSocketHandler.java 3) minimal/tiny changes to current codebase for spring websocketclient integration - class Nostr public method signatures cloned into interface NostrIF - class Nostr now implements NostrIF - added class NostrSpringWebSocketClient, also implements NostrIF (this class wraps Spring WebSocketClient reference implementation mentioned above) 4) class EventNostr formerly: public abstract class EventNostr<T extends GenericEvent> extends Nostr now public abstract class EventNostr<T extends GenericEvent> extends NostrSpringWebSocketClient all remaining nostr-java classes/heirarchiess/calls/etc remain unchanged testing: 2) ApiEventTest methods that send events to relay have been supplemented with callback logic, i.e.,: await().until(() -> Objects.nonNull(nip01.getRelayResponse())); nip01.close();
…d json correctness
various updated files, new files and test classes, categorized and described below: updated files/classes: pom.xml jdk 21 BaseEvent.java removed superfluous/unused internal ProxyEvent Nostr.java now implements NostrIF interface (for pluggable/polymorphic client implementations) send() methods now returns List<String> (relay response) instead of void Kind.java added PRODUCT_CREATE_OR_UPDATE(30_018, "create_or_update_product"), CALENDAR_DATE_BASED_EVENT(31_922, "calendar_date_based_event"), CALENDAR_TIME_BASED_EVENT(31_923, "calendar_time_based_event"), GenericEventDecoder.java added additional constructor accepting clazz customization parameter IdentifierTag.java added polymorphic deserialize() method TagDeserializer.java added IdentifierTag to switch case ClassifiedListing.java added builder added jsondeserialize using builder ClassifiedListingEvent.java added builder added jsondeserialize using builder added custom tag mapper ZapReceiptEvent.java added validate() method ZapRequestEvent.java added validate() method nostr-java-client/pom.xml and nostr-java-test/pom.xml added spring dependencies for: jakarta.websocket-api jakarta.websocket-client-api spring-websocket standard websockets spring-webflux reactive websockets reactor-netty-http reactive websockets nostr-java-event/pom.xml removed googlecode openbeans, use already available java.beans instead java.net.URL updated to java.net.URI in classes: NIP12.java NIP12Impl.java ReferenceTagSerializer.java ReferenceTag.java ---- new classes: NIP52.java NIP52Impl.java NIP52Event.java CalendarTimeBasedEvent.java CalendarContent.java NostrIF.java abstraction for pluggable client implementations, ex: Nostr.java NostrSpringWebSocketClient.java NostrSpringWebSocketClient.java SpringWebSocketClient implementation ReactiveWebSocketClient.java web-socket w/ reactive streams StandardWebSocketClient.java standard web-socket (non-reactive) WebSocketClient.java base interface contract for client implementations JsonComparator.java utility class for tests new test classes, self explanatory: ApiEventTestUsingSpringWebSocketClientTest.java ApiNIP52EventTest.java ApiNIP52RequestTest.java ApiNIP99EventTest.java ApiNIP99RequestTest.java CalendarContentDecodeTest.java CalendarTimeBasedEventTest.java ---- test/example classes: NostrApiExamples.java updated to receive relay responses
…nal classes changed (EventNostr.java and GenericEvent.java)- as well as minimizing changes in each file- descriptions/motivations for said changes are as follows: ~~~~ (newly introduced) interface NostrIF.java created to support pluggable client implementations existing class Nostr.java now implements NostrIF new class NostrSpringWebSocketClient.java implements NostrIF ~~~~ (updated) class EventNostr.java to demonstrate relay event responses to a websocket client, EventNostr.java now extends NostrSpringWebSocketClient.java instead of Nostr.java (which, in it's current state, does not handle relay responses) background: per NIP-01 section [From relay to client: sending events and notices](https://github.com/nostr-protocol/nips/blob/master/01.md#from-relay-to-client-sending-events-and-notices): OK messages MUST be sent in response to EVENT messages received from clients indicating that previously defined EventNostr.java send(...) methods had (incorrect) return type T (where <T extends GenericEvent>): public T send() public T send(Map<String, String> relays) public T signAndSend() public T signAndSend(Map<String, String> relays) thus have been updated to instead return (correct) return type OkMessage public OkMessage send() public OkMessage send(Map<String, String> relays) public OkMessage signAndSend() public OkMessage signAndSend(Map<String, String> relays) ~~~~ (updated) GenericEvent.java added protected methods: addStandardTag(...) addGenericTag(...) available to classes extending GenericEvent which require customized tag mapping. examples of their use can be seen in: CalendarTimeBasedEvent.java ClassifiedListingEvent.java with remaining classes extending GenericEvent left unaffected unless/until such time custom mappings are useful/necessary for them. ~~~~ (updated) ApiEventTest.java tests calling instance.xyz.send() now receive relay responses ~~~~ relays.properties if useful/helpful, [superconductor nostr relay](https://github.com/avlo/superconductor) is available for use (and is built atop nostr-java). please see its [README](https://github.com/avlo/superconductor) for instructions and feel free to reach out to me for assistance if needed.
updated BaseMessage encode() with Optional.ofNullable(subscriptionId)
…entTest.getRelays(), which uses relays.properties test now iterates for each URI in map
…pdate for its create() method
…elay implementations may behave differently.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.