From c090c5ff5b1421afd6c5790300dad656b167d5e2 Mon Sep 17 00:00:00 2001 From: Alexander Shishenko Date: Tue, 17 Dec 2024 21:46:26 +0300 Subject: [PATCH] Rename MobilePhoneContact to PhoneContact (tel:) --- notifico-core/src/contact.rs | 10 +++++----- transports/notifico-smpp/src/lib.rs | 4 ++-- transports/notifico-whatsapp/src/lib.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/notifico-core/src/contact.rs b/notifico-core/src/contact.rs index 5402aeb..9664f51 100644 --- a/notifico-core/src/contact.rs +++ b/notifico-core/src/contact.rs @@ -33,11 +33,11 @@ pub trait TypedContact: TryFrom { } #[derive(Serialize, Deserialize, Clone)] -pub struct MobilePhoneContact { +pub struct PhoneContact { pub number: String, } -impl TryFrom for MobilePhoneContact { +impl TryFrom for PhoneContact { type Error = EngineError; fn try_from(value: RawContact) -> Result { @@ -47,11 +47,11 @@ impl TryFrom for MobilePhoneContact { } } -impl TypedContact for MobilePhoneContact { - const CONTACT_TYPE: &'static str = "mobile_phone"; +impl TypedContact for PhoneContact { + const CONTACT_TYPE: &'static str = "tel"; } -impl MobilePhoneContact { +impl PhoneContact { pub fn msisdn(&self) -> &str { self.number.strip_prefix("+").unwrap_or(&self.number) } diff --git a/transports/notifico-smpp/src/lib.rs b/transports/notifico-smpp/src/lib.rs index 4f32b14..1b58d0b 100644 --- a/transports/notifico-smpp/src/lib.rs +++ b/transports/notifico-smpp/src/lib.rs @@ -6,7 +6,7 @@ use crate::step::{Step, STEPS}; use async_trait::async_trait; use futures_util::sink::SinkExt; use futures_util::StreamExt; -use notifico_core::contact::MobilePhoneContact; +use notifico_core::contact::PhoneContact; use notifico_core::credentials::CredentialStorage; use notifico_core::engine::{EnginePlugin, PipelineContext, StepOutput}; use notifico_core::error::EngineError; @@ -102,7 +102,7 @@ impl EnginePlugin for SmppPlugin { } } - let contact: Vec = context.get_recipient()?.get_contacts(); + let contact: Vec = context.get_recipient()?.get_contacts(); for contact in contact { for message in context.messages.iter().cloned() { diff --git a/transports/notifico-whatsapp/src/lib.rs b/transports/notifico-whatsapp/src/lib.rs index 15baff0..3f5183c 100644 --- a/transports/notifico-whatsapp/src/lib.rs +++ b/transports/notifico-whatsapp/src/lib.rs @@ -1,7 +1,7 @@ use crate::cloudapi::{MessageType, MessagingProduct}; use crate::credentials::WhatsAppCredentials; use async_trait::async_trait; -use notifico_core::contact::{MobilePhoneContact, RawContact}; +use notifico_core::contact::{PhoneContact, RawContact}; use notifico_core::credentials::RawCredential; use notifico_core::engine::{Message, PipelineContext}; use notifico_core::simpletransport::SimpleTransport; @@ -32,7 +32,7 @@ impl SimpleTransport for WabaTransport { _context: &mut PipelineContext, ) -> Result<(), EngineError> { let credential: WhatsAppCredentials = credential.try_into()?; - let contact: MobilePhoneContact = contact.try_into()?; + let contact: PhoneContact = contact.try_into()?; let message: WhatsAppContent = message.content.try_into()?; let url = format!(