refactor: update to latest nostr sdk version
This commit is contained in:
parent
360b44e64e
commit
7561bc0e2f
|
@ -1566,7 +1566,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr"
|
name = "nostr"
|
||||||
version = "0.36.0"
|
version = "0.36.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb"
|
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
@ -1591,7 +1591,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-database"
|
name = "nostr-database"
|
||||||
version = "0.36.0"
|
version = "0.36.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb"
|
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"lru",
|
"lru",
|
||||||
|
@ -1604,7 +1604,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-relay-pool"
|
name = "nostr-relay-pool"
|
||||||
version = "0.36.0"
|
version = "0.36.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb"
|
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"async-wsocket",
|
"async-wsocket",
|
||||||
|
@ -1622,7 +1622,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-sdk"
|
name = "nostr-sdk"
|
||||||
version = "0.36.0"
|
version = "0.36.0"
|
||||||
source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb"
|
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-utility",
|
"async-utility",
|
||||||
"atomic-destructor",
|
"atomic-destructor",
|
||||||
|
|
|
@ -30,7 +30,7 @@ itertools = "0.12"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
parse_datetime = "0.5.0"
|
parse_datetime = "0.5.0"
|
||||||
interim = { version = "0.1", features = ["chrono"] }
|
interim = { version = "0.1", features = ["chrono"] }
|
||||||
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" }
|
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e82bc787bdd8490ceadb034fe4483e4df1e91b2a" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1.41", features = ["rt", "rt-multi-thread", "macros", "io-std"] }
|
tokio = { version = "1.41", features = ["rt", "rt-multi-thread", "macros", "io-std"] }
|
||||||
|
|
|
@ -74,11 +74,8 @@ pub(crate) fn build_tracking<I>(id: I) -> EventBuilder
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item=EventId>,
|
I: IntoIterator<Item=EventId>,
|
||||||
{
|
{
|
||||||
EventBuilder::new(
|
EventBuilder::new(Kind::from(TRACKING_KIND), "")
|
||||||
Kind::from(TRACKING_KIND),
|
.tags(id.into_iter().map(Tag::event))
|
||||||
"",
|
|
||||||
id.into_iter().map(Tag::event),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn join<'a, T>(tags: T) -> String
|
pub fn join<'a, T>(tags: T) -> String
|
||||||
|
|
|
@ -353,22 +353,22 @@ mod tasks_test {
|
||||||
fn test_state() {
|
fn test_state() {
|
||||||
let keys = Keys::generate();
|
let keys = Keys::generate();
|
||||||
let mut task = Task::new(
|
let mut task = Task::new(
|
||||||
EventBuilder::new(TASK_KIND, "task", [Tag::hashtag("tag1")])
|
EventBuilder::new(TASK_KIND, "task").tags([Tag::hashtag("tag1")])
|
||||||
.sign_with_keys(&keys).unwrap());
|
.sign_with_keys(&keys).unwrap());
|
||||||
assert_eq!(task.pure_state(), State::Open);
|
assert_eq!(task.pure_state(), State::Open);
|
||||||
assert_eq!(task.get_hashtags().count(), 1);
|
assert_eq!(task.get_hashtags().count(), 1);
|
||||||
task.props.insert(
|
task.props.insert(
|
||||||
EventBuilder::new(State::Done.into(), "", [])
|
EventBuilder::new(State::Done.into(), "")
|
||||||
.sign_with_keys(&keys).unwrap());
|
.sign_with_keys(&keys).unwrap());
|
||||||
assert_eq!(task.pure_state(), State::Done);
|
assert_eq!(task.pure_state(), State::Done);
|
||||||
task.props.insert(
|
task.props.insert(
|
||||||
EventBuilder::new(State::Open.into(), "", [Tag::hashtag("tag2")])
|
EventBuilder::new(State::Open.into(), "").tags([Tag::hashtag("tag2")])
|
||||||
.custom_created_at(Timestamp::from(Timestamp::now() - 2))
|
.custom_created_at(Timestamp::from(Timestamp::now() - 2))
|
||||||
.sign_with_keys(&keys).unwrap());
|
.sign_with_keys(&keys).unwrap());
|
||||||
assert_eq!(task.pure_state(), State::Done);
|
assert_eq!(task.pure_state(), State::Done);
|
||||||
assert_eq!(task.get_hashtags().count(), 2);
|
assert_eq!(task.get_hashtags().count(), 2);
|
||||||
task.props.insert(
|
task.props.insert(
|
||||||
EventBuilder::new(State::Closed.into(), "", [])
|
EventBuilder::new(State::Closed.into(), "")
|
||||||
.custom_created_at(Timestamp::from(Timestamp::now() + 1))
|
.custom_created_at(Timestamp::from(Timestamp::now() + 1))
|
||||||
.sign_with_keys(&keys).unwrap());
|
.sign_with_keys(&keys).unwrap());
|
||||||
assert_eq!(task.pure_state(), State::Closed);
|
assert_eq!(task.pure_state(), State::Closed);
|
||||||
|
|
63
src/tasks.rs
63
src/tasks.rs
|
@ -633,11 +633,10 @@ impl TasksRelay {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.sender.submit(EventBuilder::new(
|
self.sender.submit(
|
||||||
Kind::Bookmarks,
|
EventBuilder::new(Kind::Bookmarks, "mostr pins")
|
||||||
"mostr pins",
|
.tags(self.bookmarks.iter().map(|id| Tag::event(*id)))
|
||||||
self.bookmarks.iter().map(|id| Tag::event(*id)),
|
)?;
|
||||||
))?;
|
|
||||||
Ok(added)
|
Ok(added)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -976,10 +975,11 @@ impl TasksRelay {
|
||||||
if input_tags.iter().any(|t| t.kind().to_string() == PRIO) { None } else { self.priority.map(|p| to_prio_tag(p)) };
|
if input_tags.iter().any(|t| t.kind().to_string() == PRIO) { None } else { self.priority.map(|p| to_prio_tag(p)) };
|
||||||
info!("Created task \"{input}\" with tags [{}]", join(&input_tags));
|
info!("Created task \"{input}\" with tags [{}]", join(&input_tags));
|
||||||
let id = self.submit(
|
let id = self.submit(
|
||||||
EventBuilder::new(TASK_KIND, &input, input_tags)
|
EventBuilder::new(TASK_KIND, &input)
|
||||||
.add_tags(self.tags.iter().cloned())
|
.tags(input_tags)
|
||||||
.add_tags(tags)
|
.tags(self.tags.iter().cloned())
|
||||||
.add_tags(prio)
|
.tags(tags)
|
||||||
|
.tags(prio)
|
||||||
);
|
);
|
||||||
if set_state {
|
if set_state {
|
||||||
self.state
|
self.state
|
||||||
|
@ -1189,13 +1189,11 @@ impl TasksRelay {
|
||||||
vec![id]
|
vec![id]
|
||||||
};
|
};
|
||||||
let (desc, tags) = extract_tags(comment);
|
let (desc, tags) = extract_tags(comment);
|
||||||
let prop = EventBuilder::new(
|
let prop =
|
||||||
state.into(),
|
EventBuilder::new(state.into(), desc)
|
||||||
desc,
|
.tags(ids.into_iter()
|
||||||
ids.into_iter()
|
.map(|e| self.make_event_tag_from_id(e, MARKER_PROPERTY)))
|
||||||
.map(|e| self.make_event_tag_from_id(e, MARKER_PROPERTY))
|
.tags(tags);
|
||||||
.chain(tags),
|
|
||||||
);
|
|
||||||
// if self.custom_time.is_none() && self.get_by_id(id).map(|task| {}) {}
|
// if self.custom_time.is_none() && self.get_by_id(id).map(|task| {}) {}
|
||||||
info!(
|
info!(
|
||||||
"Task status {} set for \"{}\"{}",
|
"Task status {} set for \"{}\"{}",
|
||||||
|
@ -1219,7 +1217,7 @@ impl TasksRelay {
|
||||||
let (name, tags) = extract_tags(note.trim());
|
let (name, tags) = extract_tags(note.trim());
|
||||||
let format = format!("\"{name}\" with tags [{}]", join(&tags));
|
let format = format!("\"{name}\" with tags [{}]", join(&tags));
|
||||||
let mut prop =
|
let mut prop =
|
||||||
EventBuilder::new(Kind::TextNote, name, tags);
|
EventBuilder::new(Kind::TextNote, name).tags(tags);
|
||||||
//.filter(|id| self.get_by_id(id).is_some_and(|t| t.is_task()))
|
//.filter(|id| self.get_by_id(id).is_some_and(|t| t.is_task()))
|
||||||
//.map(|id|
|
//.map(|id|
|
||||||
let marker =
|
let marker =
|
||||||
|
@ -1445,7 +1443,7 @@ fn display_time(format: &str, secs: u64) -> String {
|
||||||
.map_or(String::new(), |mins| format
|
.map_or(String::new(), |mins| format
|
||||||
.replace("MMM", &format!("{:3}", mins))
|
.replace("MMM", &format!("{:3}", mins))
|
||||||
.replace("HH", &format!("{:02}", mins.div(60)))
|
.replace("HH", &format!("{:02}", mins.div(60)))
|
||||||
.replace("MM", &format!("{:02}", mins.rem(60)))
|
.replace("MM", &format!("{:02}", mins.rem(60))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1775,11 +1773,10 @@ mod tasks_test {
|
||||||
fn test_sibling_dependency() {
|
fn test_sibling_dependency() {
|
||||||
let mut tasks = stub_tasks();
|
let mut tasks = stub_tasks();
|
||||||
let parent = tasks.make_task("parent");
|
let parent = tasks.make_task("parent");
|
||||||
let sub = tasks.submit(EventBuilder::new(
|
let sub = tasks.submit(
|
||||||
TASK_KIND,
|
EventBuilder::new(TASK_KIND, "sub")
|
||||||
"sub",
|
.tags([tasks.make_event_tag_from_id(parent, MARKER_PARENT)])
|
||||||
[tasks.make_event_tag_from_id(parent, MARKER_PARENT)],
|
);
|
||||||
));
|
|
||||||
assert_eq!(tasks.visible_tasks().len(), 1);
|
assert_eq!(tasks.visible_tasks().len(), 1);
|
||||||
tasks.track_at(Timestamp::now(), Some(sub));
|
tasks.track_at(Timestamp::now(), Some(sub));
|
||||||
assert_eq!(tasks.get_own_events_history().count(), 1);
|
assert_eq!(tasks.get_own_events_history().count(), 1);
|
||||||
|
@ -1807,11 +1804,10 @@ mod tasks_test {
|
||||||
assert_eq!(tasks.filtered_tasks(Some(pin), false).len(), 0);
|
assert_eq!(tasks.filtered_tasks(Some(pin), false).len(), 0);
|
||||||
assert_eq!(tasks.filtered_tasks(Some(zero), false).len(), 0);
|
assert_eq!(tasks.filtered_tasks(Some(zero), false).len(), 0);
|
||||||
|
|
||||||
tasks.submit(EventBuilder::new(
|
tasks.submit(
|
||||||
Kind::Bookmarks,
|
EventBuilder::new(Kind::Bookmarks, "")
|
||||||
"",
|
.tags([Tag::event(pin), Tag::event(zero)])
|
||||||
[Tag::event(pin), Tag::event(zero)],
|
);
|
||||||
));
|
|
||||||
assert_eq!(tasks.visible_tasks().len(), 1);
|
assert_eq!(tasks.visible_tasks().len(), 1);
|
||||||
assert_eq!(tasks.filtered_tasks(Some(pin), true).len(), 0);
|
assert_eq!(tasks.filtered_tasks(Some(pin), true).len(), 0);
|
||||||
assert_eq!(tasks.filtered_tasks(Some(pin), false).len(), 0);
|
assert_eq!(tasks.filtered_tasks(Some(pin), false).len(), 0);
|
||||||
|
@ -1833,7 +1829,7 @@ mod tasks_test {
|
||||||
vec![tasks.get_by_id(&test).unwrap()]
|
vec![tasks.get_by_id(&test).unwrap()]
|
||||||
);
|
);
|
||||||
|
|
||||||
tasks.submit(EventBuilder::new(Kind::Bookmarks, "", []));
|
tasks.submit(EventBuilder::new(Kind::Bookmarks, ""));
|
||||||
tasks.clear_filters();
|
tasks.clear_filters();
|
||||||
assert_tasks!(tasks, [pin, test]);
|
assert_tasks!(tasks, [pin, test]);
|
||||||
tasks.set_view_depth(0);
|
tasks.set_view_depth(0);
|
||||||
|
@ -1845,11 +1841,10 @@ mod tasks_test {
|
||||||
let mut tasks = stub_tasks();
|
let mut tasks = stub_tasks();
|
||||||
tasks.make_task_and_enter("proc # tags", State::Procedure);
|
tasks.make_task_and_enter("proc # tags", State::Procedure);
|
||||||
assert_eq!(tasks.get_own_events_history().count(), 1);
|
assert_eq!(tasks.get_own_events_history().count(), 1);
|
||||||
let side = tasks.submit(EventBuilder::new(
|
let side = tasks.submit(
|
||||||
TASK_KIND,
|
EventBuilder::new(TASK_KIND, "side")
|
||||||
"side",
|
.tags([tasks.make_event_tag(&tasks.get_current_task().unwrap().event, MARKER_DEPENDS)])
|
||||||
[tasks.make_event_tag(&tasks.get_current_task().unwrap().event, MARKER_DEPENDS)],
|
);
|
||||||
));
|
|
||||||
assert_eq!(tasks.visible_tasks(), Vec::<&Task>::new());
|
assert_eq!(tasks.visible_tasks(), Vec::<&Task>::new());
|
||||||
let sub_id = tasks.make_task("sub");
|
let sub_id = tasks.make_task("sub");
|
||||||
assert_tasks!(tasks, [sub_id]);
|
assert_tasks!(tasks, [sub_id]);
|
||||||
|
|
Loading…
Reference in New Issue