Fixes broadcasting created status that needs second save

This commit is contained in:
Mouse Reeve 2021-02-09 11:13:02 -08:00
parent 0a554b002d
commit e998ac28da
2 changed files with 4 additions and 4 deletions

View File

@ -164,14 +164,14 @@ class ActivitypubMixin:
class ObjectMixin(ActivitypubMixin): class ObjectMixin(ActivitypubMixin):
''' add this mixin for object models that are AP serializable ''' ''' add this mixin for object models that are AP serializable '''
def save(self, *args, **kwargs): def save(self, *args, created=None, **kwargs):
''' broadcast created/updated/deleted objects as appropriate ''' ''' broadcast created/updated/deleted objects as appropriate '''
broadcast = kwargs.get('broadcast', True) broadcast = kwargs.get('broadcast', True)
# this bonus kwarg woul cause an error in the base save method # this bonus kwarg woul cause an error in the base save method
if 'broadcast' in kwargs: if 'broadcast' in kwargs:
del kwargs['broadcast'] del kwargs['broadcast']
created = not bool(self.id) created = created or not bool(self.id)
# first off, we want to save normally no matter what # first off, we want to save normally no matter what
super().save(*args, **kwargs) super().save(*args, **kwargs)
if not broadcast: if not broadcast:

View File

@ -34,7 +34,7 @@ class CreateStatus(View):
if not status.sensitive and status.content_warning: if not status.sensitive and status.content_warning:
# the cw text field remains populated when you click "remove" # the cw text field remains populated when you click "remove"
status.content_warning = None status.content_warning = None
status.save() status.save(broadcast=False)
# inspect the text for user tags # inspect the text for user tags
content = status.content content = status.content
@ -82,7 +82,7 @@ class CreateStatus(View):
if hasattr(status, 'quote'): if hasattr(status, 'quote'):
status.quote = to_markdown(status.quote) status.quote = to_markdown(status.quote)
status.save() status.save(created=True)
return redirect(request.headers.get('Referer', '/')) return redirect(request.headers.get('Referer', '/'))