Post status about goal

This commit is contained in:
Mouse Reeve 2021-01-16 12:48:04 -08:00
parent f3f6592e72
commit ec79b10088

View file

@ -7,6 +7,8 @@ from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import forms, models
from bookwyrm.broadcast import broadcast
from bookwyrm.status import create_generated_note
from .helpers import get_user_from_username, object_visible_to_user
@ -58,4 +60,20 @@ class Goal(View):
return TemplateResponse(request, 'goal.html', data)
form.save()
if request.POST.get('post-status'):
# create status, if appropraite
status = create_generated_note(
request.user,
'set a goal to read %d books in %d' % (goal.goal, goal.year),
privacy=goal.privacy
)
broadcast(
request.user,
status.to_create_activity(request.user),
software='bookwyrm')
# re-format the activity for non-bookwyrm servers
remote_activity = status.to_create_activity(request.user, pure=True)
broadcast(request.user, remote_activity, software='other')
return redirect(request.headers.get('Referer', '/'))