Skip to content
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

Implement posting #118

Merged
merged 8 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export android_emulator=false

use nix --arg use_android $use_android --arg android_emulator $android_emulator

# you can put secret keys in here
source .privenv || :

export PATH=$PATH:$HOME/.cargo/bin
export JB55=32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.buildcmd
perf.data
perf.data.old
.privenv
target
queries/damus-notifs.json
.git
Expand Down
21 changes: 3 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ serde_json = "1.0.89"
env_logger = "0.10.0"
puffin_egui = { version = "0.27.0", optional = true }
puffin = { version = "0.19.0", optional = true }
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "5733ece62b8495db8624a21637bacd12ebb22b2c" }
#nostrdb = "0.3.3"
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "ee8afeeb0b6695fca6d27dd0b74a8dc159e37b95" }
#nostrdb = "0.3.4"
hex = "0.4.3"
base32 = "0.4.0"
strum = "0.26"
Expand Down
16 changes: 11 additions & 5 deletions enostr/src/client/message.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{Event, Filter};
use crate::{Filter, Note};
use serde_json::json;

/// Messages sent by clients, received by relays
#[derive(Debug, Eq, PartialEq)]
pub enum ClientMessage {
Event {
event: Event,
note: Note,
},
Req {
sub_id: String,
Expand All @@ -14,11 +14,16 @@ pub enum ClientMessage {
Close {
sub_id: String,
},
Raw(String),
}

impl ClientMessage {
pub fn event(event: Event) -> Self {
ClientMessage::Event { event }
pub fn event(note: Note) -> Self {
ClientMessage::Event { note }
}

pub fn raw(raw: String) -> Self {
ClientMessage::Raw(raw)
}

pub fn req(sub_id: String, filters: Vec<Filter>) -> Self {
Expand All @@ -31,7 +36,8 @@ impl ClientMessage {

pub fn to_json(&self) -> String {
match self {
Self::Event { event } => json!(["EVENT", event]).to_string(),
Self::Event { note } => json!(["EVENT", note]).to_string(),
Self::Raw(raw) => raw.clone(),
Self::Req { sub_id, filters } => {
let mut json = json!(["REQ", sub_id]);
let mut filters = json!(filters);
Expand Down
122 changes: 0 additions & 122 deletions enostr/src/event.rs

This file was deleted.

10 changes: 5 additions & 5 deletions enostr/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use crate::{EventId, Pubkey};
use crate::{NoteId, Pubkey};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
pub struct Filter {
#[serde(skip_serializing_if = "Option::is_none")]
pub ids: Option<Vec<EventId>>,
pub ids: Option<Vec<NoteId>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub authors: Option<Vec<Pubkey>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub kinds: Option<Vec<u64>>,
#[serde(rename = "#e")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<EventId>>,
pub events: Option<Vec<NoteId>>,
#[serde(rename = "#p")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pubkeys: Option<Vec<Pubkey>>,
Expand Down Expand Up @@ -49,7 +49,7 @@ impl Filter {
150
}

pub fn ids(mut self, ids: Vec<EventId>) -> Self {
pub fn ids(mut self, ids: Vec<NoteId>) -> Self {
self.ids = Some(ids);
self
}
Expand All @@ -64,7 +64,7 @@ impl Filter {
self
}

pub fn events(mut self, events: Vec<EventId>) -> Self {
pub fn events(mut self, events: Vec<NoteId>) -> Self {
self.events = Some(events);
self
}
Expand Down
4 changes: 1 addition & 3 deletions enostr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mod client;
mod error;
mod event;
mod filter;
mod keypair;
mod note;
Expand All @@ -10,12 +9,11 @@ mod relay;

pub use client::ClientMessage;
pub use error::Error;
pub use event::{Event, EventId};
pub use ewebsock;
pub use filter::Filter;
pub use keypair::{FullKeypair, Keypair};
pub use nostr::SecretKey;
pub use note::NoteId;
pub use note::{Note, NoteId};
pub use profile::Profile;
pub use pubkey::Pubkey;
pub use relay::message::{RelayEvent, RelayMessage};
Expand Down
Loading
Loading