Skip to content

Commit

Permalink
feat(pay): add hack that saves metadata raw on pay query
Browse files Browse the repository at this point in the history
  • Loading branch information
lsunsi committed Dec 6, 2023
1 parent 0720b5c commit 7b64968
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct Query {
pub comment_size: Option<u64>,
pub min: u64,
pub max: u64,
pub metadata_raw: Option<String>,
}

impl std::str::FromStr for Query {
Expand Down Expand Up @@ -76,6 +77,7 @@ impl std::str::FromStr for Query {
});

Ok(Query {
metadata_raw: Some(p.metadata),
callback: p.callback.0.into_owned(),
comment_size: p.comment_allowed,
min: p.min_sendable,
Expand Down Expand Up @@ -275,7 +277,7 @@ mod tests {
let input = r#"
{
"callback": "https://yuri?o=callback",
"metadata": "[[\"text/plain\", \"boneco do steve magal\"]]",
"metadata": "[[\"text/plain\", \"boneco do steve magal\"],[\"text/crazy\", \"👋🇧🇴💾\"]]",
"maxSendable": 315,
"minSendable": 314
}
Expand All @@ -285,6 +287,10 @@ mod tests {

assert_eq!(parsed.callback.to_string(), "https://yuri/?o=callback");
assert_eq!(parsed.short_description, "boneco do steve magal");
assert_eq!(
parsed.metadata_raw.unwrap(),
"[[\"text/plain\", \"boneco do steve magal\"],[\"text/crazy\", \"👋🇧🇴💾\"]]"
);
assert_eq!(parsed.min, 314);
assert_eq!(parsed.max, 315);

Expand Down Expand Up @@ -389,6 +395,7 @@ mod tests {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
};

assert_eq!(
Expand All @@ -410,6 +417,7 @@ mod tests {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
};

assert_eq!(
Expand All @@ -431,6 +439,7 @@ mod tests {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
};

assert_eq!(
Expand All @@ -452,6 +461,7 @@ mod tests {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
};

assert_eq!(
Expand All @@ -473,6 +483,7 @@ mod tests {
max: 315,
identifier: Some(String::from("steve@magal.brutal")),
email: None,
metadata_raw: None,
};

assert_eq!(
Expand All @@ -494,6 +505,7 @@ mod tests {
max: 315,
identifier: None,
email: Some(String::from("steve@magal.brutal")),
metadata_raw: None,
};

assert_eq!(
Expand Down
1 change: 1 addition & 0 deletions tests/lud06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn test() {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
})
}
},
Expand Down
1 change: 1 addition & 0 deletions tests/lud09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn test() {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
})
}
},
Expand Down
1 change: 1 addition & 0 deletions tests/lud11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn test() {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
})
}
},
Expand Down
1 change: 1 addition & 0 deletions tests/lud12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn test() {
max: 315,
identifier: None,
email: None,
metadata_raw: None,
})
}
},
Expand Down
1 change: 1 addition & 0 deletions tests/lud16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async fn test() {
max: 315,
identifier: identifier.clone().filter(|i| i.starts_with('n')),
email: identifier.filter(|i| i.starts_with('j')),
metadata_raw: None,
})
}
},
Expand Down

0 comments on commit 7b64968

Please sign in to comment.