summaryrefslogtreecommitdiff
path: root/program/steps/mail/show.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-04-11 16:53:59 +0000
committeralecpl <alec@alec.pl>2008-04-11 16:53:59 +0000
commit6d2714b3b3660f8a4efbb9c53e00b76245c2bcc2 (patch)
treef5193b8a3130b02ffec6718a6848456e7a1a722b /program/steps/mail/show.inc
parentfe6b7ae748f1065a9f6ece6f0cc26594b6d208c3 (diff)
#1484972: optimization: mark as read in one action with preview, deleted redundant quota reads
Diffstat (limited to 'program/steps/mail/show.inc')
-rw-r--r--program/steps/mail/show.inc18
1 files changed, 13 insertions, 5 deletions
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 27d26603f..94e4c6105 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -53,8 +53,10 @@ if ($_GET['_uid'])
else if ($_SESSION['safe_messages'][$MESSAGE['UID']])
$MESSAGE['is_safe'] = 1;
+ $mbox_name = $IMAP->get_mailbox_name();
+
// calculate Etag for this request
- $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE));
+ $etag = md5($MESSAGE['UID'].$mbox_name.session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE));
// allow caching, unless remote images are present
if ((bool)$MESSAGE['is_safe'])
@@ -75,17 +77,23 @@ if ($_GET['_uid'])
else
$MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']);
-
// mark message as read
- if (!$MESSAGE['headers']->seen && $_action != 'preview')
- $IMAP->set_flag($MESSAGE['UID'], 'SEEN');
+ if (!$MESSAGE['headers']->seen)
+ {
+ $marked = $IMAP->set_flag($MESSAGE['UID'], 'SEEN');
+ if($_action == 'preview' && $marked != -1)
+ {
+ $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX'));
+ $OUTPUT->command('mark_as_read_from_preview', $MESSAGE['UID']);
+ }
+ }
// give message uid to the client
$OUTPUT->set_env('uid', $MESSAGE['UID']);
$OUTPUT->set_env('safemode', $MESSAGE['is_safe']);
// check for unset disposition notification
- if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $IMAP->get_mailbox_name() != $CONFIG['drafts_mbox'])
+ if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $mbox_name != $CONFIG['drafts_mbox'])
{
if (intval($CONFIG['mdn_requests']) === 1)
{