Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/scram.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class ScramAuthenticator {

private function getHashAlgorithm($scramAlgorithm) {
$parts = explode('-', mb_strtolower($scramAlgorithm));
return $this->hashes[$parts[1]] ?? 'sha1'; // Default to sha1 if the algorithm is not found
if (count($parts) > 2) {
$hashAlgorithm = implode('-', array_slice($parts, 1));
} else {
$hashAlgorithm = $parts[1] ?? '';
}
return $this->hashes[$hashAlgorithm] ?? 'sha1'; // Default to sha1 if the algorithm is not found
}
private function log($message) {
// Use Hm_Debug to add the debug message
Expand Down
16 changes: 16 additions & 0 deletions modules/core/hm-mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public function __construct($server_id, $user_config, $session, $config) {
}
}

/**
* Set connection
* @param object $connection The connection object to inject
*/
public function set_connection($connection) {
$this->connection = $connection;
}

public function connect() {
if (! $this->connection) {
return false;
Expand Down Expand Up @@ -563,6 +571,14 @@ public function search($folder, $target='ALL', $terms=array(), $sort=null, $reve
if (! $this->select_folder($folder)) {
return [];
}

// Handle JMAP specifically since it's "IMAP-like" but has different method signatures
if ($this->type === self::TYPE_JMAP) {
// JMAP search uses IMAP-like parameters but handles sorting internally
$uids = $this->connection->search($target, false, $terms, [], $exclude_deleted, $exclude_auto_bcc, $only_auto_bcc);
return $uids;
}

if ($this->is_imap()) {
if ($sort) {
if ($this->connection->is_supported('SORT')) {
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/hm-imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Hm_IMAP extends Hm_IMAP_Cache {
);

/* holds the current IMAP connection state */
private $state = 'disconnected';
public $state = 'disconnected';

/* used for message part content streaming */
private $stream_size = 0;
Expand Down
31 changes: 31 additions & 0 deletions modules/imap/hm-jmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1359,4 +1359,35 @@ private function get_raw_message_content($blob_id, $name) {
$this->api->format = 'json';
return $res;
}

/**
* Check if a feature is supported (JMAP compatibility method)
* JMAP doesn't use IMAP extensions, so most features are handled differently
*/
public function is_supported($feature) {
// TODO: Implement more features as needed, but most IMAP features don't have direct JMAP equivalents
return false;
}

/**
* Get message sort order (JMAP compatibility method)
* This provides IMAP-like interface for JMAP sorting
* JMAP doesn't have direct equivalent to IMAP SORT
* Fall back to search and let JMAP handle sorting internally
*/
public function get_message_sort_order($sort, $reverse=false, $target='ALL', $terms=array(), $exclude_deleted=true, $exclude_auto_bcc=true, $only_auto_bcc=false) {
return $this->search($target, false, $terms, [], $exclude_deleted, $exclude_auto_bcc, $only_auto_bcc);
}

/**
* Sort by fetch (JMAP compatibility method)
* JMAP doesn't need this since it handles sorting differently
*/
public function sort_by_fetch($sort, $reverse=false, $target='ALL', $uids='') {
// TODO: implement according to JMAP spec if needed
if (empty($uids)) {
return [];
}
return explode(',', $uids);
}
}
Loading