Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4588519
Merge branch 'java21' into java21-merge_sig
avlo Dec 18, 2024
3a9d112
Merge branch 'develop' into temp_java21-merge_sig-dev
avlo Jan 4, 2025
aef0ad4
heavy refactor
avlo Jan 6, 2025
180e96a
merge req_message-validation
avlo Jan 13, 2025
2248a8a
explicit exception handling added for usages of BaseDecoder<>.decode(…
avlo Jan 13, 2025
e54a60f
sneaky throws
avlo Jan 13, 2025
3c2dd32
replace jetbrain @NotNull with lombok @NonNull, add unit tests
avlo Jan 19, 2025
c0c30a2
merge deprecated_client_removal
avlo Jan 19, 2025
89c1bd2
updated tests
avlo Jan 19, 2025
97b2155
replace boolean with AtomicBoolean for message handling synchronization
avlo Jan 25, 2025
ed95b99
websocket client update
avlo Jan 26, 2025
7ff7545
filters refactor
avlo Feb 2, 2025
5ee8e94
filters in own test directory
avlo Feb 2, 2025
85bbbbf
additional filter tests
avlo Feb 2, 2025
46ba956
module info
avlo Feb 2, 2025
be2dc42
test edge/null/empty cases
avlo Feb 2, 2025
4c8b52d
update using predicates
avlo Feb 3, 2025
d27e2f7
bug fixes
avlo Feb 3, 2025
279d00c
since until
avlo Feb 4, 2025
c2dfb74
ongoing, initial tests working
avlo Feb 6, 2025
0f62b0f
Merge branch 'deprecated_client_removal' into filters_refactor
avlo Feb 13, 2025
62e5d54
ongoing
avlo Feb 13, 2025
ed3491a
Merge branch 'command_handler_connection_removal-merge-req_msg_valida…
avlo Feb 13, 2025
99fc81e
ongoing
avlo Feb 13, 2025
0ea8117
ongoing filters
avlo Feb 16, 2025
595ac71
added identifier tag filter tests
avlo Feb 16, 2025
77a7f91
addressable tag filters tests
avlo Feb 16, 2025
5d73c92
filters encoding ongoing
avlo Feb 17, 2025
fc485b3
filters encoding ongoing
avlo Feb 17, 2025
a45b69e
fixed object filters
avlo Feb 18, 2025
8464f52
ongoing tests
avlo Feb 18, 2025
2c42bdc
ongoing filters
avlo Feb 18, 2025
2b8ef5b
ongoing filters
avlo Feb 18, 2025
36f24b6
ongoing filters
avlo Feb 18, 2025
c1a2637
ongoing filters
avlo Feb 18, 2025
286b451
ongoing filters
avlo Feb 18, 2025
5827520
ongoing filters
avlo Feb 18, 2025
3af2cbe
ongoing tests
avlo Feb 18, 2025
405f78f
ongoing tests
avlo Feb 19, 2025
d35e2ee
filters exception hanler testing
avlo Feb 19, 2025
8ed2146
since until fixes
avlo Feb 19, 2025
9ff0f09
Merge branch 'upstream-develop' into filters_refactor-upstream-develo…
avlo Feb 19, 2025
fdeb9f0
removed nostr-java-command-provider, replaced by NostrSpringWebSocket…
avlo Feb 19, 2025
6b8b3b5
cleanup
avlo Feb 19, 2025
3574642
kind updates
avlo Feb 20, 2025
64d8227
cleanup
avlo Feb 20, 2025
9ea4d33
removed empty tests
avlo Feb 20, 2025
9d15e3d
add convenience methods
avlo Feb 20, 2025
a20215f
cleanup
avlo Feb 20, 2025
3197bab
cleanup
avlo Feb 20, 2025
0b7b97f
cleanup
avlo Feb 20, 2025
4e251ac
refactored Filters ctors, map ctor now private
avlo Feb 21, 2025
d536c5c
Removed unused context modules
Feb 23, 2025
dd2f62b
0.6.4-SNAPSHOT
Feb 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nostr-java-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>xyz.tcheeric</groupId>
<artifactId>nostr-java</artifactId>
<version>0.6.3-SNAPSHOT</version>
<version>0.6.4-SNAPSHOT</version>
</parent>
<artifactId>nostr-java-api</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -45,9 +45,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nostr-java-command-provider</artifactId>
<version>${project.version}</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
</dependencies>
<properties>
Expand Down
6 changes: 3 additions & 3 deletions nostr-java-api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
requires nostr.id;
requires nostr.client;
requires nostr.context;
requires nostr.context.impl;
requires nostr.encryption;
requires nostr.encryption.nip04dm;
requires nostr.encryption.nip44dm;

requires com.fasterxml.jackson.databind;

requires lombok;
requires java.logging;
requires nostr.crypto;
requires org.apache.commons.lang3;

exports nostr.api;
}
15 changes: 8 additions & 7 deletions nostr-java-api/src/main/java/nostr/api/EventNostr.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import lombok.Setter;
import nostr.api.factory.impl.GenericEventFactory;
import nostr.base.PublicKey;
import nostr.event.BaseMessage;
import nostr.event.BaseTag;
import nostr.event.impl.GenericEvent;
import nostr.event.json.codec.BaseMessageDecoder;
import nostr.id.Identity;
import org.apache.commons.lang3.stream.Streams.FailableStream;

import java.util.List;
import java.util.Map;

import nostr.event.BaseMessage;
import java.util.Objects;

/**
* @author guilhermegps
Expand Down Expand Up @@ -46,14 +47,14 @@ public <U extends BaseMessage> U send() {
return this.send(getRelays());
}

@SuppressWarnings("unchecked")
public <U extends BaseMessage> U send(Map<String, String> relays) {
List<String> messages = super.send(this.event, relays);
BaseMessageDecoder<U> decoder = new BaseMessageDecoder<U>();
List<String> messages = super.sendEvent(this.event, relays);
BaseMessageDecoder<U> decoder = new BaseMessageDecoder<>();

return messages.stream()
return new FailableStream<>(messages.stream())
.map(msg -> (U) decoder.decode(msg))
.filter(msg -> msg != null)
.filter(Objects::nonNull)
.stream()
.findFirst()
.orElseThrow(() -> new RuntimeException("No message received"));
}
Expand Down
54 changes: 4 additions & 50 deletions nostr-java-api/src/main/java/nostr/api/NIP01.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
import nostr.api.factory.impl.NIP01Impl.ReplaceableEventFactory;
import nostr.api.factory.impl.NIP01Impl.ReqMessageFactory;
import nostr.api.factory.impl.NIP01Impl.TextNoteEventFactory;
import nostr.base.GenericTagQuery;
import nostr.base.IEvent;
import nostr.base.PublicKey;
import nostr.base.Relay;
import nostr.base.UserProfile;
import nostr.event.BaseTag;
import nostr.event.Kind;
import nostr.event.Marker;
import nostr.event.NIP01Event;
import nostr.event.impl.Filters;
import nostr.event.impl.GenericEvent;
import nostr.event.filter.Filters;
import nostr.event.message.CloseMessage;
import nostr.event.message.EoseMessage;
import nostr.event.message.EventMessage;
Expand All @@ -42,7 +39,6 @@
import nostr.id.Identity;

import java.util.List;
import java.util.Map;

/**
*
Expand Down Expand Up @@ -98,7 +94,7 @@ public NIP01<T> createMetadataEvent(@NonNull UserProfile profile) {

/**
* Create a replaceable event
*
*
* @param kind the kind (10000 <= kind < 20000 || kind == 0 || kind == 3)
* @param content the content
*/
Expand All @@ -111,7 +107,7 @@ public NIP01<T> createReplaceableEvent(@NonNull Integer kind, String content) {

/**
* Create a replaceable event
*
*
* @param tags the note's tags
* @param kind the kind (10000 <= kind < 20000 || kind == 0 || kind == 3)
* @param content the note's content
Expand All @@ -125,7 +121,7 @@ public NIP01<T> createReplaceableEvent(@NonNull List<BaseTag> tags, @NonNull Int

/**
* Create an ephemeral event
*
*
* @param kind the kind (20000 <= n < 30000)
* @param content the note's content
*/
Expand Down Expand Up @@ -190,48 +186,6 @@ public static PubKeyTag createPubKeyTag(@NonNull PublicKey publicKey, String mai
return result;
}

/**
* Create a NIP01 filters object (all parameters are optional)
*
* @param events a list of event
* @param authors a list of pubkeys or prefixes, the pubkey of an event
* must
* be one of these
* @param kinds a list of a kind numbers
* @param referencedEvents a list of event ids that are referenced in an "e"
* tag
* @param referencePubKeys a list of pubkeys that are referenced in a "p"
* tag
* @param since an integer unix timestamp in seconds, events must be
* newer
* than this to pass
* @param until an integer unix timestamp in seconds, events must be
* older
* than this to pass
* @param limit maximum number of events to be returned in the
* initial query
* @param genericTagQuery a generic tag query
* @return a filters object
*/
@Deprecated(forRemoval = true)
public static Filters createFilters(List<GenericEvent> events, List<PublicKey> authors, List<Kind> kinds,
List<GenericEvent> referencedEvents, List<PublicKey> referencePubKeys, Long since, Long until,
Integer limit, GenericTagQuery genericTagQuery) {
return Filters.builder()
.authors(authors)
.events(events)
.genericTagQuery(
Map.of(
genericTagQuery.getTagName(),
genericTagQuery.getValue()))
.kinds(kinds).limit(limit)
.referencePubKeys(referencePubKeys)
.referencedEvents(referencedEvents)
.since(since)
.until(until)
.build();
}

/**
* Create an event message to send events requested by clients
*
Expand Down
21 changes: 14 additions & 7 deletions nostr-java-api/src/main/java/nostr/api/NIP52.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package nostr.api;

import lombok.NonNull;
import nostr.api.factory.impl.NIP52Impl.CalendarRsvpEventFactory;
import nostr.api.factory.impl.NIP52Impl.CalendarTimeBasedEventFactory;
import nostr.event.BaseTag;
import nostr.event.NIP52Event;
import nostr.event.impl.CalendarContent;
import nostr.event.impl.CalendarRsvpContent;
import nostr.id.Identity;

import java.util.List;

public class NIP52<T extends NIP52Event> extends EventNostr<T> {
public NIP52(@NonNull Identity sender) {
setSender(sender);
}
public NIP52(@NonNull Identity sender) {
setSender(sender);
}

public NIP52<T> createCalendarTimeBasedEvent(@NonNull List<BaseTag> baseTags, @NonNull String content, @NonNull CalendarContent calendarContent) {
setEvent((T) new CalendarTimeBasedEventFactory(getSender(), baseTags, content, calendarContent).create());
return this;
}
public NIP52<T> createCalendarTimeBasedEvent(@NonNull List<BaseTag> baseTags, @NonNull String content, @NonNull CalendarContent calendarContent) {
setEvent((T) new CalendarTimeBasedEventFactory(getSender(), baseTags, content, calendarContent).create());
return this;
}

public NIP52<T> createCalendarRsvpEvent(@NonNull List<BaseTag> baseTags, @NonNull String content, @NonNull CalendarRsvpContent calendarRsvpContent) {
setEvent((T) new CalendarRsvpEventFactory(getSender(), baseTags, content, calendarRsvpContent).create());
return this;
}
}
Loading