From fdfb7bb93eab14df28465271caae835f2d100206 Mon Sep 17 00:00:00 2001 From: David Quick Date: Fri, 3 Feb 2023 12:15:54 -0500 Subject: [PATCH] pin bleach dep to 4.1, disable mastodon version checks --- Pipfile | 2 +- brutaldon/views.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 66f743f..09e8b9c 100644 --- a/Pipfile +++ b/Pipfile @@ -5,7 +5,7 @@ name = "pypi" [packages] "beautifulsoup4" = "*" -bleach = "*" +bleach = "~=4.1" certifi = "*" chardet = "*" decorator = "*" diff --git a/brutaldon/views.py b/brutaldon/views.py index 4806633..971c520 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -92,6 +92,7 @@ def get_usercontext(request, feature_set="mainline"): session=get_session(client.api_base_id), ratelimit_method="throw", feature_set=feature_set, + version_check_mode='none', ) return user, mastodon else: @@ -105,6 +106,7 @@ def is_logged_in(request): def _notes_count(account, mastodon): if not mastodon: return "" + mastodon.version_check_mode = 'none' notes = mastodon.notifications(limit=40) if account.preferences.filter_notifications: notes = [ @@ -182,6 +184,7 @@ def user_search(request): def user_search_inner(request, query): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' results = mastodon.search(query) return render( request, @@ -208,6 +211,7 @@ def timeline( filter_context="home", ): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' data = mastodon.timeline(timeline, limit=40, max_id=max_id, min_id=min_id) form = PostForm( initial={"visibility": request.session["active_user"].source.privacy} @@ -257,6 +261,7 @@ def timeline( def get_filters(mastodon, context=None): try: + mastodon.version_check_mode = 'none' if context: return [ff for ff in mastodon.filters() if context in ff.context] else: @@ -341,6 +346,7 @@ def forget_account(request, account_name): def notes_count(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' count = _notes_count(account, mastodon) return render( request, @@ -372,6 +378,7 @@ def tag(request, tag): account, mastodon = get_usercontext(request) except NotLoggedInException: return redirect(login) + mastodon.version_check_mode = 'none' data = mastodon.timeline_hashtag(tag) notifications = _notes_count(account, mastodon) return render( @@ -438,6 +445,7 @@ def login(request): client_id=client.client_id, client_secret=client.client_secret, api_base_url=api_base_url, + version_check_mode='none', ) client.version = mastodon.instance().get("version") client.save() @@ -460,6 +468,7 @@ def oauth_callback(request): client_id=request.session["active_client_id"], client_secret=request.session["active_client_secret"], api_base_url=request.session["active_instance"], + version_check_mode="none", ) redirect_uri = request.build_absolute_uri(reverse("oauth_callback")) access_token = mastodon.log_in( @@ -467,6 +476,7 @@ def oauth_callback(request): ) request.session["access_token"] = access_token user = mastodon.account_verify_credentials() + try: account = Account.objects.get( username=user.username + "@" + request.session["active_instance_hostname"] @@ -615,6 +625,7 @@ def note(request, next=None, prev=None): account, mastodon = get_usercontext(request) except NotLoggedInException: return redirect(about) + mastodon.version_check_mode = 'none' try: last_seen = mastodon.notifications(limit=1)[0] except IndexError: @@ -740,6 +751,7 @@ def user(request, username, prev=None, next=None): except NotLoggedInException: return redirect(about) user_dict = None + mastodon.version_check_mode = 'none' # pleroma currently flops if the user's not already locally known # this is a BUG that they MUST FIX # but until then, we might have to fallback to a regular search, @@ -855,6 +867,7 @@ def status_post(account, request, mastodon, **kw): @br_login_required def toot(request, mention=None): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.method == "GET": if mention: if not mention.startswith("@"): @@ -960,6 +973,7 @@ def toot(request, mention=None): def redraft(request, id): if request.method == "GET": account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) toot_content = get_text(toot.content) # convert to plain text # fix up white space @@ -995,6 +1009,7 @@ def redraft(request, id): elif request.method == "POST": form = PostForm(request.POST, request.FILES) account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) if form.is_valid(): media_objects = [] @@ -1081,6 +1096,7 @@ def safe_get_attachment(toot, index): def reply(request, id): if request.method == "GET": account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' try: toot = mastodon.status(id) context = mastodon.status_context(id) @@ -1199,6 +1215,7 @@ def reply(request, id): @br_login_required def share(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.method == "GET": params = request.GET if request.method == "POST": @@ -1231,6 +1248,7 @@ def share(request): @br_login_required def fav(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) if request.method == "POST": if not request.POST.get("cancel", None): @@ -1270,6 +1288,7 @@ def fav(request, id): @br_login_required def boost(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) if request.method == "POST": if not request.POST.get("cancel", None): @@ -1309,6 +1328,7 @@ def boost(request, id): @br_login_required def delete(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) if request.method == "POST" or request.method == "DELETE": if toot.account.acct != request.session["active_user"].acct: @@ -1335,6 +1355,7 @@ def delete(request, id): @br_login_required def follow(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' try: user_dict = mastodon.account(id) relationship = mastodon.account_relationships(user_dict.id)[0] @@ -1381,6 +1402,7 @@ def follow(request, id): @br_login_required def block(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' try: user_dict = mastodon.account(id) relationship = mastodon.account_relationships(user_dict.id)[0] @@ -1419,6 +1441,7 @@ def block(request, id): @br_login_required def mute(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' try: user_dict = mastodon.account(id) relationship = mastodon.account_relationships(user_dict.id)[0] @@ -1456,6 +1479,7 @@ def mute(request, id): @br_login_required def search(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.GET.get("ic-request"): return render( request, @@ -1487,6 +1511,7 @@ def search_results(request): query = "" account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' results = mastodon.search(query) notifications = _notes_count(account, mastodon) return render( @@ -1523,6 +1548,7 @@ def about(request): @cache_page(60 * 30) def privacy(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if account: preferences = account.preferences else: @@ -1541,6 +1567,7 @@ def privacy(request): @br_login_required def emoji_reference(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' emojos = mastodon.custom_emojis() notifications = _notes_count(account, mastodon) return render( @@ -1558,6 +1585,7 @@ def emoji_reference(request): @br_login_required def list_filters(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' filters = mastodon.filters() return render( request, @@ -1569,6 +1597,7 @@ def list_filters(request): @br_login_required def create_filter(request): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.method == "POST": form = FilterForm(request.POST) if form.is_valid(): @@ -1609,6 +1638,7 @@ def create_filter(request): @br_login_required def delete_filter(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' filter = mastodon.filter(id) if request.method == "POST" or request.method == "DELETE": @@ -1633,6 +1663,7 @@ def delete_filter(request, id): @br_login_required def edit_filter(request, id): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' filter = mastodon.filter(id) contexts = [] @@ -1696,6 +1727,7 @@ def edit_filter(request, id): @br_login_required def follow_requests(request, id=None): account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.method == "GET": reqs = mastodon.follow_requests() return render( @@ -1716,6 +1748,7 @@ def follow_requests(request, id=None): @br_login_required def accounts(request, id=None): active_account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' if request.method == "GET": accounts = [x for x in request.session.get("accounts_dict").values()] return render( @@ -1758,6 +1791,7 @@ def vote(request, id): return redirect("thread", id) if request.method == "POST": account, mastodon = get_usercontext(request) + mastodon.version_check_mode = 'none' toot = mastodon.status(id) poll = toot.poll if not poll: