Skip to content

Commit

Permalink
feat(backend): Fix php error Call to a member function authed() on null
Browse files Browse the repository at this point in the history
  • Loading branch information
amaninyumu1 committed Feb 10, 2025
1 parent aed9a95 commit bd6abb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions modules/core/hm-mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public function server_type() {
}

public function authed() {
if ($this->connection) {
return false;
}
if ($this->is_imap()) {
return $this->connection->get_state() == 'authenticated' || $this->connection->get_state() == 'selected';
} elseif ($this->is_smtp()) {
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->get_connection() != null && $mailbox->connect()) {
if ($mailbox->authed()) {
$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->get_connection() != null && $mailbox->connect()) {
if ($mailbox->authed()) {
$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 || ! $mailbox->connect()) {
if (! $mailbox->authed()) {
return -1;
}

Expand Down

0 comments on commit bd6abb8

Please sign in to comment.