def remove_proxy(author_id: Union[AccountId, str], account_id: Union[AccountId,
                                                                     str],
                 proxy_id: Union[AccountId, str], server: Server):
    """Remove proxy 'proxy' from account with authorization from author."""
    author = _get_account(author_id, server)
    account = _get_account(account_id, server)
    proxy = _get_account(proxy_id, server)
    _assert_authorized(author, None)

    server.remove_proxy(author_id, proxy, account)
Esempio n. 2
0
def process_admin_remove_proxy(author: AccountId, message: str, server: Server,
                               **kwargs):
    """Processes an admin proxy addition command."""
    assert_authorized(author, server, Authorization.ADMIN)
    parsed = parse_admin_add_proxy_command(message)
    if parsed is None:
        raise CommandException(
            'Incorrect formatting. Expected format `admin-remove-proxy ACCOUNT_NAME PROXIED_ACCOUNT_NAME`.'
        )

    account_name, proxied_account_name = parsed
    account = assert_is_account(account_name, server)
    proxied_account = assert_is_account(proxied_account_name, server)
    server.remove_proxy(author, account, proxied_account)
    return 'Account %s can no longer act as a proxy for account %s.' % (
        account_name, proxied_account_name)