Skip to content

Commit

Permalink
Merge pull request #909 from Shadow243/stalwart-jmap-648
Browse files Browse the repository at this point in the history
improve JMAP compatibilities with stalwart
  • Loading branch information
kroky authored Mar 5, 2024
2 parents 441a228 + e9cecf9 commit 47fdd9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function del($id) {
}

public static function get($id) {
if (array_key_exists($id, self::$entities)) {
if (is_array(self::$entities) && array_key_exists($id, self::$entities)) {
return self::$entities[$id];
}
return false;
Expand Down
14 changes: 6 additions & 8 deletions modules/imap/hm-jmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,16 +833,16 @@ private function normalize_headers($msg) {
'internal_date' => $msg['receivedAt'],
'size' => $msg['size'],
'date' => $msg['sentAt'],
'from' => $this->combine_addresses($msg['from']),
'to' => $this->combine_addresses($msg['to']),
'from' => (is_array($msg['from']) ? $this->combine_addresses($msg['from']) : $msg['from']),
'to' => (is_array($msg['to']) ? $this->combine_addresses($msg['to']) : $msg['to']),
'subject' => $msg['subject'],
'content-type' => '',
'timestamp' => strtotime($msg['receivedAt']),
'charset' => '',
'x-priority' => '',
'type' => 'jmap',
'references' => '',
'message_id' => implode(' ', $msg['messageId']),
'message_id' => (is_array($msg['messageId']) ? implode(' ', $msg['messageId']) : ''),
'x_auto_bcc' => ''
);
}
Expand All @@ -861,6 +861,7 @@ private function init_session($data, $url) {
preg_replace("/\/$/", '', $url),
$data['apiUrl']
);
$this->api_url = $data['apiUrl'];
$this->download_url = sprintf(
'%s%s',
preg_replace("/\/$/", '', $url),
Expand All @@ -872,10 +873,7 @@ private function init_session($data, $url) {
$data['uploadUrl']
);
foreach ($data['accounts'] as $account) {
if (array_key_exists('isPrimary', $account) && $account['isPrimary']) {
$this->account_id = array_keys($data['accounts'])[0];
break;
}
$this->account_id = array_keys($data['accounts'])[0];
}
if ($this->account_id && count($this->folder_list) == 0) {
$this->reset_folders();
Expand Down Expand Up @@ -994,7 +992,7 @@ private function format_request($methods, $caps=array()) {
return json_encode(array(
'using' => count($caps) == 0 ? $this->default_caps : $caps,
'methodCalls' => $methods
));
), JSON_UNESCAPED_SLASHES);
}

/**
Expand Down

0 comments on commit 47fdd9d

Please sign in to comment.