Skip to content

Commit

Permalink
Provide basic notifications for sending progress, fixes #735
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Aug 8, 2015
1 parent 6d2a236 commit 6e443d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mailpile/plugins/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@ def command(self, emails=None):
# FIXME: Also fatal, when the SMTP server REJECTS the mail
except:
# We want to try that again!
message = _('Failed to send %s') % email
subject = email.get_msg_info(config.index.MSG_SUBJECT)
message = _('Failed to send message: %s') % subject
for ev in events:
ev.flags = Event.INCOMPLETE
ev.message = message
Expand Down Expand Up @@ -1032,14 +1033,27 @@ def command(self):
if not idx:
return self._error(_('The index is not ready yet'))

# Collect a list of messages from the outbox
messages = []
for tag in cfg.get_tags(type='outbox'):
search = ['in:%s' % tag._key]
for msg_idx_pos in idx.search(self.session, search,
order='flat-index').as_set():
messages.append('=%s' % b36(msg_idx_pos))

# Messages no longer in the outbox get their events canceled...
if cfg.event_log:
events = cfg.event_log.incomplete(source='.plugins.compose.Sendit')
for ev in events:
if ('mid' in ev.data and
('=%s' % ev.data['mid']) not in messages):
ev.flags = ev.COMPLETE
ev.message = _('Sending cancelled.')
cfg.event_log.log_event(ev)

# Send all the mail!
if messages:
self.args = tuple(messages)
self.args = tuple(set(messages))
return Sendit.command(self)
else:
return self._success(_('The outbox is empty'))
Expand Down
9 changes: 9 additions & 0 deletions mailpile/www/default/html/jsapi/global/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,12 @@ EventLog.subscribe('.*mail_source.*', function(ev) {
Mailpile.notification(ev);
}
});
EventLog.subscribe('.*compose.Sendit', function(ev) {
if (ev.data.delivered == ev.data.recipients) {
ev.icon = 'icon-outbox';
}
else if (ev.data.last_error) {
ev.icon = 'icon-signature-unknown';
}
Mailpile.notification(ev);
});

0 comments on commit 6e443d5

Please sign in to comment.