Unverified Commit f15673c6 authored by meskio's avatar meskio
Browse files

[feat] add delete key command to the cli

parent ff7c106e
......@@ -140,6 +140,8 @@ GENERAL COMMANDS:
help='List all known keys')
parser.add_argument('--export', action='store_true',
help='Export the given key')
parser.add_argument('--delete', action='store_true',
help='Delete the given key')
parser.add_argument('address', nargs='?',
help='email address of the key')
args = parser.parse_args(sys.argv[2:])
......@@ -353,6 +355,9 @@ def send_command(cli):
data += ['export']
cb = do_print_key
elif subargs.delete:
data += ['delete']
error('Use bitmask_cli keys --help to see available subcommands',
......@@ -171,6 +171,17 @@ class KeysCmd(SubCommand):
d.addCallback(service.do_export, address)
return d
def do_DELETE(self, service, *parts, **kw):
if len(parts) < 3:
return defer.fail("An email address is needed")
address = parts[2]
bonafide = kw['bonafide']
d = bonafide.do_get_active_user()
d.addCallback(service.do_delete, address)
return d
class CommandDispatcher(object):
......@@ -358,6 +358,13 @@ class KeymanagerService(HookableService):
d.addCallback(lambda key: dict(key))
return d
def do_delete(self, userid, address):
km = self._container.get_instance(userid)
key = yield km.get_key(address, fetch_remote=False)
class StandardMailService(service.MultiService, HookableService):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment