feat(webhooks): store request and response payloads in events table (#4029)

This commit is contained in:
Sanchith Hegde
2024-03-14 12:30:37 +05:30
committed by GitHub
parent ad17cc7383
commit fd67a6c225
32 changed files with 1267 additions and 644 deletions

View File

@ -493,9 +493,9 @@ pub type OptionalEncryptableName = Option<Encryptable<Secret<String>>>;
pub type OptionalEncryptableEmail = Option<Encryptable<Secret<String, pii::EmailStrategy>>>;
/// Type alias for `Option<Encryptable<Secret<String>>>` used for `phone` field
pub type OptionalEncryptablePhone = Option<Encryptable<Secret<String>>>;
/// Type alias for `Option<Encryptable<Secret<serde_json::Value>>>` used for `phone` field
/// Type alias for `Option<Encryptable<Secret<serde_json::Value>>>`
pub type OptionalEncryptableValue = Option<Encryptable<Secret<serde_json::Value>>>;
/// Type alias for `Option<Secret<serde_json::Value>>` used for `phone` field
/// Type alias for `Option<Secret<serde_json::Value>>`
pub type OptionalSecretValue = Option<Secret<serde_json::Value>>;
#[cfg(test)]

View File

@ -198,3 +198,9 @@ pub fn generate_id_with_default_len(prefix: &str) -> String {
let len = consts::ID_LENGTH;
format!("{}_{}", prefix, nanoid::nanoid!(len, &consts::ALPHABETS))
}
/// Generate a time-ordered (time-sortable) unique identifier using the current time
#[inline]
pub fn generate_time_ordered_id(prefix: &str) -> String {
format!("{prefix}_{}", uuid::Uuid::now_v7().as_simple())
}

View File

@ -51,6 +51,7 @@ impl std::fmt::Debug for RequestContent {
Self::FormUrlEncoded(_) => "FormUrlEncodedRequestBody",
Self::FormData(_) => "FormDataRequestBody",
Self::Xml(_) => "XmlRequestBody",
Self::RawBytes(_) => "RawBytesRequestBody",
})
}
}
@ -60,6 +61,7 @@ pub enum RequestContent {
FormUrlEncoded(Box<dyn masking::ErasedMaskSerialize + Send>),
FormData(reqwest::multipart::Form),
Xml(Box<dyn masking::ErasedMaskSerialize + Send>),
RawBytes(Vec<u8>),
}
impl Request {
@ -200,6 +202,7 @@ impl RequestBody {
}
RequestContent::Xml(i) => quick_xml::se::to_string(&i).unwrap_or_default().into(),
RequestContent::FormData(_) => String::new().into(),
RequestContent::RawBytes(_) => String::new().into(),
}
}
}