Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: macro user id logging (#1663)

Will Hutchinson5de89a7ef277
diff --git a/rust/cloud-storage/macro_user_id/src/user_id.rs b/rust/cloud-storage/macro_user_id/src/user_id.rs
index c0e0926701..922926564b 100644
--- a/rust/cloud-storage/macro_user_id/src/user_id.rs
+++ b/rust/cloud-storage/macro_user_id/src/user_id.rs
@@ -31,13 +31,22 @@ fn macro_user_id(input: &str) -> IResult<&str, MacroUserId<ArcCowStr<'_>>> {
}
/// A structure that encapsulates a macro user id
-#[derive(Debug, Clone, Copy)]
+#[derive(Clone, Copy)]
pub struct MacroUserId<T> {
email_part: Email<()>,
email_part_offset: usize,
user_id: T,
}
+impl<T> std::fmt::Debug for MacroUserId<T>
+where
+ T: AsRef<str>,
+{
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.user_id.as_ref())
+ }
+}
+
impl<T> PartialEq for MacroUserId<T>
where
T: PartialEq,
@@ -62,15 +71,27 @@ where
/// The standard inner type for a [MacroUserId]
/// This is a value which is guaranteed to be unmodified from its original input
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
+#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(try_from = "String", into = "String")]
pub struct MacroUserIdStr<'a>(pub MacroUserId<Lowercase<'a>>);
+impl<'a> std::fmt::Debug for MacroUserIdStr<'a> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.0.as_ref())
+ }
+}
+
/// Deserialize a MacroUserId to a guaranteed borrowed lifetime from the 'de argument
-#[derive(Debug, Clone, Deserialize)]
+#[derive(Clone, Deserialize)]
#[serde(try_from = "&str")]
pub struct BorrowedUserIdStr<'a>(#[serde(borrow)] pub MacroUserId<ArcCowStr<'a>>);
+impl<'a> std::fmt::Debug for BorrowedUserIdStr<'a> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.0.as_ref())
+ }
+}
+
impl<'a> doppleganger::Primitive for MacroUserIdStr<'a> {}
impl<'a> std::fmt::Display for MacroUserIdStr<'a> {
diff --git a/rust/cloud-storage/macro_user_id/src/user_id/tests.rs b/rust/cloud-storage/macro_user_id/src/user_id/tests.rs
index 346c843009..d7af1f0157 100644
--- a/rust/cloud-storage/macro_user_id/src/user_id/tests.rs
+++ b/rust/cloud-storage/macro_user_id/src/user_id/tests.rs
@@ -86,3 +86,12 @@ fn casing_ignored_for_email() {
assert_eq!(id.email_part().local_part(), "###hello###+WEIRD");
}
+
+#[test]
+fn debug_output_is_simple_string() {
+ let id = MacroUserId::parse_from_str("macro|[email protected]").unwrap();
+ assert_eq!(format!("{:?}", id), "macro|[email protected]");
+
+ let id_str = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+ assert_eq!(format!("{:?}", id_str), "macro|[email protected]");
+}