limit public toot to local_only

This commit is contained in:
doubaniux 2020-05-08 12:26:41 +08:00
parent 32860bbe82
commit b480033935
2 changed files with 4 additions and 3 deletions

View file

@ -227,7 +227,7 @@ def create_update_mark(request):
words = BookMarkStatusTranslator(int(form.cleaned_data['status'])) +\ words = BookMarkStatusTranslator(int(form.cleaned_data['status'])) +\
f"{book.title}" + rating_to_emoji(form.cleaned_data['rating']) f"{book.title}" + rating_to_emoji(form.cleaned_data['rating'])
content = words + '\n' + url + '\n' + form.cleaned_data['text'] content = words + '\n' + url + '\n' + form.cleaned_data['text']
post_toot(content, visibility, request.session['oauth_token']) post_toot(content, visibility, request.session['oauth_token'], local_only=True)
else: else:
return HttpResponseBadRequest() return HttpResponseBadRequest()

View file

@ -66,7 +66,7 @@ def check_visibility(user_owned_entity, token, visitor):
return True return True
def post_toot(content, visibility, token): def post_toot(content, visibility, token, local_only=False):
url = 'https://' + MASTODON_DOMAIN_NAME + API_PUBLISH_TOOT url = 'https://' + MASTODON_DOMAIN_NAME + API_PUBLISH_TOOT
headers = { headers = {
'Authorization': f'Bearer {token}', 'Authorization': f'Bearer {token}',
@ -74,7 +74,8 @@ def post_toot(content, visibility, token):
} }
payload = { payload = {
'status': content, 'status': content,
'visibility': visibility 'visibility': visibility,
'local_only': local_only,
} }
response = post(url, headers=headers, data=payload) response = post(url, headers=headers, data=payload)
return response return response