-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
NIP38: User Statuses #771
base: master
Are you sure you want to change the base?
NIP38: User Statuses #771
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've marked some changes to do
/// | ||
/// <https://github.com/nostr-protocol/nips/blob/master/38.md> | ||
#[inline] | ||
pub fn live_statuses<S, I>(status: LiveStatus, content: S, extra_tags: I) -> Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename it to live_status
, what do you think?
And since any extra tag can be added with EventBuilder::tags
I think is better to remove the extra_tags
arg.
@@ -150,6 +150,7 @@ kind_variants! { | |||
Torrent => 2003, "Torrent", "<https://github.com/nostr-protocol/nips/blob/master/35.md>", | |||
TorrentComment => 2004, "Torrent Comment", "<https://github.com/nostr-protocol/nips/blob/master/35.md>", | |||
PeerToPeerOrder => 38383, "Peer-to-peer Order events", "<https://github.com/nostr-protocol/nips/blob/master/69.md>", | |||
UserStatuses => 30315, "User Statuses", "<https://github.com/nostr-protocol/nips/blob/master/38.md>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, I would call it UserStatus
|
||
/// NIP38 types | ||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub enum StatusType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rewrite this to:
/// NIP38 types
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum StatusType {
/// General status: "Working", "Hiking", etc.
#[default]
General,
/// Music what you are currently listening to
Music,
/// Custom status: "Playing", "Reading", etc.
Custom(String),
}
reference, | ||
}: LiveStatus, | ||
) -> Self { | ||
let mut tags = Vec::with_capacity(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rewrite this to:
let mut tags = Vec::with_capacity(3);
tags.push(Tag::identifier(status_type.to_string()));
if let Some(expire_at) = expiration {
tags.push(Tag::expiration(expire_at));
}
if let Some(content) = reference {
tags.push(Tag::reference(content));
}
@@ -28,11 +28,5 @@ async fn main() -> Result<()> { | |||
let builder = EventBuilder::text_note("POW text note from rust-nostr").pow(20); | |||
client.send_event_builder(builder).await?; | |||
|
|||
// Send a text note POW event to specific relays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was removed accidentaly during tests
// Copyright (c) 2023-2025 Rust Nostr Developers | ||
// Distributed under the MIT software license | ||
|
||
use nips::nip38::{LiveStatus, StatusType}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this line to the prelude
module, so all NIP38 module is re-exported:
pub use crate::nips::nip38::{self, *};
/// Reference to the external resource (Optional) | ||
pub reference: Option<String>, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you thin about adding a constructor to build a status without optional stuff? Like:
impl LiveStatus {
pub fn new(status_type: StatusType) -> Self {
Self {
status_type,
expiration: None,
reference: None
}
}
}
Ah, and can you also mark NIP38 as supported in |
Ah, thank for your suggestions, I will update it later today. |
Description
Add support for create NIP38 event with
EventBuilder
. Close: #666Usage:
Notes to the reviewers
None
Checklist
just precommit
orjust check
before committing