mirror of
https://github.com/jfmcbrayer/brutaldon
synced 2025-01-05 11:56:41 +01:00
Use a simpler check for whether content_type argument can be used to post
This commit is contained in:
parent
2903a5ea6e
commit
f0843488d1
@ -13,16 +13,11 @@ from urllib import parse
|
|||||||
from pdb import set_trace
|
from pdb import set_trace
|
||||||
from inscriptis import get_text
|
from inscriptis import get_text
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import inspect
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
class NotLoggedInException(Exception):
|
class NotLoggedInException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post_has_content_type():
|
|
||||||
sig = inspect.signature(Mastodon.status_post)
|
|
||||||
return 'content_type' in sig.parameters.keys()
|
|
||||||
|
|
||||||
def get_usercontext(request):
|
def get_usercontext(request):
|
||||||
if is_logged_in(request):
|
if is_logged_in(request):
|
||||||
try:
|
try:
|
||||||
@ -491,13 +486,13 @@ def toot(request, mention=None):
|
|||||||
if form.cleaned_data['visibility'] == '':
|
if form.cleaned_data['visibility'] == '':
|
||||||
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
||||||
try:
|
try:
|
||||||
if post_has_content_type():
|
try:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
media_ids=media_objects,
|
media_ids=media_objects,
|
||||||
content_type='text/markdown')
|
content_type='text/markdown')
|
||||||
else:
|
except TypeError:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
@ -555,14 +550,14 @@ def redraft(request, id):
|
|||||||
if form.cleaned_data['visibility'] == '':
|
if form.cleaned_data['visibility'] == '':
|
||||||
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
||||||
try:
|
try:
|
||||||
if post_has_content_type():
|
try:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
media_ids=media_objects,
|
media_ids=media_objects,
|
||||||
in_reply_to_id=toot.in_reply_to_id,
|
in_reply_to_id=toot.in_reply_to_id,
|
||||||
content_type='text/markdown')
|
content_type='text/markdown')
|
||||||
else:
|
except TypeError:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
@ -637,14 +632,14 @@ def reply(request, id):
|
|||||||
+str(index),
|
+str(index),
|
||||||
None)))
|
None)))
|
||||||
try:
|
try:
|
||||||
if post_has_content_type():
|
try:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
media_ids=media_objects,
|
media_ids=media_objects,
|
||||||
in_reply_to_id=id,
|
in_reply_to_id=id,
|
||||||
content_type="text/markdown")
|
content_type="text/markdown")
|
||||||
else:
|
except TypeError:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
|
Loading…
Reference in New Issue
Block a user