|
@@ -143,7 +143,7 @@ impl Tag {
|
|
Tag::Hashtag(content) | Tag::Title(content) => Some(TagValue::String(content.clone())),
|
|
Tag::Hashtag(content) | Tag::Title(content) => Some(TagValue::String(content.clone())),
|
|
Tag::Relay((_, url), _) => Some(TagValue::String(url.to_string())),
|
|
Tag::Relay((_, url), _) => Some(TagValue::String(url.to_string())),
|
|
Tag::Unknown(_, args) => {
|
|
Tag::Unknown(_, args) => {
|
|
- let value = args.get(0).cloned().unwrap_or_default();
|
|
|
|
|
|
+ let value = args.first().cloned().unwrap_or_default();
|
|
Some(
|
|
Some(
|
|
value
|
|
value
|
|
.as_str()
|
|
.as_str()
|
|
@@ -254,10 +254,7 @@ impl<'de> Deserialize<'de> for Tag {
|
|
0 => return Ok(Tag::Empty),
|
|
0 => return Ok(Tag::Empty),
|
|
1 => {
|
|
1 => {
|
|
let tag_name = parts.pop_front().unwrap_or_default();
|
|
let tag_name = parts.pop_front().unwrap_or_default();
|
|
- match tag_name.as_str() {
|
|
|
|
- "encrypted" => return Ok(Tag::Encrypted),
|
|
|
|
- _ => {}
|
|
|
|
- }
|
|
|
|
|
|
+ if tag_name.as_str() == "encrypted" { return Ok(Tag::Encrypted) }
|
|
return Ok(Tag::Unknown(tag_name, vec![]));
|
|
return Ok(Tag::Unknown(tag_name, vec![]));
|
|
}
|
|
}
|
|
_ => {}
|
|
_ => {}
|
|
@@ -271,16 +268,16 @@ impl<'de> Deserialize<'de> for Tag {
|
|
.pop_front()
|
|
.pop_front()
|
|
.ok_or_else::<D::Error, _>(|| de::Error::custom("missing argument"))
|
|
.ok_or_else::<D::Error, _>(|| de::Error::custom("missing argument"))
|
|
.and_then(|id| id.parse().map_err(de::Error::custom))
|
|
.and_then(|id| id.parse().map_err(de::Error::custom))
|
|
- .and_then(|id| {
|
|
|
|
|
|
+ .map(|id| {
|
|
let relayer_url = parts.pop_front().map(|value| (value.parse().ok(), value));
|
|
let relayer_url = parts.pop_front().map(|value| (value.parse().ok(), value));
|
|
|
|
|
|
let extra = parts.pop_front();
|
|
let extra = parts.pop_front();
|
|
- Ok(match tag_type.as_str() {
|
|
|
|
|
|
+ match tag_type.as_str() {
|
|
"e" => Tag::Event(id, relayer_url, extra.map(|x| x.as_str().into())),
|
|
"e" => Tag::Event(id, relayer_url, extra.map(|x| x.as_str().into())),
|
|
"goal" => Tag::ZapGoal(id, relayer_url),
|
|
"goal" => Tag::ZapGoal(id, relayer_url),
|
|
"p" => Tag::PubKey(id, relayer_url, extra),
|
|
"p" => Tag::PubKey(id, relayer_url, extra),
|
|
_ => unreachable!(),
|
|
_ => unreachable!(),
|
|
- })
|
|
|
|
|
|
+ }
|
|
}),
|
|
}),
|
|
"expiration" => {
|
|
"expiration" => {
|
|
let timestamp = parts
|
|
let timestamp = parts
|