Created
January 9, 2025 23:07
-
-
Save richiethomas/44c7474d40758120635bc500250b23c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/handlers/requests/upsert_keyword_template.rs b/src/handlers/requests/upsert_keyword_template.rs | |
index 33c3861..35c7054 100644 | |
--- a/src/handlers/requests/upsert_keyword_template.rs | |
+++ b/src/handlers/requests/upsert_keyword_template.rs | |
@@ -35,8 +35,8 @@ impl TryFrom<Request<UpsertKeywordTemplateRequest>> for UpsertKeywordTemplate { | |
} = required(keyword_template, "keyword_template")?; | |
let segmented_by_subscribed: SegmentedBySubscribed = SegmentedBySubscribed::new( | |
- unpack_uuid(template_id.clone(),"template_id").unwrap(), | |
- unpack_uuid(unsubscribed_template_id.clone(),"unsubscribed_template_id").unwrap() | |
+ Some(unpack_uuid(template_id.clone(),"template_id").unwrap()), | |
+ Some(unpack_uuid(unsubscribed_template_id.clone(),"unsubscribed_template_id").unwrap()) | |
); | |
let template_type = TemplateType::try_derive_from_parts( | |
template.clone(), | |
diff --git a/src/keyword_actions/mod.rs b/src/keyword_actions/mod.rs | |
index eaa876d..1a8aa85 100644 | |
--- a/src/keyword_actions/mod.rs | |
+++ b/src/keyword_actions/mod.rs | |
@@ -380,10 +380,8 @@ mod tests { | |
fn new_random_segmented_template(subscribed_template_id: Uuid, unsubscribed_template_id: Uuid) -> TemplateType { | |
TemplateType::SegmentedTemplate(SegmentedBySubscribed::new( | |
- subscribed_template_id, | |
- // Uuid::new_v4(), | |
- unsubscribed_template_id | |
- // Uuid::new_v4(), | |
+ Some(subscribed_template_id), | |
+ Some(unsubscribed_template_id) | |
)) | |
} | |
diff --git a/src/models/keyword_template/mod.rs b/src/models/keyword_template/mod.rs | |
index d4e4909..b7dc3e7 100644 | |
--- a/src/models/keyword_template/mod.rs | |
+++ b/src/models/keyword_template/mod.rs | |
@@ -135,8 +135,8 @@ impl FromRow for KeywordTemplate { | |
let template_type = TemplateType::try_derive_from_parts( | |
template_text.clone(), | |
SegmentedBySubscribed::new( | |
- template_id.unwrap_or_default(), | |
- unsubscribed_template_id.unwrap_or_default() | |
+ Some(template_id.unwrap_or_default()), | |
+ Some(unsubscribed_template_id.unwrap_or_default()) | |
), | |
template_type_stored, | |
) | |
@@ -195,8 +195,8 @@ impl From<KeywordTemplate> for protobuf_schema::sms::v1::KeywordTemplate { | |
TemplateType::PlainText(template) => (template, None, None), | |
TemplateType::SegmentedTemplate(segmented_by_subscribed) => ( | |
"".to_string(), | |
- pack_uuid(segmented_by_subscribed.subscribed_template_id), | |
- pack_uuid(segmented_by_subscribed.unsubscribed_template_id), | |
+ pack_uuid(segmented_by_subscribed.subscribed_template_id.unwrap()), | |
+ pack_uuid(segmented_by_subscribed.unsubscribed_template_id.unwrap()), | |
), | |
}; | |
@@ -280,7 +280,7 @@ impl KeywordTemplate { | |
TemplateType::SegmentedTemplate(segmented_by_subscribed) => { | |
KeywordType::Generic(GenericKeyword::new( | |
self.keyword.clone(), | |
- segmented_by_subscribed.subscribed_template_id, | |
+ segmented_by_subscribed.subscribed_template_id.unwrap(), | |
self.actions.clone(), | |
self.player_tag_changes.clone(), | |
)) | |
@@ -296,8 +296,8 @@ mod tests { | |
fn new_random_segmented_template() -> TemplateType { | |
TemplateType::SegmentedTemplate(SegmentedBySubscribed::new( | |
- Uuid::new_v4(), | |
- Uuid::new_v4(), | |
+ Some(Uuid::new_v4()), | |
+ Some(Uuid::new_v4()), | |
)) | |
} | |
diff --git a/src/models/keyword_template/template_type.rs b/src/models/keyword_template/template_type.rs | |
index 3620d33..6d5124c 100644 | |
--- a/src/models/keyword_template/template_type.rs | |
+++ b/src/models/keyword_template/template_type.rs | |
@@ -4,14 +4,14 @@ use uuid::Uuid; | |
#[derive(Clone, Debug, Default)] | |
pub struct SegmentedBySubscribed { | |
- pub subscribed_template_id: Uuid, | |
- pub unsubscribed_template_id: Uuid, | |
+ pub subscribed_template_id: Option<Uuid>, | |
+ pub unsubscribed_template_id: Option<Uuid>, | |
} | |
impl SegmentedBySubscribed { | |
pub fn new( | |
- subscribed_template_id: Uuid, | |
- unsubscribed_template_id: Uuid, | |
+ subscribed_template_id: Option<Uuid>, | |
+ unsubscribed_template_id: Option<Uuid>, | |
) -> Self { | |
Self { | |
subscribed_template_id, | |
@@ -20,14 +20,18 @@ impl SegmentedBySubscribed { | |
} | |
pub fn is_nil(&self) -> bool { | |
- match ( | |
- self.subscribed_template_id.is_nil(), | |
- self.unsubscribed_template_id | |
- .is_nil(), | |
- ) { | |
- (true, true) => true, | |
+ match (self.subscribed_template_id, self.unsubscribed_template_id) { | |
+ (None, None) => true, | |
_ => false, | |
} | |
+ // match ( | |
+ // self.subscribed_template_id.is_nil(), | |
+ // self.unsubscribed_template_id | |
+ // .is_nil(), | |
+ // ) { | |
+ // (true, true) => true, | |
+ // _ => false, | |
+ // } | |
} | |
} | |
@@ -42,8 +46,8 @@ pub enum TemplateType { | |
impl TemplateType { | |
pub fn new_segmented_template( | |
- subscribed_template_id: Uuid, | |
- unsubscribed_template_id: Uuid, | |
+ subscribed_template_id: Option<Uuid>, | |
+ unsubscribed_template_id: Option<Uuid>, | |
) -> Self { | |
Self::SegmentedTemplate(SegmentedBySubscribed::new( | |
subscribed_template_id, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment