Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
89b19aa
docs: add comprehensive PR for all changes from 0.2.2 to 0.5.1
Oct 5, 2025
76bd6cb
style: fix Qodana findings (javadoc order, regex, redundant cast, com…
Oct 6, 2025
d69c0c5
refactor: address additional Qodana issues (duplicate expressions, re…
Oct 6, 2025
c22e564
style: suppress unchecked warnings and remove redundant casts across …
Oct 6, 2025
edac1fd
chore: restore workflow, qodana config, and docs removed inadvertently
Oct 6, 2025
cc1a5d3
refactor: use typed tag helpers across API and events; add code-aware…
Oct 6, 2025
520d866
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
bed8994
Merge remote-tracking branch 'origin/develop' into chore/qodana-fixes
Oct 6, 2025
68114ed
chore(bom): bump to 1.1.1 and remove local JUnit overrides; test: qua…
Oct 6, 2025
e198b6e
chore(version): bump project version to 0.6.0 across poms and docs
Oct 6, 2025
6146268
Merge pull request #453 from tcheeric/chore/qodana-fixes
tcheeric Oct 6, 2025
98df86e
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
6e1ee6a
fix(logging): improve error messages and log levels per Clean Code gu…
Oct 6, 2025
911ab87
refactor(logging): remove constructor logging from low-level key classes
Oct 6, 2025
33270a7
refactor(test): remove test method name logging per Clean Code guidel…
Oct 6, 2025
337bce4
refactor(logging): extract duplicated recovery logging in SpringWebSo…
Oct 6, 2025
90a4c8b
chore: bump version to 0.6.1
Oct 6, 2025
1feba9f
Merge pull request #454 from tcheeric/chore/bump-version-0.6.1
tcheeric Oct 6, 2025
a988d62
fix(logging): improve error messages and log levels per Clean Code gu…
Oct 6, 2025
5ffd3e7
refactor(logging): remove constructor logging from low-level key classes
Oct 6, 2025
37ea04b
refactor(test): remove test method name logging per Clean Code guidel…
Oct 6, 2025
6326f23
refactor(logging): extract duplicated recovery logging in SpringWebSo…
Oct 6, 2025
e813346
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
c0e6509
docs(javadoc): fix plain-text NIP links to anchors; fully-qualify Jav…
Oct 6, 2025
7dc0019
docs(javadoc): address Qodana javadoc items (anchor NIP links, fully-…
Oct 6, 2025
f5ce0ad
chore: bump version to 0.6.2 and tighten fields per Qodana (FieldMayB…
Oct 6, 2025
93c5c2c
test: configure Mockito to use subclass mock-maker via SPI and surefi…
Oct 6, 2025
529b849
Merge pull request #455 from tcheeric/chore/qodana-final-and-bump-0.6.2
tcheeric Oct 6, 2025
7e9c139
fix: replace generic exception handling
tcheeric Oct 6, 2025
ec39a51
Merge pull request #456 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
9995e9f
fix: replace sneaky throws with explicit handling
tcheeric Oct 6, 2025
1a86ffb
Merge pull request #457 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
176020d
refactor: unify nostr exception hierarchy
tcheeric Oct 6, 2025
a555d0a
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
7816173
Merge pull request #458 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
981c57d
refactor: modularize nip helpers and client orchestration
tcheeric Oct 6, 2025
f11f80a
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
8ce884d
Merge pull request #459 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
241cbe2
refactor: streamline subscriptions and zap parameters
tcheeric Oct 6, 2025
5a52f53
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
e9a3248
Merge pull request #460 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
9397543
docs: clarify api documentation
tcheeric Oct 6, 2025
028d724
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
1c4ddf0
Merge pull request #461 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
b2abab2
refactor: normalize event cache naming and mapper access
tcheeric Oct 6, 2025
7ca269c
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
6c89350
Merge pull request #462 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
67a565a
fix(api): allow optional sender when constructing websocket client
tcheeric Oct 6, 2025
398fc69
Merge pull request #463 from tcheeric/codex/fix-ci-error
tcheeric Oct 6, 2025
e2c80fc
refactor: abstract relay clients and codify nip ranges
tcheeric Oct 6, 2025
d3499a1
Merge branch 'develop' into codex/create-tasks-for-milestone-1-ylzf9j
tcheeric Oct 6, 2025
9ee96ee
Merge pull request #464 from tcheeric/codex/create-tasks-for-mileston…
tcheeric Oct 6, 2025
6b2a597
feat: finalize calendar decoding and generic event builder
tcheeric Oct 6, 2025
175b159
Merge branch 'develop' into codex/create-tasks-for-milestone-1-mt6702
tcheeric Oct 6, 2025
afdb80a
Merge pull request #465 from tcheeric/codex/create-tasks-for-mileston…
tcheeric Oct 6, 2025
69fefe1
build(pom): restore BOM version to 1.1.1 and re-add internal module o…
Oct 6, 2025
00c2ab5
chore(deps): bump org.sonatype.central:central-publishing-maven-plugin
dependabot[bot] Oct 6, 2025
7b71243
docs: complete Phase 2 documentation enhancement
Oct 6, 2025
223d911
Merge pull request #467 from tcheeric/docs/phase-2-documentation-enha…
tcheeric Oct 6, 2025
8216182
Merge pull request #466 from tcheeric/dependabot/maven/develop/org.so…
tcheeric Oct 6, 2025
0925bbd
docs: complete Phase 2 Task 5 - extended JavaDoc for NIPs and exceptions
Oct 6, 2025
2844e5e
chore: organize project management files into .project-management folder
Oct 6, 2025
6635cc4
chore: rename logging review and improvements markdown files
Oct 6, 2025
cfac008
Merge pull request #468 from tcheeric/docs/phase-2-extended-javadoc
tcheeric Oct 6, 2025
4ed2daf
docs: add MIGRATION.md for 1.0.0 upgrade path - Phase 2 Task 6 complete
Oct 8, 2025
89c05b0
test: add comprehensive tests for NIP-04, NIP-44, and NIP-57
Oct 8, 2025
afb5ffa
docs: add Phase 3 & 4 testing analysis and progress tracking
Oct 8, 2025
482fff9
chore: bump version to 0.6.4
Oct 8, 2025
e215449
docs: add PR document for critical tests and Phase 3 & 4
Oct 8, 2025
b963138
fix: remove unsupported eventId test from NIP57ImplTest
Oct 8, 2025
d191718
fix: adjust NIP-44 tests to respect NIP-44 plaintext constraints
Oct 8, 2025
cf5fc5b
Merge pull request #470 from tcheeric/test/critical-nip-tests-impleme…
tcheeric Oct 8, 2025
4bcc23b
chore(tests): strengthen client/handler tests and increase coverage; …
Oct 9, 2025
d5a3c60
Merge pull request #471 from tcheeric/chore/tests-coverage-enhancements
tcheeric Oct 9, 2025
a199549
build(api): add slf4j-test version (2.4.0) for test logging assertions
Oct 9, 2025
e98c4ce
chore: automate roadmap project setup
tcheeric Oct 11, 2025
6d653b0
Merge pull request #472 from tcheeric/codex/establish-remaining-tasks…
tcheeric Oct 11, 2025
e2f0382
Merge remote-tracking branch 'origin/develop' into develop
Oct 11, 2025
31ce804
fix(api): close WebSocket clients when subscription handles close; bu…
Oct 11, 2025
471c290
Merge pull request #473 from tcheeric/fix/websocket-handler-close-client
tcheeric Oct 11, 2025
fa6a8ba
chore: bump project version to 1.0.0-SNAPSHOT
Oct 11, 2025
5cd2a91
docs(migration): update migration steps for nostr-java BOM usage
Oct 11, 2025
85985de
docs(troubleshooting): update dependency version references for clarity
Oct 11, 2025
4243e5a
fix: parse BOLT11 separator correctly
tcheeric Oct 11, 2025
4d63f19
test: fix bolt11 whole btc fixture
tcheeric Oct 11, 2025
6fd28ca
Merge pull request #475 from tcheeric/codex/address-review-comment-in…
tcheeric Oct 11, 2025
7679bf2
fix(bolt11): correct HRP separator parsing in BOLT11 invoices
Oct 11, 2025
d4ddb67
fix(nip01): handle null uuid in identifier tag parsing
Oct 11, 2025
9861b76
feat: enhance task management in roadmap project script
Oct 11, 2025
de0f48a
Merge pull request #474 from tcheeric/chore/bump-version-1.0.0-SNAPSHOT
tcheeric Oct 11, 2025
199764f
chore(version): bump to 1.0.1-SNAPSHOT across all modules
Oct 12, 2025
4274095
fix: restore GenericTag fallback for DM decrypt
tcheeric Oct 12, 2025
b85dd49
Merge pull request #476 from tcheeric/chore/bump-version-1.0.1-SNAPSHOT
tcheeric Oct 12, 2025
8d04481
refactor(tags): reorganize imports for clarity
Oct 12, 2025
2d3cbd4
docs: rename relay references to 398ja
tcheeric Oct 12, 2025
8857498
Merge pull request #477 from tcheeric/codex/update-relay-name-from-da…
tcheeric Oct 12, 2025
41cdc37
fix: enforce string nip metadata
tcheeric Oct 12, 2025
4df2582
Merge pull request #478 from tcheeric/codex/update-event-kind-type-to…
tcheeric Oct 12, 2025
98d4df3
chore(deps): bump actions/checkout from 4 to 5
dependabot[bot] Oct 13, 2025
7c3458f
chore(deps): bump actions/setup-java from 4 to 5
dependabot[bot] Oct 13, 2025
ac61230
chore(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.13 to 0.8.14
dependabot[bot] Oct 13, 2025
364452b
Merge pull request #481 from tcheeric/dependabot/maven/develop/org.ja…
tcheeric Oct 13, 2025
c8518be
Merge pull request #479 from tcheeric/dependabot/github_actions/devel…
tcheeric Oct 13, 2025
5834f52
Merge pull request #480 from tcheeric/dependabot/github_actions/devel…
tcheeric Oct 13, 2025
4a340ab
chore(version): bump to 1.0.2-SNAPSHOT across all modules
Oct 13, 2025
796773c
chore: release version 1.0.0
Oct 13, 2025
993b342
refactor(api): remove deprecated Identity parameter methods from NIP01
Oct 13, 2025
21c704a
Merge pull request #482 from tcheeric/chore/bump-version-1.0.2-SNAPSHOT
tcheeric Oct 13, 2025
d35c334
docs(readme): update troubleshooting section and remove outdated content
Oct 13, 2025
5af42bd
docs(readme): fix formatting of features list for consistency
Oct 13, 2025
0dcd0dc
chore: update changelog for version 1.0.0 release
Oct 13, 2025
8fbbb71
refactor(api)!: clean up and remove deprecated APIs in v1.0.0
Oct 13, 2025
9726c58
refactor(release): enhance Maven command options handling
Oct 13, 2025
baa075b
chore(settings): add Maven settings for repository configuration
Oct 13, 2025
7e273ec
chore(settings): update Maven repository URL for consistency
Oct 14, 2025
6cefd8f
fix(api): handle generic p-tags during DM decrypt
tcheeric Oct 14, 2025
54109ad
Merge pull request #484 from tcheeric/codex/add-unit-test-for-nip04.java
tcheeric Oct 14, 2025
c966937
fix: restore sender overrides in NIP-01 builder
tcheeric Oct 14, 2025
00870ac
style: use diamond operator in NIP01 builder
tcheeric Oct 14, 2025
b0b8d60
Merge pull request #485 from tcheeric/codex/address-code-comment-in-n…
tcheeric Oct 14, 2025
38b1639
Merge branch 'chore/bump-version-1.0.2-SNAPSHOT' into codex/address-c…
tcheeric Oct 14, 2025
042d019
Merge pull request #486 from tcheeric/codex/address-code-comment-in-n…
tcheeric Oct 14, 2025
c652345
Merge pull request #487 from tcheeric/chore/bump-version-1.0.2-SNAPSHOT
tcheeric Oct 14, 2025
58bceed
refactor(api)!: simplify event building methods by removing sender pa…
Oct 14, 2025
3a16764
refactor(api): update default sender handling in NIP01 event builder
Oct 14, 2025
7c90fec
ci: update Maven command to use custom settings file
Oct 14, 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
88 changes: 48 additions & 40 deletions nostr-java-api/src/main/java/nostr/config/Constants.java
Original file line number Diff line number Diff line change
@@ -1,52 +1,60 @@
package nostr.config;

import nostr.base.Kind;

/** Collection of common constants used across the API. */
public final class Constants {
private Constants() {}

/**
* @deprecated Prefer using {@link Kind} directly. This indirection remains for backward
* compatibility and will be removed in a future release.
*/
@Deprecated(forRemoval = true, since = "1.2.0")
public static final class Kind {
private Kind() {}

public static final int USER_METADATA = 0;
public static final int SHORT_TEXT_NOTE = 1;
@Deprecated public static final int RECOMMENDED_RELAY = 2;
public static final int CONTACT_LIST = 3;
public static final int ENCRYPTED_DIRECT_MESSAGE = 4;
public static final int EVENT_DELETION = 5;
public static final int OTS_ATTESTATION = 1040;
public static final int DATE_BASED_CALENDAR_CONTENT = 31922;
public static final int TIME_BASED_CALENDAR_CONTENT = 31923;
public static final int CALENDAR = 31924;
public static final int CALENDAR_EVENT_RSVP = 31925;
public static final int REPOST = 6;
public static final int REACTION = 7;
public static final int CHANNEL_CREATION = 40;
public static final int CHANNEL_METADATA = 41;
public static final int CHANNEL_MESSAGE = 42;
public static final int CHANNEL_HIDE_MESSAGE = 43;
public static final int CHANNEL_MUTE_USER = 44;
public static final int REPORT = 1984;
public static final int ZAP_REQUEST = 9734;
public static final int ZAP_RECEIPT = 9735;
public static final int RELAY_LIST_METADATA = 10002;
public static final int CLIENT_AUTHENTICATION = 22242;
public static final int BADGE_DEFINITION = 30008;
public static final int BADGE_AWARD = 30009;
public static final int LONG_FORM_TEXT_NOTE = 30023;
public static final int LONG_FORM_DRAFT = 30024;
public static final int APPLICATION_SPECIFIC_DATA = 30078;
public static final int CASHU_WALLET_EVENT = 17375;
public static final int CASHU_WALLET_TOKENS = 7375;
public static final int CASHU_WALLET_HISTORY = 7376;
public static final int CASHU_RESERVED_WALLET_TOKENS = 7374;
public static final int CASHU_NUTZAP_EVENT = 9321;
public static final int CASHU_NUTZAP_INFO_EVENT = 10019;
public static final int SET_STALL = 30017;
public static final int SET_PRODUCT = 30018;
public static final int REACTION_TO_WEBSITE = 17;
public static final int REQUEST_EVENTS = 24133;
public static final int CLASSIFIED_LISTING = 30_402;
public static final int RELAY_LIST_METADATA_EVENT = 10_002;
public static final int USER_METADATA = Kind.SET_METADATA.getValue();
public static final int SHORT_TEXT_NOTE = Kind.TEXT_NOTE.getValue();
/** @deprecated Use {@link Kind#RECOMMEND_SERVER}. */

Check warning on line 19 in nostr-java-api/src/main/java/nostr/config/Constants.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Declaration has problems in Javadoc references

Cannot resolve symbol `RECOMMEND_SERVER`
@Deprecated public static final int RECOMMENDED_RELAY = Kind.RECOMMEND_SERVER.getValue();
public static final int CONTACT_LIST = Kind.CONTACT_LIST.getValue();
public static final int ENCRYPTED_DIRECT_MESSAGE = Kind.ENCRYPTED_DIRECT_MESSAGE.getValue();
public static final int EVENT_DELETION = Kind.DELETION.getValue();
public static final int OTS_ATTESTATION = Kind.OTS_EVENT.getValue();
public static final int DATE_BASED_CALENDAR_CONTENT = Kind.CALENDAR_DATE_BASED_EVENT.getValue();
public static final int TIME_BASED_CALENDAR_CONTENT = Kind.CALENDAR_TIME_BASED_EVENT.getValue();
public static final int CALENDAR = Kind.CALENDAR_EVENT.getValue();
public static final int CALENDAR_EVENT_RSVP = Kind.CALENDAR_RSVP_EVENT.getValue();
public static final int REPOST = Kind.REPOST.getValue();
public static final int REACTION = Kind.REACTION.getValue();
public static final int CHANNEL_CREATION = Kind.CHANNEL_CREATE.getValue();
public static final int CHANNEL_METADATA = Kind.CHANNEL_METADATA.getValue();
public static final int CHANNEL_MESSAGE = Kind.CHANNEL_MESSAGE.getValue();
public static final int CHANNEL_HIDE_MESSAGE = Kind.HIDE_MESSAGE.getValue();
public static final int CHANNEL_MUTE_USER = Kind.MUTE_USER.getValue();
public static final int REPORT = Kind.REPORT.getValue();
public static final int ZAP_REQUEST = Kind.ZAP_REQUEST.getValue();
public static final int ZAP_RECEIPT = Kind.ZAP_RECEIPT.getValue();
public static final int RELAY_LIST_METADATA = Kind.RELAY_LIST_METADATA.getValue();
public static final int CLIENT_AUTHENTICATION = Kind.CLIENT_AUTH.getValue();
public static final int BADGE_DEFINITION = Kind.BADGE_DEFINITION.getValue();
public static final int BADGE_AWARD = Kind.BADGE_AWARD.getValue();
public static final int LONG_FORM_TEXT_NOTE = Kind.LONG_FORM_TEXT_NOTE.getValue();
public static final int LONG_FORM_DRAFT = Kind.LONG_FORM_DRAFT.getValue();
public static final int APPLICATION_SPECIFIC_DATA = Kind.APPLICATION_SPECIFIC_DATA.getValue();
public static final int CASHU_WALLET_EVENT = Kind.WALLET.getValue();
public static final int CASHU_WALLET_TOKENS = Kind.WALLET_UNSPENT_PROOF.getValue();
public static final int CASHU_WALLET_HISTORY = Kind.WALLET_TX_HISTORY.getValue();
public static final int CASHU_RESERVED_WALLET_TOKENS = Kind.RESERVED_CASHU_WALLET_TOKENS.getValue();
public static final int CASHU_NUTZAP_EVENT = Kind.NUTZAP.getValue();
public static final int CASHU_NUTZAP_INFO_EVENT = Kind.NUTZAP_INFORMATIONAL.getValue();
public static final int SET_STALL = Kind.STALL_CREATE_OR_UPDATE.getValue();
public static final int SET_PRODUCT = Kind.PRODUCT_CREATE_OR_UPDATE.getValue();
public static final int REACTION_TO_WEBSITE = Kind.REACTION_TO_WEBSITE.getValue();
public static final int REQUEST_EVENTS = Kind.REQUEST_EVENTS.getValue();
public static final int CLASSIFIED_LISTING = Kind.CLASSIFIED_LISTING.getValue();
public static final int RELAY_LIST_METADATA_EVENT = Kind.RELAY_LIST_METADATA.getValue();
}

public static final class Tag {
Expand Down
11 changes: 9 additions & 2 deletions nostr-java-base/src/main/java/nostr/base/Kind.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public enum Kind {
TEXT_NOTE(1, "text_note"),
RECOMMEND_SERVER(2, "recommend_server"),
COINJOIN_POOL(2022, "coinjoin_pool"),
REACTION_TO_WEBSITE(17, "reaction_to_website"),
CONTACT_LIST(3, "contact_list"),
ENCRYPTED_DIRECT_MESSAGE(4, "encrypted_direct_message"),
DELETION(5, "deletion"),
REPOST(6, "repost"),
REACTION(7, "reaction"),
REPORT(1984, "report"),
CHANNEL_CREATE(40, "channel_create"),
CHANNEL_METADATA(41, "channel_metadata"),
CHANNEL_MESSAGE(42, "channel_message"),
Expand All @@ -33,14 +35,18 @@ public enum Kind {
WALLET_TX_HISTORY(7_376, "wallet_tx_history"),
ZAP_REQUEST(9734, "zap_request"),
ZAP_RECEIPT(9735, "zap_receipt"),
BADGE_DEFINITION(30_008, "badge_definition"),
BADGE_AWARD(30_009, "badge_award"),
REPLACEABLE_EVENT(10_000, "replaceable_event"),
EPHEMEREAL_EVENT(20_000, "ephemereal_event"),
ADDRESSABLE_EVENT(30_000, "addressable_event"),
PIN_LIST(10_001, "pin_list"),
CLIENT_AUTH(22_242, "authentication_of_clients_to_relays"),
STALL_CREATE_OR_UPDATE(30_017, "create_or_update_stall"),
PRODUCT_CREATE_OR_UPDATE(30_018, "create_or_update_product"),
PRE_LONG_FORM_CONTENT(30_023, "long_form_content"),
LONG_FORM_TEXT_NOTE(30_023, "long_form_text_note"),
LONG_FORM_DRAFT(30_024, "long_form_draft"),
APPLICATION_SPECIFIC_DATA(30_078, "application_specific_data"),
CLASSIFIED_LISTING(30_402, "classified_listing_active"),
CLASSIFIED_LISTING_INACTIVE(30_403, "classified_listing_inactive"),
CLASSIFIED_LISTING_DRAFT(30_403, "classified_listing_draft"),
Expand All @@ -50,7 +56,8 @@ public enum Kind {
CALENDAR_RSVP_EVENT(31_925, "calendar_rsvp_event"),
NUTZAP_INFORMATIONAL(10_019, "nutzap_informational"),
NUTZAP(9_321, "nutzap"),
RELAY_LIST_METADATA(10_002, "relay_list_metadata");
RELAY_LIST_METADATA(10_002, "relay_list_metadata"),
REQUEST_EVENTS(24_133, "request_events");

@JsonValue private final int value;

Expand Down
40 changes: 40 additions & 0 deletions nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
Expand Down Expand Up @@ -43,13 +44,13 @@
@EqualsAndHashCode(callSuper = false)
public class GenericEvent extends BaseEvent implements ISignable, Deleteable {

@Key @EqualsAndHashCode.Include private String id;

Check warning on line 47 in nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Field can be local variable

Field can be converted to a local variable

@Key
@JsonProperty("pubkey")
@EqualsAndHashCode.Include
@JsonDeserialize(using = PublicKeyDeserializer.class)
private PublicKey pubKey;

Check warning on line 53 in nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Field can be local variable

Field can be converted to a local variable

@Key
@JsonProperty("created_at")
Expand Down Expand Up @@ -118,6 +119,45 @@
updateTagsParents(this.tags);
}

@Builder(
builderClassName = "GenericEventBuilder",
builderMethodName = "builder",
toBuilder = true)
private static GenericEvent newGenericEvent(
String id,
@NonNull PublicKey pubKey,
Kind kind,
Integer customKind,
List<BaseTag> tags,
String content,
Long createdAt,
Signature signature,
Integer nip) {

GenericEvent event = new GenericEvent();

Optional.ofNullable(id).ifPresent(event::setId);
event.setPubKey(pubKey);

if (customKind == null && kind == null) {
throw new IllegalArgumentException("A kind value must be provided when building a GenericEvent.");
}

if (customKind != null) {
event.setKind(customKind);
} else if (kind != null) {

Check warning on line 148 in nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant values

Condition `kind != null` is always `true`
event.setKind(kind.getValue());
}

event.setTags(Optional.ofNullable(tags).map(ArrayList::new).orElseGet(ArrayList::new));
event.setContent(Optional.ofNullable(content).orElse(""));
event.setCreatedAt(createdAt);
event.setSignature(signature);
event.setNip(nip);

return event;
}

public void setId(String id) {
HexStringValidator.validateHex(id, 64);
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,28 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.StreamSupport;
import nostr.base.IEvent;
import nostr.base.PublicKey;
import nostr.base.Signature;
import nostr.event.BaseTag;
import nostr.base.json.EventJsonMapper;
import nostr.event.impl.CalendarDateBasedEvent;
import nostr.event.impl.CalendarTimeBasedEvent;
import nostr.event.impl.GenericEvent;
import nostr.util.NostrException;

public class CalendarDateBasedEventDeserializer extends StdDeserializer<CalendarDateBasedEvent> {
public CalendarDateBasedEventDeserializer() {
super(CalendarTimeBasedEvent.class);
super(CalendarDateBasedEvent.class);
}

// TODO: below methods needs comprehensive tags assignment completion
@Override
public CalendarDateBasedEvent deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException {
JsonNode calendarTimeBasedEventNode = jsonParser.getCodec().readTree(jsonParser);
ArrayNode tags = (ArrayNode) calendarTimeBasedEventNode.get("tags");

List<BaseTag> baseTags =
StreamSupport.stream(tags.spliterator(), false).toList().stream()
.map(JsonNode::elements)
.map(element -> EventJsonMapper.mapper().convertValue(element, BaseTag.class))
.toList();

Map<String, String> generalMap = new HashMap<>();
var fieldNames = calendarTimeBasedEventNode.fieldNames();
while (fieldNames.hasNext()) {
String key = fieldNames.next();
generalMap.put(key, calendarTimeBasedEventNode.get(key).asText());
JsonNode calendarEventNode = jsonParser.getCodec().readTree(jsonParser);
GenericEvent genericEvent =
EventJsonMapper.mapper().treeToValue(calendarEventNode, GenericEvent.class);

try {
return GenericEvent.convert(genericEvent, CalendarDateBasedEvent.class);
} catch (NostrException ex) {
throw new IOException("Failed to convert generic event into CalendarDateBasedEvent", ex);
}

CalendarDateBasedEvent calendarDateBasedEvent =
new CalendarDateBasedEvent(
new PublicKey(generalMap.get("pubkey")), baseTags, generalMap.get("content"));
calendarDateBasedEvent.setId(generalMap.get("id"));
calendarDateBasedEvent.setCreatedAt(Long.valueOf(generalMap.get("created_at")));
calendarDateBasedEvent.setSignature(Signature.fromString(generalMap.get("sig")));

return calendarDateBasedEvent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,28 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.StreamSupport;
import nostr.base.IEvent;
import nostr.base.PublicKey;
import nostr.base.Signature;
import nostr.event.BaseTag;
import nostr.base.json.EventJsonMapper;
import nostr.event.impl.CalendarEvent;
import nostr.event.impl.GenericEvent;
import nostr.util.NostrException;

public class CalendarEventDeserializer extends StdDeserializer<CalendarEvent> {
public CalendarEventDeserializer() {
super(CalendarEvent.class);
}

// TODO: below methods needs comprehensive tags assignment completion
@Override
public CalendarEvent deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException {
JsonNode calendarTimeBasedEventNode = jsonParser.getCodec().readTree(jsonParser);
ArrayNode tags = (ArrayNode) calendarTimeBasedEventNode.get("tags");

List<BaseTag> baseTags =
StreamSupport.stream(tags.spliterator(), false).toList().stream()
.map(JsonNode::elements)
.map(element -> EventJsonMapper.mapper().convertValue(element, BaseTag.class))
.toList();

Map<String, String> generalMap = new HashMap<>();
var fieldNames = calendarTimeBasedEventNode.fieldNames();
while (fieldNames.hasNext()) {
String key = fieldNames.next();
generalMap.put(key, calendarTimeBasedEventNode.get(key).asText());
JsonNode calendarEventNode = jsonParser.getCodec().readTree(jsonParser);
GenericEvent genericEvent =
EventJsonMapper.mapper().treeToValue(calendarEventNode, GenericEvent.class);

try {
return GenericEvent.convert(genericEvent, CalendarEvent.class);
} catch (NostrException ex) {
throw new IOException("Failed to convert generic event into CalendarEvent", ex);
}

CalendarEvent calendarEvent =
new CalendarEvent(
new PublicKey(generalMap.get("pubkey")), baseTags, generalMap.get("content"));
calendarEvent.setId(generalMap.get("id"));
calendarEvent.setCreatedAt(Long.valueOf(generalMap.get("created_at")));
calendarEvent.setSignature(Signature.fromString(generalMap.get("sig")));

return calendarEvent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,28 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.StreamSupport;
import nostr.base.IEvent;
import nostr.base.PublicKey;
import nostr.base.Signature;
import nostr.event.BaseTag;
import nostr.base.json.EventJsonMapper;
import nostr.event.impl.CalendarRsvpEvent;
import nostr.event.impl.GenericEvent;
import nostr.util.NostrException;

public class CalendarRsvpEventDeserializer extends StdDeserializer<CalendarRsvpEvent> {
public CalendarRsvpEventDeserializer() {
super(CalendarRsvpEvent.class);
}

// TODO: below methods needs comprehensive tags assignment completion
@Override
public CalendarRsvpEvent deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException {
JsonNode calendarTimeBasedEventNode = jsonParser.getCodec().readTree(jsonParser);
ArrayNode tags = (ArrayNode) calendarTimeBasedEventNode.get("tags");

List<BaseTag> baseTags =
StreamSupport.stream(tags.spliterator(), false).toList().stream()
.map(JsonNode::elements)
.map(element -> EventJsonMapper.mapper().convertValue(element, BaseTag.class))
.toList();

Map<String, String> generalMap = new HashMap<>();
var fieldNames = calendarTimeBasedEventNode.fieldNames();
while (fieldNames.hasNext()) {
String key = fieldNames.next();
generalMap.put(key, calendarTimeBasedEventNode.get(key).asText());
JsonNode calendarEventNode = jsonParser.getCodec().readTree(jsonParser);
GenericEvent genericEvent =
EventJsonMapper.mapper().treeToValue(calendarEventNode, GenericEvent.class);

try {
return GenericEvent.convert(genericEvent, CalendarRsvpEvent.class);
} catch (NostrException ex) {
throw new IOException("Failed to convert generic event into CalendarRsvpEvent", ex);
}

CalendarRsvpEvent calendarTimeBasedEvent =
new CalendarRsvpEvent(
new PublicKey(generalMap.get("pubkey")), baseTags, generalMap.get("content"));
calendarTimeBasedEvent.setId(generalMap.get("id"));
calendarTimeBasedEvent.setCreatedAt(Long.valueOf(generalMap.get("created_at")));
calendarTimeBasedEvent.setSignature(Signature.fromString(generalMap.get("sig")));

return calendarTimeBasedEvent;
}
}
Loading
Loading