Skip to content

Commit

Permalink
Save UTC time to fix delayed scheduled message sending
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Feb 11, 2025
1 parent cfab9e2 commit dfa6839
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function get_scheduled_date($format, $only_label = false) {
return [$label, date('D, H:i', $time)];
}

return date('D, d M Y H:i', $time);
return date('D, d M Y H:i T', $time);
}
}

Expand Down
10 changes: 6 additions & 4 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -2425,8 +2425,9 @@ function setupActionSchedule(callback) {
}
});
$(document).on('change', '.nexter_input_date', function (e) {
if ($(this).val() && new Date().getTime() < new Date($(this).val()).getTime()) {
$('.nexter_input').val($(this).val()).trigger('change');
const selectedDate = new Date($(this).val());
if ($(this).val() && new Date().getTime() < selectedDate.getTime()) {
$('.nexter_input').val(selectedDate.toISOString()).trigger('change');
}
});
$(document).on('change', '.nexter_input', callback);
Expand All @@ -2451,8 +2452,9 @@ function setupActionSnooze(callback) {
}
});
$(document).on('change', '.nexter_input_date_snooze', function (e) {
if ($(this).val() && new Date().getTime() < new Date($(this).val()).getTime()) {
$('.nexter_input_snooze').val($(this).val()).trigger('change');
const selectedDate = new Date($(this).val());
if ($(this).val() && new Date().getTime() < selectedDate.getTime()) {
$('.nexter_input_snooze').val(selectedDate.toISOString()).trigger('change');
}
});
$(document).on('change', '.nexter_input_snooze', callback);
Expand Down
4 changes: 1 addition & 3 deletions modules/smtp/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ function send_scheduled_message($handler, $imapMailbox, $folder, $msg_id, $send_
}
$profile = $profiles[0];
}
$smtpConfig = Hm_SMTP_List::dumpForMailbox($profile['smtp_id']);
$smtpMailbox = new Hm_Mailbox($profile['smtp_id'], $handler->user_config, $handler->session, $smtpConfig);

$smtpMailbox = Hm_SMTP_List::connect($profile['smtp_id'], false);
if (! $smtpMailbox->authed()) {
Hm_Msgs::add("ERRFailed to authenticate to the SMTP server");
return;
Expand Down
6 changes: 3 additions & 3 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ public function process() {

foreach ($servers as $server_id => $config) {
$mailbox = new Hm_Mailbox($server_id, $this->user_config, $this->session, $config);
if ($mailbox->authed()) {
if ($mailbox->connect()) {
$folder = 'Scheduled';
$ret = $mailbox->get_messages($folder, 'DATE', false, 'ALL');
foreach ($ret[1] as $msg) {
Expand Down Expand Up @@ -1621,7 +1621,7 @@ public function process() {
$imap_server = Hm_IMAP_List::getForMailbox($imap_server_id);

$mailbox = new Hm_Mailbox($imap_server_id, $this->user_config, $this->session, $imap_server);
if ($mailbox->authed()) {
if ($mailbox->connect()) {
$folder = hex2bin($folder);
if (reschedule_message_sending($this, $mailbox, $msg_id, $folder, $new_schedule_date)) {
$scheduled_msg_count++;
Expand Down Expand Up @@ -2047,7 +2047,7 @@ function save_imap_draft($atts, $id, $session, $mod, $mod_cache, $uploaded_files
return -1;
}
$mailbox = new Hm_Mailbox($imap_profile['id'], $mod->user_config, $session, $imap_profile);
if (! $mailbox->authed()) {
if (! $mailbox->connect()) {
return -1;
}

Expand Down

0 comments on commit dfa6839

Please sign in to comment.