mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-08-25 16:01:56 +00:00
fix: align forward params with backend, use Option<bool> for default handling
This commit is contained in:
@@ -1698,11 +1698,11 @@ message SendControl {
|
||||
// Optional: The mail envelope details for the SMTP transaction.
|
||||
optional MailEnvelope envelope = 1;
|
||||
// If true, saves the sent email to the 'Sent' folder of the sending account.
|
||||
bool save_to_sent = 2;
|
||||
optional bool save_to_sent = 2;
|
||||
// Optional: The name of the folder where the sent email should be saved (e.g., "Sent Items").
|
||||
optional string sent_folder = 3;
|
||||
// If true, simulates the email sending process without actually sending.
|
||||
bool dry_run = 4;
|
||||
optional bool dry_run = 4;
|
||||
// Optional: The specific timestamp to schedule the email for sending (Unix timestamp).
|
||||
optional int64 send_at = 5;
|
||||
// Optional: The retry policy to apply if sending fails.
|
||||
@@ -1714,7 +1714,7 @@ message SendControl {
|
||||
// Optional: A campaign ID to associate with this email for tracking purposes.
|
||||
optional string campaign_id = 9;
|
||||
// If true, enables tracking (e.g., open tracking, link click tracking) for this email.
|
||||
bool enable_tracking = 10;
|
||||
optional bool enable_tracking = 10;
|
||||
}
|
||||
|
||||
// MailEnvelope defines the sender and recipients for the SMTP transaction.
|
||||
|
||||
@@ -105,7 +105,7 @@ impl TryFrom<&TaskMetaEntity> for SendEmailTask {
|
||||
attachment_count: smtp_task.attachment_count,
|
||||
cache_key: smtp_task.cache_key,
|
||||
envelope: smtp_task.control.envelope,
|
||||
save_to_sent: smtp_task.control.save_to_sent,
|
||||
save_to_sent: smtp_task.control.save_to_sent.unwrap_or(false),
|
||||
sent_folder: smtp_task.control.sent_folder,
|
||||
send_at: smtp_task.control.send_at,
|
||||
mta: smtp_task.control.mta,
|
||||
|
||||
@@ -426,13 +426,13 @@ pub struct SendControl {
|
||||
/// The email envelope containing sender and recipient addresses (SMTP `MAIL FROM` and `RCPT TO`).
|
||||
pub envelope: Option<MailEnvelope>,
|
||||
/// Whether to save a copy of the email to the sent folder after successful delivery.
|
||||
pub save_to_sent: bool,
|
||||
pub save_to_sent: Option<bool>,
|
||||
/// The name of the folder where the email should be saved if `save_to_sent` is true.
|
||||
/// If `None` and `save_to_sent` is true, a default folder (e.g., "Sent") may be used.
|
||||
pub sent_folder: Option<String>,
|
||||
/// Whether to perform a dry run (simulate sending without actual delivery).
|
||||
/// Useful for testing email configurations without sending emails.
|
||||
pub dry_run: bool,
|
||||
pub dry_run: Option<bool>,
|
||||
/// An optional Unix timestamp (milliseconds since epoch) specifying when to send the email.
|
||||
/// If `None`, the email is sent immediately.
|
||||
pub send_at: Option<i64>,
|
||||
@@ -456,7 +456,7 @@ pub struct SendControl {
|
||||
/// Note: This field only takes effect **if system-wide tracking is enabled** (`SETTINGS.rustmailer_email_tracking_enabled == true`).
|
||||
/// If system tracking is disabled, this flag has no effect and no tracking will be inserted.
|
||||
/// - This field is **only used when sending new emails**
|
||||
pub enable_tracking: bool,
|
||||
pub enable_tracking: Option<bool>,
|
||||
}
|
||||
|
||||
impl SendControl {
|
||||
@@ -522,7 +522,7 @@ impl SendControl {
|
||||
account_id: u64,
|
||||
body: &[u8],
|
||||
) -> RustMailerResult<()> {
|
||||
if self.save_to_sent {
|
||||
if let Some(true) = self.save_to_sent {
|
||||
let encoded_sent_folder = self.resolve_sent_mailbox(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor
|
||||
@@ -761,7 +761,7 @@ impl EmailHandler {
|
||||
)
|
||||
})?;
|
||||
// Skip sending if dry_run is enabled; used for testing or simulation.
|
||||
if send_control.dry_run {
|
||||
if let Some(true) = send_control.dry_run {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
@@ -212,26 +212,28 @@ impl EmailBuilder for SendEmailRequest {
|
||||
}
|
||||
let mut tracker: Option<EmailTracker> = None;
|
||||
|
||||
if self.send_control.enable_tracking && SETTINGS.rustmailer_email_tracking_enabled {
|
||||
let campaign_id = self
|
||||
.send_control
|
||||
.campaign_id
|
||||
.clone()
|
||||
.unwrap_or_else(|| "default".to_string());
|
||||
if let Some(true) = self.send_control.enable_tracking {
|
||||
if SETTINGS.rustmailer_email_tracking_enabled {
|
||||
let campaign_id = self
|
||||
.send_control
|
||||
.campaign_id
|
||||
.clone()
|
||||
.unwrap_or_else(|| "default".to_string());
|
||||
|
||||
let recipient_address = recipient
|
||||
.to
|
||||
.first()
|
||||
.map(|r| r.address.clone())
|
||||
.unwrap_or_default();
|
||||
let recipient_address = recipient
|
||||
.to
|
||||
.first()
|
||||
.map(|r| r.address.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
tracker = Some(EmailTracker::new(
|
||||
campaign_id,
|
||||
message_id.clone(),
|
||||
recipient_address,
|
||||
account_id.into(),
|
||||
account.email.clone(),
|
||||
));
|
||||
tracker = Some(EmailTracker::new(
|
||||
campaign_id,
|
||||
message_id.clone(),
|
||||
recipient_address,
|
||||
account_id.into(),
|
||||
account.email.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
builder = match &self.eml {
|
||||
|
||||
@@ -85,7 +85,7 @@ export function EventHooksMutateDrawer({ open, onOpenChange, currentRow }: Props
|
||||
const httpForm = useForm<HttpEventHookForm>({
|
||||
resolver: zodResolver(httpFormSchema),
|
||||
defaultValues: currentRow ? {
|
||||
account_id: currentRow.account_id,
|
||||
account_id: currentRow.account_id ?? undefined,
|
||||
description: currentRow.description ?? undefined,
|
||||
enabled: currentRow.enabled,
|
||||
global: currentRow.global === 1,
|
||||
@@ -101,7 +101,7 @@ export function EventHooksMutateDrawer({ open, onOpenChange, currentRow }: Props
|
||||
const natsForm = useForm<NatsEventHookForm>({
|
||||
resolver: zodResolver(natsFormSchema),
|
||||
defaultValues: currentRow ? {
|
||||
account_id: currentRow.account_id,
|
||||
account_id: currentRow.account_id ?? undefined,
|
||||
description: currentRow.description,
|
||||
enabled: currentRow.enabled,
|
||||
global: currentRow.global === 1,
|
||||
|
||||
@@ -131,7 +131,8 @@ export function EmailActionDialog({
|
||||
include_all_attachments: false,
|
||||
send_control: {
|
||||
save_to_sent: false,
|
||||
dry_run: false
|
||||
dry_run: false,
|
||||
enable_tracking: false
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -145,7 +146,8 @@ export function EmailActionDialog({
|
||||
include_all_attachments: false,
|
||||
send_control: {
|
||||
save_to_sent: false,
|
||||
dry_run: false
|
||||
dry_run: false,
|
||||
enable_tracking: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user