Skip to content

Commit f710fbc

Browse files
committed
nostr/event/tags: add name tag
1 parent 4981a51 commit f710fbc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/nostr/src/event/tag.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ pub enum TagKind {
187187
Amount,
188188
/// Lnurl (NIP57)
189189
Lnurl,
190+
/// Name tag
191+
Name,
190192
/// Custom tag kind
191193
Custom(String),
192194
}
@@ -218,6 +220,7 @@ impl fmt::Display for TagKind {
218220
Self::Relays => write!(f, "relays"),
219221
Self::Amount => write!(f, "amount"),
220222
Self::Lnurl => write!(f, "lnurl"),
223+
Self::Name => write!(f, "name"),
221224
Self::Custom(tag) => write!(f, "{tag}"),
222225
}
223226
}
@@ -254,6 +257,7 @@ where
254257
"relays" => Self::Relays,
255258
"amount" => Self::Amount,
256259
"lnurl" => Self::Lnurl,
260+
"name" => Self::Name,
257261
tag => Self::Custom(tag.to_string()),
258262
}
259263
}
@@ -300,14 +304,15 @@ pub enum Tag {
300304
Subject(String),
301305
Challenge(String),
302306
Title(String),
303-
Image(String),
307+
Image(String, Option<(u64, u64)>),
304308
Summary(String),
305309
Description(String),
306310
Bolt11(String),
307311
Preimage(String),
308312
Relays(Vec<UncheckedUrl>),
309313
Amount(u64),
310314
Lnurl(String),
315+
Name(String),
311316
PublishedAt(Timestamp),
312317
}
313318

@@ -356,6 +361,7 @@ impl Tag {
356361
Tag::Preimage(..) => TagKind::Preimage,
357362
Tag::Relays(..) => TagKind::Relays,
358363
Tag::Amount(..) => TagKind::Amount,
364+
Tag::Name(..) => TagKind::Name,
359365
Tag::Lnurl(..) => TagKind::Lnurl,
360366
}
361367
}
@@ -413,6 +419,7 @@ where
413419
TagKind::Preimage => Ok(Self::Preimage(content.to_string())),
414420
TagKind::Amount => Ok(Self::Amount(content.parse()?)),
415421
TagKind::Lnurl => Ok(Self::Lnurl(content.to_string())),
422+
TagKind::Name => Ok(Self::Name(content.to_string())),
416423
_ => Ok(Self::Generic(tag_kind, vec![content.to_string()])),
417424
}
418425
} else if tag_len == 3 {
@@ -601,6 +608,9 @@ impl From<Tag> for Vec<String> {
601608
Tag::Amount(amount) => {
602609
vec![TagKind::Amount.to_string(), amount.to_string()]
603610
}
611+
Tag::Name(name) => {
612+
vec![TagKind::Name.to_string(), name]
613+
}
604614
Tag::Lnurl(lnurl) => {
605615
vec![TagKind::Lnurl.to_string(), lnurl]
606616
}

0 commit comments

Comments
 (0)