Skip to content

Commit e4a96ba

Browse files
authored
refactor(backend): expose more message header fields (message-id & in-reply-to) to the client (#1529)
1 parent e40fb8e commit e4a96ba

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

modules/core/message_list_functions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ function human_readable_interval($date_str) {
208208
* @return array
209209
*/
210210
if (!hm_exists('message_list_row')) {
211-
function message_list_row($values, $id, $style, $output_mod, $row_class='') {
211+
function message_list_row($values, $id, $style, $output_mod, $row_class='', $msgId = '', $inReplyTo = '') {
212212
$res = '<tr class="'.$output_mod->html_safe($id);
213213
if ($row_class) {
214214
$res .= ' '.$output_mod->html_safe($row_class);
215215
}
216+
if (!empty($msgId)) {
217+
$res .= '" data-msg-id="'.$output_mod->html_safe($msgId);
218+
}
219+
if (!empty($inReplyTo)) {
220+
$res .= '" data-in-reply-to="'.$output_mod->html_safe($inReplyTo);
221+
}
216222
$data_uid = "";
217223
if ($uids = explode("_", $id)) {
218224
if (isset($uids[2])) {

modules/imap/functions.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,16 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
321321
// $url = '?page=compose&list_path='.sprintf('imap_%s_%s', $msg['server_id'], $msg['folder']).'&uid='.$msg['uid'].'&imap_draft=1';
322322
//}
323323

324+
$msgId = $msg['message_id'] ?? '';
325+
$inReplyTo = $msg['in_reply_to'] ?? '';
326+
327+
if ($msgId) {
328+
$msgId = str_replace(['<', '>'], '', trim($msgId));
329+
}
330+
if ($inReplyTo) {
331+
$inReplyTo = str_replace(['<', '>'], '', trim($inReplyTo));
332+
}
333+
324334
if ($style == 'news') {
325335
$res[$id] = message_list_row(array(
326336
array('checkbox_callback', $id),
@@ -334,7 +344,9 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
334344
$id,
335345
$style,
336346
$output_module,
337-
$row_class
347+
$row_class,
348+
$msgId,
349+
$inReplyTo
338350
);
339351
}
340352
else {
@@ -350,7 +362,9 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
350362
$id,
351363
$style,
352364
$output_module,
353-
$row_class
365+
$row_class,
366+
$msgId,
367+
$inReplyTo
354368
);
355369
}
356370
}

modules/imap/hm-imap.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ public function get_message_list($uids, $raw=false, $include_content_body = fals
974974
if ($this->is_supported( 'X-GM-EXT-1' )) {
975975
$command .= 'X-GM-MSGID X-GM-THRID X-GM-LABELS ';
976976
}
977-
$command .= "BODY.PEEK[HEADER.FIELDS (SUBJECT X-AUTO-BCC FROM DATE CONTENT-TYPE X-PRIORITY TO LIST-ARCHIVE REFERENCES MESSAGE-ID X-SNOOZED X-SCHEDULE X-PROFILE-ID X-DELIVERY)]";
977+
$command .= "BODY.PEEK[HEADER.FIELDS (SUBJECT X-AUTO-BCC FROM DATE CONTENT-TYPE X-PRIORITY TO LIST-ARCHIVE REFERENCES MESSAGE-ID IN-REPLY-TO X-SNOOZED X-SCHEDULE X-PROFILE-ID X-DELIVERY)]";
978978
if ($include_content_body) {
979979
$command .= " BODY.PEEK[TEXT]<0.500>";
980980
}
@@ -988,8 +988,8 @@ public function get_message_list($uids, $raw=false, $include_content_body = fals
988988
$res = $this->get_response(false, true);
989989
$status = $this->check_response($res, true);
990990
$tags = array('X-GM-MSGID' => 'google_msg_id', 'X-GM-THRID' => 'google_thread_id', 'X-GM-LABELS' => 'google_labels', 'UID' => 'uid', 'FLAGS' => 'flags', 'RFC822.SIZE' => 'size', 'INTERNALDATE' => 'internal_date');
991-
$junk = array('X-AUTO-BCC', 'MESSAGE-ID', 'REFERENCES', 'X-SNOOZED', 'X-SCHEDULE', 'X-PROFILE-ID', 'X-DELIVERY', 'LIST-ARCHIVE', 'SUBJECT', 'FROM', 'CONTENT-TYPE', 'TO', '(', ')', ']', 'X-PRIORITY', 'DATE');
992-
$flds = array('x-auto-bcc' => 'x_auto_bcc', 'message-id' => 'message_id', 'references' => 'references', 'x-snoozed' => 'x_snoozed', 'x-schedule' => 'x_schedule', 'x-profile-id' => 'x_profile_id', 'x-delivery' => 'x_delivery', 'list-archive' => 'list_archive', 'date' => 'date', 'from' => 'from', 'to' => 'to', 'subject' => 'subject', 'content-type' => 'content_type', 'x-priority' => 'x_priority', 'body' => 'content_body');
991+
$junk = array('X-AUTO-BCC', 'MESSAGE-ID', 'IN-REPLY-TO', 'REFERENCES', 'X-SNOOZED', 'X-SCHEDULE', 'X-PROFILE-ID', 'X-DELIVERY', 'LIST-ARCHIVE', 'SUBJECT', 'FROM', 'CONTENT-TYPE', 'TO', '(', ')', ']', 'X-PRIORITY', 'DATE');
992+
$flds = array('x-auto-bcc' => 'x_auto_bcc', 'message-id' => 'message_id', 'in-reply-to' => 'in_reply_to', 'references' => 'references', 'x-snoozed' => 'x_snoozed', 'x-schedule' => 'x_schedule', 'x-profile-id' => 'x_profile_id', 'x-delivery' => 'x_delivery', 'list-archive' => 'list_archive', 'date' => 'date', 'from' => 'from', 'to' => 'to', 'subject' => 'subject', 'content-type' => 'content_type', 'x-priority' => 'x_priority', 'body' => 'content_body');
993993
$headers = array();
994994

995995
foreach ($res as $n => $vals) {
@@ -1002,6 +1002,7 @@ public function get_message_list($uids, $raw=false, $include_content_body = fals
10021002
$references = '';
10031003
$date = '';
10041004
$message_id = '';
1005+
$in_reply_to = '';
10051006
$x_priority = 0;
10061007
$content_type = '';
10071008
$to = '';
@@ -1089,7 +1090,7 @@ public function get_message_list($uids, $raw=false, $include_content_body = fals
10891090
'date' => $date, 'from' => $from, 'to' => $to, 'subject' => $subject, 'content-type' => $content_type,
10901091
'timestamp' => time(), 'charset' => $cset, 'x-priority' => $x_priority, 'google_msg_id' => $google_msg_id,
10911092
'google_thread_id' => $google_thread_id, 'google_labels' => $google_labels, 'list_archive' => $list_archive,
1092-
'references' => $references, 'message_id' => $message_id, 'x_auto_bcc' => $x_auto_bcc,
1093+
'references' => $references, 'message_id' => $message_id, 'in_reply_to' => $in_reply_to, 'x_auto_bcc' => $x_auto_bcc,
10931094
'x_snoozed' => $x_snoozed, 'x_schedule' => $x_schedule, 'x_profile_id' => $x_profile_id, 'x_delivery' => $x_delivery);
10941095
$headers[$uid]['preview_msg'] = $flds['body'] != "content_body" ? $flds['body'] : "";
10951096

0 commit comments

Comments
 (0)