|
@@ -42,7 +42,7 @@ pub enum Error {
|
|
|
///
|
|
|
/// The event must be signed, in the crate::types::Event, which wraps this
|
|
|
/// struct, but all the content of the event is defined here, but the signature.
|
|
|
-#[derive(Debug, Clone, Serialize)]
|
|
|
+#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
|
|
|
pub struct UnsignedEvent {
|
|
|
/// The public key that signs this event
|
|
|
#[serde(rename = "pubkey")]
|
|
@@ -137,7 +137,7 @@ impl UnsignedEvent {
|
|
|
/// This is a wrap for UnsignedEvent but it will serializes the ID and the signature.
|
|
|
///
|
|
|
/// This is the struct that is published to relayers from clients
|
|
|
-#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
pub struct Event {
|
|
|
/// Event Id
|
|
|
///
|
|
@@ -170,6 +170,11 @@ impl Event {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ /// Returns the event author
|
|
|
+ pub fn author(&self) -> &Id {
|
|
|
+ &self.inner.public_key
|
|
|
+ }
|
|
|
+
|
|
|
/// Checks if the event is valid
|
|
|
pub fn is_valid(&self) -> Result<(), Error> {
|
|
|
let calculated_id = self.inner.id()?;
|
|
@@ -179,6 +184,11 @@ impl Event {
|
|
|
Self::verify_signature(&self.inner.public_key, &self.signature, &self.id)
|
|
|
}
|
|
|
|
|
|
+ /// Returns list of tags for this event
|
|
|
+ pub fn tags(&self) -> &[super::Tag] {
|
|
|
+ &self.inner.tags
|
|
|
+ }
|
|
|
+
|
|
|
/// Returns a reference to the inner content (the parsed content)
|
|
|
pub fn content(&self) -> &Content {
|
|
|
&self.inner.content
|