Compare commits
7 commits
473f26d7a5
...
cb1d8ef8fb
Author | SHA1 | Date | |
---|---|---|---|
|
cb1d8ef8fb | ||
|
7561bc0e2f | ||
|
360b44e64e | ||
|
adcd35967f | ||
|
2400f7c45b | ||
|
e186d034e5 | ||
|
59b789d5ed |
9 changed files with 428 additions and 635 deletions
332
Cargo.lock
generated
332
Cargo.lock
generated
|
@ -1189,29 +1189,6 @@ dependencies = [
|
|||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body-util"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.9.4"
|
||||
|
@ -1224,62 +1201,6 @@ version = "2.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.27.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"http",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tower-service",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
|
@ -1355,12 +1276,6 @@ dependencies = [
|
|||
"logos",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
|
@ -1465,18 +1380,6 @@ version = "0.4.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "lnurl-pay"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "536e7c782167a2d48346ca0b2677fad19eaef20f19a4ab868e4d5b96ca879def"
|
||||
dependencies = [
|
||||
"bech32",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
|
@ -1540,12 +1443,6 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
|
@ -1591,7 +1488,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mostr"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-english",
|
||||
|
@ -1669,10 +1566,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "nostr"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14ad56c1d9a59f4edc46b17bc64a217b38b99baefddc0080f85ad98a0855336d"
|
||||
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"bech32",
|
||||
|
@ -1683,26 +1578,20 @@ dependencies = [
|
|||
"chacha20poly1305",
|
||||
"getrandom 0.2.15",
|
||||
"instant",
|
||||
"js-sys",
|
||||
"negentropy 0.3.1",
|
||||
"negentropy 0.4.3",
|
||||
"once_cell",
|
||||
"reqwest",
|
||||
"scrypt",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"unicode-normalization",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nostr-database"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1859abebf78d7d9e945b20c8faaf710c9db905adeb148035b803ae45792dbebe"
|
||||
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"lru",
|
||||
|
@ -1715,8 +1604,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "nostr-relay-pool"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e39cfcb30cab86b30ca9acba89f5ccb25a4142a5dc5fcfbf3edf34b204ddd7c7"
|
||||
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"async-wsocket",
|
||||
|
@ -1734,33 +1622,18 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "nostr-sdk"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4739ed15ff81a0e474d79b38c3eb481ff5f968c1865f38ba46852daf6f6495e"
|
||||
source = "git+https://github.com/rust-nostr/nostr?rev=e82bc787bdd8490ceadb034fe4483e4df1e91b2a#e82bc787bdd8490ceadb034fe4483e4df1e91b2a"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"atomic-destructor",
|
||||
"lnurl-pay",
|
||||
"nostr",
|
||||
"nostr-database",
|
||||
"nostr-relay-pool",
|
||||
"nostr-zapper",
|
||||
"nwc",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nostr-zapper"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d9709ecf8050bbe4ecf0e5efda2f25b690bb1761fc504e05654621ba9e568a8"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"nostr",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
|
@ -1834,21 +1707,6 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nwc"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5f98bcaf232b3ec48e018792ca7bc2b90e7520d001a07b8218a9e76a03fda2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"async-utility",
|
||||
"nostr",
|
||||
"nostr-relay-pool",
|
||||
"nostr-zapper",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.4"
|
||||
|
@ -2049,55 +1907,6 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quinn"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"pin-project-lite",
|
||||
"quinn-proto",
|
||||
"quinn-udp",
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"socket2",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quinn-proto"
|
||||
version = "0.11.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"rand",
|
||||
"ring",
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"slab",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quinn-udp"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da"
|
||||
dependencies = [
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"socket2",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
|
@ -2204,49 +2013,6 @@ version = "0.8.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.12.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-util",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"quinn",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"rustls-pki-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tokio-socks",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
"windows-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.8"
|
||||
|
@ -2280,12 +2046,6 @@ version = "0.1.24"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.35"
|
||||
|
@ -2313,16 +2073,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.8.0"
|
||||
|
@ -2514,18 +2264,6 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
|
@ -2632,15 +2370,6 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.12.0"
|
||||
|
@ -2796,12 +2525,6 @@ dependencies = [
|
|||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.40"
|
||||
|
@ -2833,12 +2556,6 @@ dependencies = [
|
|||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.24.0"
|
||||
|
@ -2955,15 +2672,6 @@ version = "0.9.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
|
||||
dependencies = [
|
||||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
|
@ -3093,36 +2801,6 @@ dependencies = [
|
|||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-registry"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
|
||||
dependencies = [
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||
dependencies = [
|
||||
"windows-result",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
|
|
|
@ -5,7 +5,7 @@ repository = "https://forge.ftt.gmbh/janek/mostr"
|
|||
readme = "README.md"
|
||||
license = "GPL 3.0"
|
||||
authors = ["melonion"]
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
rust-version = "1.82"
|
||||
edition = "2021"
|
||||
default-run = "mostr"
|
||||
|
@ -30,7 +30,7 @@ itertools = "0.12"
|
|||
chrono = "0.4"
|
||||
parse_datetime = "0.5.0"
|
||||
interim = { version = "0.1", features = ["chrono"] }
|
||||
nostr-sdk = "0.36" # { git = "https://github.com/xeruf/rust-nostr-sdk", rev = "7b556e1e" }
|
||||
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e82bc787bdd8490ceadb034fe4483e4df1e91b2a" }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.41", features = ["rt", "rt-multi-thread", "macros", "io-std"] }
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
All used nostr kinds are listed on the top of [kinds.rs](./src/kinds.rs)
|
||||
|
||||
Mostr mainly uses the following NIPs:
|
||||
Mostr mainly uses the following [NIPs](https://github.com/nostr-protocol/nips):
|
||||
|
||||
- Kind 1 for task descriptions and permanent tasks, can contain task property updates (tags, priority)
|
||||
- Issue Tracking: https://github.com/nostr-protocol/nips/blob/master/34.md
|
||||
|
|
|
@ -14,7 +14,7 @@ First, start a nostr relay, such as
|
|||
- https://github.com/coracle-social/bucket for local development
|
||||
- https://github.com/rnostr/rnostr for production use
|
||||
|
||||
Install rustup and run a development build with:
|
||||
Install rust(up) and run a development build with:
|
||||
|
||||
cargo run
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ use nostr_sdk::Timestamp;
|
|||
|
||||
pub const CHARACTER_THRESHOLD: usize = 3;
|
||||
|
||||
pub fn to_string_or_default(arg: Option<impl ToString>) -> String {
|
||||
arg.map(|arg| arg.to_string()).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn some_non_empty(str: &str) -> Option<String> {
|
||||
if str.is_empty() { None } else { Some(str.to_string()) }
|
||||
}
|
||||
|
|
40
src/kinds.rs
40
src/kinds.rs
|
@ -53,15 +53,29 @@ Utilities:
|
|||
- TBI `depends` - list all tasks this task depends on before it becomes actionable
|
||||
Debugging: `kind`, `pubkey`, `props`, `alltags`, `descriptions`";
|
||||
|
||||
pub struct EventTag {
|
||||
pub id: EventId,
|
||||
pub marker: Option<String>,
|
||||
}
|
||||
|
||||
/// Return event tag if existing
|
||||
pub(crate) fn match_event_tag(tag: &Tag) -> Option<EventTag> {
|
||||
let mut vec = tag.as_slice().into_iter();
|
||||
if vec.next() == Some(&"e".to_string()) {
|
||||
if let Some(id) = vec.next().and_then(|v| EventId::parse(v).ok()) {
|
||||
vec.next();
|
||||
return Some(EventTag { id, marker: vec.next().cloned() });
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn build_tracking<I>(id: I) -> EventBuilder
|
||||
where
|
||||
I: IntoIterator<Item=EventId>,
|
||||
{
|
||||
EventBuilder::new(
|
||||
Kind::from(TRACKING_KIND),
|
||||
"",
|
||||
id.into_iter().map(Tag::event),
|
||||
)
|
||||
EventBuilder::new(Kind::from(TRACKING_KIND), "")
|
||||
.tags(id.into_iter().map(Tag::event))
|
||||
}
|
||||
|
||||
pub fn join<'a, T>(tags: T) -> String
|
||||
|
@ -90,15 +104,15 @@ pub(crate) fn extract_tags(input: &str) -> (String, Vec<Tag>) {
|
|||
if s.starts_with('*') {
|
||||
if s.len() == 1 {
|
||||
prio = Some(HIGH_PRIO);
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return match s[1..].parse::<Prio>() {
|
||||
Ok(num) => {
|
||||
prio = Some(num * (if s.len() > 2 { 1 } else { 10 }));
|
||||
false
|
||||
},
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
};
|
||||
}
|
||||
true
|
||||
}).collect_vec();
|
||||
|
@ -118,12 +132,12 @@ pub fn to_hashtag(tag: &str) -> Tag {
|
|||
}
|
||||
|
||||
fn format_tag(tag: &Tag) -> String {
|
||||
if let Some(et) = match_event_tag(tag) {
|
||||
return format!("{}: {:.8}",
|
||||
et.marker.as_ref().map(|m| m.to_string()).unwrap_or(MARKER_PARENT.to_string()),
|
||||
et.id);
|
||||
}
|
||||
match tag.as_standardized() {
|
||||
Some(TagStandard::Event {
|
||||
event_id,
|
||||
marker,
|
||||
..
|
||||
}) => format!("{}: {:.8}", marker.as_ref().map(|m| m.to_string()).unwrap_or(MARKER_PARENT.to_string()), event_id),
|
||||
Some(TagStandard::PublicKey {
|
||||
public_key,
|
||||
alias,
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -82,6 +82,8 @@ fn read_keys(readline: &mut DefaultEditor) -> Result<Keys> {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
println!("Running Mostr Version {}", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
let mut args = args().skip(1).peekable();
|
||||
let mut builder = if args.peek().is_some_and(|arg| arg == "--debug") {
|
||||
args.next();
|
||||
|
@ -136,7 +138,7 @@ async fn main() -> Result<()> {
|
|||
let client = ClientBuilder::new()
|
||||
.opts(Options::new()
|
||||
.automatic_authentication(true)
|
||||
//.notification_channel_size(8192)
|
||||
.notification_channel_size(8192)
|
||||
)
|
||||
.signer(keys.clone())
|
||||
.build();
|
||||
|
@ -639,7 +641,7 @@ async fn main() -> Result<()> {
|
|||
let pos = tasks.up_by(dots - 1);
|
||||
|
||||
if remaining.is_empty() {
|
||||
tasks.move_to(pos.cloned());
|
||||
tasks.move_to(pos);
|
||||
if dots > 1 {
|
||||
info!("Moving up {} tasks", dots - 1)
|
||||
} else {
|
||||
|
@ -648,13 +650,13 @@ async fn main() -> Result<()> {
|
|||
} else {
|
||||
match remaining.parse::<usize>() {
|
||||
Ok(depth) if depth < 10 => {
|
||||
if pos != tasks.get_position_ref() {
|
||||
tasks.move_to(pos.cloned());
|
||||
if pos != tasks.get_position() {
|
||||
tasks.move_to(pos);
|
||||
}
|
||||
tasks.set_view_depth(depth);
|
||||
}
|
||||
_ => {
|
||||
tasks.filter_or_create(pos.cloned().as_ref(), &remaining).map(|id| tasks.move_to(Some(id)));
|
||||
tasks.filter_or_create(pos, &remaining).map(|id| tasks.move_to(Some(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -667,13 +669,13 @@ async fn main() -> Result<()> {
|
|||
let pos = tasks.up_by(dots - 1);
|
||||
|
||||
if remaining.is_empty() {
|
||||
tasks.move_to(pos.cloned());
|
||||
tasks.move_to(pos);
|
||||
if dots > 1 {
|
||||
info!("Moving up {} tasks", dots - 1)
|
||||
}
|
||||
} else if let Ok(depth) = remaining.parse::<usize>() {
|
||||
if pos != tasks.get_position_ref() {
|
||||
tasks.move_to(pos.cloned());
|
||||
if pos != tasks.get_position() {
|
||||
tasks.move_to(pos);
|
||||
}
|
||||
tasks.set_search_depth(depth);
|
||||
} else {
|
||||
|
@ -693,7 +695,7 @@ async fn main() -> Result<()> {
|
|||
if filtered.len() == 1 {
|
||||
tasks.move_to(filtered.into_iter().next());
|
||||
} else {
|
||||
tasks.move_to(pos.cloned());
|
||||
tasks.move_to(pos);
|
||||
if !tasks.set_view(filtered) {
|
||||
continue 'repl;
|
||||
}
|
||||
|
@ -726,7 +728,7 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
tasks.filter_or_create(tasks.get_position().as_ref(), &command);
|
||||
tasks.filter_or_create(tasks.get_position(), &command);
|
||||
}
|
||||
}
|
||||
tasks.custom_time = None;
|
||||
|
|
20
src/task.rs
20
src/task.rs
|
@ -10,10 +10,10 @@ use colored::{ColoredString, Colorize};
|
|||
use itertools::Either::{Left, Right};
|
||||
use itertools::Itertools;
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use nostr_sdk::{Alphabet, Event, EventId, Kind, Tag, TagStandard, Timestamp};
|
||||
use nostr_sdk::{Alphabet, Event, EventId, Kind, Tag, Timestamp};
|
||||
|
||||
use crate::helpers::{format_timestamp_local, some_non_empty};
|
||||
use crate::kinds::{is_hashtag, Prio, PRIO, PROCEDURE_KIND, PROCEDURE_KIND_ID, TASK_KIND};
|
||||
use crate::kinds::{is_hashtag, match_event_tag, Prio, PRIO, PROCEDURE_KIND, PROCEDURE_KIND_ID, TASK_KIND};
|
||||
use crate::tasks::now;
|
||||
|
||||
pub static MARKER_PARENT: &str = "parent";
|
||||
|
@ -52,10 +52,10 @@ impl Hash for Task {
|
|||
|
||||
impl Task {
|
||||
pub(crate) fn new(event: Event) -> Task {
|
||||
let (refs, tags) = event.tags.iter().partition_map(|tag| match tag.as_standardized() {
|
||||
Some(TagStandard::Event { event_id, marker, .. }) =>
|
||||
Left((marker.as_ref().map_or(MARKER_PARENT.to_string(), |m| m.to_string()), *event_id)),
|
||||
_ => Right(tag.clone()),
|
||||
let (refs, tags) = event.tags.iter().partition_map(|tag| if let Some(et) = match_event_tag(tag) {
|
||||
Left((et.marker.as_ref().map_or(MARKER_PARENT.to_string(), |m| m.to_string()), et.id))
|
||||
} else {
|
||||
Right(tag.clone())
|
||||
});
|
||||
// Separate refs for dependencies
|
||||
Task {
|
||||
|
@ -353,22 +353,22 @@ mod tasks_test {
|
|||
fn test_state() {
|
||||
let keys = Keys::generate();
|
||||
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());
|
||||
assert_eq!(task.pure_state(), State::Open);
|
||||
assert_eq!(task.get_hashtags().count(), 1);
|
||||
task.props.insert(
|
||||
EventBuilder::new(State::Done.into(), "", [])
|
||||
EventBuilder::new(State::Done.into(), "")
|
||||
.sign_with_keys(&keys).unwrap());
|
||||
assert_eq!(task.pure_state(), State::Done);
|
||||
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))
|
||||
.sign_with_keys(&keys).unwrap());
|
||||
assert_eq!(task.pure_state(), State::Done);
|
||||
assert_eq!(task.get_hashtags().count(), 2);
|
||||
task.props.insert(
|
||||
EventBuilder::new(State::Closed.into(), "", [])
|
||||
EventBuilder::new(State::Closed.into(), "")
|
||||
.custom_created_at(Timestamp::from(Timestamp::now() + 1))
|
||||
.sign_with_keys(&keys).unwrap());
|
||||
assert_eq!(task.pure_state(), State::Closed);
|
||||
|
|
637
src/tasks.rs
637
src/tasks.rs
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue