Пример #1
0
def api_set_settings() -> Response:
    request_data = request.get_json()

    accounts = request_data.get('accounts', [])

    try:
        validate_unique_accounts(accounts)
    except ValueError as e:
        abort(400, f'{e}')

    for account in accounts:
        # IMAP user/password accounts
        _extract_any_secret('account', 'password',
                            account.get('imap_connection'))
        _extract_any_secret('account', 'password',
                            account.get('smtp_connection'))
        # IMAP OAuth accounts
        _extract_any_secret('oauth-account', 'oauth_refresh_token',
                            account.get('imap_connection'))
        _extract_any_secret('oauth-account', 'oauth_refresh_token',
                            account.get('smtp_connection'))

    changed_keys = overwrite_settings(request_data)

    # If sync days changes we need to nuke the caches
    if 'system.sync_days' in changed_keys:
        bust_all_caches()  # nuke the on-disk caches

    reset_accounts()  # un-cache accounts + folders to pick up settings changes
    reload_main_window()

    return jsonify(saved=True)
Пример #2
0
def api_set_settings() -> Response:
    request_data = request.get_json()

    accounts = request_data.get('accounts', [])
    validate_unique_accounts(accounts)

    for account in accounts:
        _extract_password(account.get('imap_settings'))
        _extract_password(account.get('smtp_settings'))

    changed_keys = overwrite_settings(request_data)

    # If sync days changes we need to nuke the caches
    if 'system.sync_days' in changed_keys:
        bust_all_caches()  # nuke the on-disk caches

    reset_accounts()  # un-cache accounts + folders to pick up settings changes
    reload_main_window()

    return jsonify(saved=True)
Пример #3
0
def api_delete_caches() -> Response:
    bust_all_caches()
    reload_main_window()
    return jsonify(deleted=True)