From 4003aaaa124b1ffa77d07f7e2ae5d16e2dddacf1 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Wed, 1 Mar 2017 01:13:21 +0100 Subject: [feat] mail status will only work for a valid userid We used to return the system status if no userid is provided. We don't do it anymore, now is only userid based. - Resolves: #8785 --- src/leap/bitmask/cli/mail.py | 5 +---- src/leap/bitmask/core/dispatcher.py | 6 ++++-- src/leap/bitmask/core/mail_services.py | 10 +++++----- ui/app/lib/bitmask.js | 3 --- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/leap/bitmask/cli/mail.py b/src/leap/bitmask/cli/mail.py index 025804eb..fd44383b 100644 --- a/src/leap/bitmask/cli/mail.py +++ b/src/leap/bitmask/cli/mail.py @@ -50,15 +50,12 @@ SUBCOMMANDS: help='uid to check the status of') subargs = parser.parse_args(raw_args) - self.data.append('status') - uid = None if subargs.uid: uid = subargs.uid else: uid = self.cfg.get('bonafide', 'active', default=None) - if uid: - self.data.append(uid) + self.data += ['status', uid] return self._send(self._print_status) diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index f0c4e766..3e50b11f 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -252,9 +252,11 @@ class MailCmd(SubCommand): @register_method('dict') def do_STATUS(self, mail, *parts, **kw): - userid = None - if len(parts) > 2: + try: userid = parts[2] + except IndexError: + raise DispatchError( + 'wrong number of arguments: expected 1, got none') d = mail.do_status(userid) return d diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 4e67ac45..92712019 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -571,16 +571,16 @@ class StandardMailService(service.MultiService, HookableService): # commands @defer.inlineCallbacks - def do_status(self, userid=None): + def do_status(self, userid): smtp = self.getServiceNamed('smtp') imap = self.getServiceNamed('imap') + incoming = self.getServiceNamed('incoming_mail') + incoming_status = yield incoming.status(userid) childrenStatus = { 'smtp': smtp.status(), - 'imap': imap.status() + 'imap': imap.status(), + 'incoming': incoming_status } - if userid is not None: - incoming = self.getServiceNamed('incoming_mail') - childrenStatus['incoming'] = yield incoming.status(userid) def key(service): status = childrenStatus[service] diff --git a/ui/app/lib/bitmask.js b/ui/app/lib/bitmask.js index 0a628ee3..79f4b916 100644 --- a/ui/app/lib/bitmask.js +++ b/ui/app/lib/bitmask.js @@ -213,9 +213,6 @@ var bitmask = function(){ * @return {Promise} User readable status */ status: function(uid) { - if (typeof uid !== 'string') { - uid = null - } return call(['mail', 'status', uid]); }, -- cgit v1.2.3