From ec79b1008853c8ce39a2e55804c537e28f1fdfc0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 16 Jan 2021 12:48:04 -0800 Subject: [PATCH] Post status about goal --- bookwyrm/views/goal.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bookwyrm/views/goal.py b/bookwyrm/views/goal.py index fa919b76f..4404d008d 100644 --- a/bookwyrm/views/goal.py +++ b/bookwyrm/views/goal.py @@ -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', '/'))