Skip to content

Commit

Permalink
Rename MobilePhoneContact to PhoneContact (tel:)
Browse files Browse the repository at this point in the history
  • Loading branch information
GamePad64 committed Dec 17, 2024
1 parent b5a7aa2 commit c090c5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions notifico-core/src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ pub trait TypedContact: TryFrom<RawContact, Error = EngineError> {
}

#[derive(Serialize, Deserialize, Clone)]
pub struct MobilePhoneContact {
pub struct PhoneContact {
pub number: String,
}

impl TryFrom<RawContact> for MobilePhoneContact {
impl TryFrom<RawContact> for PhoneContact {
type Error = EngineError;

fn try_from(value: RawContact) -> Result<Self, Self::Error> {
Expand All @@ -47,11 +47,11 @@ impl TryFrom<RawContact> 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)
}
Expand Down
4 changes: 2 additions & 2 deletions transports/notifico-smpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl EnginePlugin for SmppPlugin {
}
}

let contact: Vec<MobilePhoneContact> = context.get_recipient()?.get_contacts();
let contact: Vec<PhoneContact> = context.get_recipient()?.get_contacts();

for contact in contact {
for message in context.messages.iter().cloned() {
Expand Down
4 changes: 2 additions & 2 deletions transports/notifico-whatsapp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit c090c5f

Please sign in to comment.