diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-07-24 19:21:40 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-08-24 17:15:20 -0400 |
commit | 3f620e20f0b18246a26aa8e0ec4c3719719700ce (patch) | |
tree | 27e64a1e7be68045eca497cab63397c419206b9c /src/leap/bitmask/cli/mail.py | |
parent | 00a9de84771b27e62515ce6d878d182c8f053de5 (diff) |
[feat] add mail.add_msg API call
- Resolves: #8973
Diffstat (limited to 'src/leap/bitmask/cli/mail.py')
-rw-r--r-- | src/leap/bitmask/cli/mail.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/leap/bitmask/cli/mail.py b/src/leap/bitmask/cli/mail.py index b6d6cd16..933f72a9 100644 --- a/src/leap/bitmask/cli/mail.py +++ b/src/leap/bitmask/cli/mail.py @@ -35,6 +35,7 @@ SUBCOMMANDS: disable Stop service status Display status about service get_token Returns token for the mail service + add_msg Add a msg file to a mailbox '''.format(name=command.appname) @@ -74,6 +75,34 @@ SUBCOMMANDS: return self._send(command.default_dict_printer) + def add_msg(self, raw_args): + parser = argparse.ArgumentParser( + description='Bitmask email status', + prog='%s %s %s' % tuple(sys.argv[:3])) + parser.add_argument('-u', '--userid', default='', + help='Select the userid of the mail') + parser.add_argument('-m', '--mailbox', default='', + help='Select the mailbox to add the email') + parser.add_argument('file', nargs=1, + help='file where the mail is stored') + subargs = parser.parse_args(raw_args) + + if subargs.userid: + userid = subargs.userid + else: + userid = self.cfg.get('bonafide', 'active', default=None) + + mailbox = '' + if subargs.mailbox: + mailbox = subargs.mailbox + + with open(subargs.file[0], 'r') as msgfile: + rawmsg = msgfile.read() + + self.data += ['add_msg', userid, mailbox, rawmsg] + + return self._send(command.default_dict_printer) + def mixnet_status(self, raw_args): parser = argparse.ArgumentParser( description='Bitmask mixnet status', |