mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-11-02 16:37:19 -04:00
Merge branch 'fix/support-gts' into 'main'
pin bleach dep to 4.1, disable mastodon version checks See merge request brutaldon/brutaldon!11
This commit is contained in:
commit
9768c08466
2
Pipfile
2
Pipfile
@ -5,7 +5,7 @@ name = "pypi"
|
|||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
"beautifulsoup4" = "*"
|
"beautifulsoup4" = "*"
|
||||||
bleach = "*"
|
bleach = "~=4.1"
|
||||||
certifi = "*"
|
certifi = "*"
|
||||||
chardet = "*"
|
chardet = "*"
|
||||||
decorator = "*"
|
decorator = "*"
|
||||||
|
@ -92,6 +92,7 @@ def get_usercontext(request, feature_set="mainline"):
|
|||||||
session=get_session(client.api_base_id),
|
session=get_session(client.api_base_id),
|
||||||
ratelimit_method="throw",
|
ratelimit_method="throw",
|
||||||
feature_set=feature_set,
|
feature_set=feature_set,
|
||||||
|
version_check_mode='none',
|
||||||
)
|
)
|
||||||
return user, mastodon
|
return user, mastodon
|
||||||
else:
|
else:
|
||||||
@ -105,6 +106,7 @@ def is_logged_in(request):
|
|||||||
def _notes_count(account, mastodon):
|
def _notes_count(account, mastodon):
|
||||||
if not mastodon:
|
if not mastodon:
|
||||||
return ""
|
return ""
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
notes = mastodon.notifications(limit=40)
|
notes = mastodon.notifications(limit=40)
|
||||||
if account.preferences.filter_notifications:
|
if account.preferences.filter_notifications:
|
||||||
notes = [
|
notes = [
|
||||||
@ -182,6 +184,7 @@ def user_search(request):
|
|||||||
|
|
||||||
def user_search_inner(request, query):
|
def user_search_inner(request, query):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
results = mastodon.search(query)
|
results = mastodon.search(query)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@ -208,6 +211,7 @@ def timeline(
|
|||||||
filter_context="home",
|
filter_context="home",
|
||||||
):
|
):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
data = mastodon.timeline(timeline, limit=40, max_id=max_id, min_id=min_id)
|
data = mastodon.timeline(timeline, limit=40, max_id=max_id, min_id=min_id)
|
||||||
form = PostForm(
|
form = PostForm(
|
||||||
initial={"visibility": request.session["active_user"].source.privacy}
|
initial={"visibility": request.session["active_user"].source.privacy}
|
||||||
@ -257,6 +261,7 @@ def timeline(
|
|||||||
|
|
||||||
def get_filters(mastodon, context=None):
|
def get_filters(mastodon, context=None):
|
||||||
try:
|
try:
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if context:
|
if context:
|
||||||
return [ff for ff in mastodon.filters() if context in ff.context]
|
return [ff for ff in mastodon.filters() if context in ff.context]
|
||||||
else:
|
else:
|
||||||
@ -341,6 +346,7 @@ def forget_account(request, account_name):
|
|||||||
|
|
||||||
def notes_count(request):
|
def notes_count(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
count = _notes_count(account, mastodon)
|
count = _notes_count(account, mastodon)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@ -372,6 +378,7 @@ def tag(request, tag):
|
|||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(login)
|
return redirect(login)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
data = mastodon.timeline_hashtag(tag)
|
data = mastodon.timeline_hashtag(tag)
|
||||||
notifications = _notes_count(account, mastodon)
|
notifications = _notes_count(account, mastodon)
|
||||||
return render(
|
return render(
|
||||||
@ -438,6 +445,7 @@ def login(request):
|
|||||||
client_id=client.client_id,
|
client_id=client.client_id,
|
||||||
client_secret=client.client_secret,
|
client_secret=client.client_secret,
|
||||||
api_base_url=api_base_url,
|
api_base_url=api_base_url,
|
||||||
|
version_check_mode='none',
|
||||||
)
|
)
|
||||||
client.version = mastodon.instance().get("version")
|
client.version = mastodon.instance().get("version")
|
||||||
client.save()
|
client.save()
|
||||||
@ -460,6 +468,7 @@ def oauth_callback(request):
|
|||||||
client_id=request.session["active_client_id"],
|
client_id=request.session["active_client_id"],
|
||||||
client_secret=request.session["active_client_secret"],
|
client_secret=request.session["active_client_secret"],
|
||||||
api_base_url=request.session["active_instance"],
|
api_base_url=request.session["active_instance"],
|
||||||
|
version_check_mode="none",
|
||||||
)
|
)
|
||||||
redirect_uri = request.build_absolute_uri(reverse("oauth_callback"))
|
redirect_uri = request.build_absolute_uri(reverse("oauth_callback"))
|
||||||
access_token = mastodon.log_in(
|
access_token = mastodon.log_in(
|
||||||
@ -467,6 +476,7 @@ def oauth_callback(request):
|
|||||||
)
|
)
|
||||||
request.session["access_token"] = access_token
|
request.session["access_token"] = access_token
|
||||||
user = mastodon.account_verify_credentials()
|
user = mastodon.account_verify_credentials()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
account = Account.objects.get(
|
account = Account.objects.get(
|
||||||
username=user.username + "@" + request.session["active_instance_hostname"]
|
username=user.username + "@" + request.session["active_instance_hostname"]
|
||||||
@ -615,6 +625,7 @@ def note(request, next=None, prev=None):
|
|||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(about)
|
return redirect(about)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
try:
|
try:
|
||||||
last_seen = mastodon.notifications(limit=1)[0]
|
last_seen = mastodon.notifications(limit=1)[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -740,6 +751,7 @@ def user(request, username, prev=None, next=None):
|
|||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(about)
|
return redirect(about)
|
||||||
user_dict = None
|
user_dict = None
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
# pleroma currently flops if the user's not already locally known
|
# pleroma currently flops if the user's not already locally known
|
||||||
# this is a BUG that they MUST FIX
|
# this is a BUG that they MUST FIX
|
||||||
# but until then, we might have to fallback to a regular search,
|
# 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
|
@br_login_required
|
||||||
def toot(request, mention=None):
|
def toot(request, mention=None):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
if mention:
|
if mention:
|
||||||
if not mention.startswith("@"):
|
if not mention.startswith("@"):
|
||||||
@ -960,6 +973,7 @@ def toot(request, mention=None):
|
|||||||
def redraft(request, id):
|
def redraft(request, id):
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
toot_content = get_text(toot.content) # convert to plain text
|
toot_content = get_text(toot.content) # convert to plain text
|
||||||
# fix up white space
|
# fix up white space
|
||||||
@ -995,6 +1009,7 @@ def redraft(request, id):
|
|||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
form = PostForm(request.POST, request.FILES)
|
form = PostForm(request.POST, request.FILES)
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
media_objects = []
|
media_objects = []
|
||||||
@ -1081,6 +1096,7 @@ def safe_get_attachment(toot, index):
|
|||||||
def reply(request, id):
|
def reply(request, id):
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
try:
|
try:
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
context = mastodon.status_context(id)
|
context = mastodon.status_context(id)
|
||||||
@ -1199,6 +1215,7 @@ def reply(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def share(request):
|
def share(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
params = request.GET
|
params = request.GET
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
@ -1231,6 +1248,7 @@ def share(request):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def fav(request, id):
|
def fav(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if not request.POST.get("cancel", None):
|
if not request.POST.get("cancel", None):
|
||||||
@ -1270,6 +1288,7 @@ def fav(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def boost(request, id):
|
def boost(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if not request.POST.get("cancel", None):
|
if not request.POST.get("cancel", None):
|
||||||
@ -1309,6 +1328,7 @@ def boost(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def delete(request, id):
|
def delete(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == "POST" or request.method == "DELETE":
|
if request.method == "POST" or request.method == "DELETE":
|
||||||
if toot.account.acct != request.session["active_user"].acct:
|
if toot.account.acct != request.session["active_user"].acct:
|
||||||
@ -1335,6 +1355,7 @@ def delete(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def follow(request, id):
|
def follow(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
@ -1381,6 +1402,7 @@ def follow(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def block(request, id):
|
def block(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
@ -1419,6 +1441,7 @@ def block(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def mute(request, id):
|
def mute(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
@ -1456,6 +1479,7 @@ def mute(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def search(request):
|
def search(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.GET.get("ic-request"):
|
if request.GET.get("ic-request"):
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@ -1487,6 +1511,7 @@ def search_results(request):
|
|||||||
query = ""
|
query = ""
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
results = mastodon.search(query)
|
results = mastodon.search(query)
|
||||||
notifications = _notes_count(account, mastodon)
|
notifications = _notes_count(account, mastodon)
|
||||||
return render(
|
return render(
|
||||||
@ -1523,6 +1548,7 @@ def about(request):
|
|||||||
@cache_page(60 * 30)
|
@cache_page(60 * 30)
|
||||||
def privacy(request):
|
def privacy(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if account:
|
if account:
|
||||||
preferences = account.preferences
|
preferences = account.preferences
|
||||||
else:
|
else:
|
||||||
@ -1541,6 +1567,7 @@ def privacy(request):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def emoji_reference(request):
|
def emoji_reference(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
emojos = mastodon.custom_emojis()
|
emojos = mastodon.custom_emojis()
|
||||||
notifications = _notes_count(account, mastodon)
|
notifications = _notes_count(account, mastodon)
|
||||||
return render(
|
return render(
|
||||||
@ -1558,6 +1585,7 @@ def emoji_reference(request):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def list_filters(request):
|
def list_filters(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
filters = mastodon.filters()
|
filters = mastodon.filters()
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@ -1569,6 +1597,7 @@ def list_filters(request):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def create_filter(request):
|
def create_filter(request):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = FilterForm(request.POST)
|
form = FilterForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
@ -1609,6 +1638,7 @@ def create_filter(request):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def delete_filter(request, id):
|
def delete_filter(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
filter = mastodon.filter(id)
|
filter = mastodon.filter(id)
|
||||||
|
|
||||||
if request.method == "POST" or request.method == "DELETE":
|
if request.method == "POST" or request.method == "DELETE":
|
||||||
@ -1633,6 +1663,7 @@ def delete_filter(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def edit_filter(request, id):
|
def edit_filter(request, id):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
filter = mastodon.filter(id)
|
filter = mastodon.filter(id)
|
||||||
|
|
||||||
contexts = []
|
contexts = []
|
||||||
@ -1696,6 +1727,7 @@ def edit_filter(request, id):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def follow_requests(request, id=None):
|
def follow_requests(request, id=None):
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
reqs = mastodon.follow_requests()
|
reqs = mastodon.follow_requests()
|
||||||
return render(
|
return render(
|
||||||
@ -1716,6 +1748,7 @@ def follow_requests(request, id=None):
|
|||||||
@br_login_required
|
@br_login_required
|
||||||
def accounts(request, id=None):
|
def accounts(request, id=None):
|
||||||
active_account, mastodon = get_usercontext(request)
|
active_account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
accounts = [x for x in request.session.get("accounts_dict").values()]
|
accounts = [x for x in request.session.get("accounts_dict").values()]
|
||||||
return render(
|
return render(
|
||||||
@ -1758,6 +1791,7 @@ def vote(request, id):
|
|||||||
return redirect("thread", id)
|
return redirect("thread", id)
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
mastodon.version_check_mode = 'none'
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
poll = toot.poll
|
poll = toot.poll
|
||||||
if not poll:
|
if not poll:
|
||||||
|
Loading…
Reference in New Issue
Block a user