forked from mirrors/bookwyrm
Fixes broadcasting on generated notes
This commit is contained in:
parent
222dc118af
commit
88b2504402
1 changed files with 14 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
''' Handle user activity '''
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
|
||||
from bookwyrm import models
|
||||
|
@ -19,16 +20,20 @@ def create_generated_note(user, content, mention_books=None, privacy='public'):
|
|||
parser.feed(content)
|
||||
content = parser.get_output()
|
||||
|
||||
status = models.GeneratedNote.objects.create(
|
||||
user=user,
|
||||
content=content,
|
||||
privacy=privacy
|
||||
)
|
||||
|
||||
if mention_books:
|
||||
for book in mention_books:
|
||||
status.mention_books.add(book)
|
||||
with transaction.atomic():
|
||||
# create but don't save
|
||||
status = models.GeneratedNote(
|
||||
user=user,
|
||||
content=content,
|
||||
privacy=privacy
|
||||
)
|
||||
# we have to save it to set the related fields, but hold off on telling
|
||||
# folks about it because it is not ready
|
||||
status.save(broadcast=False)
|
||||
|
||||
if mention_books:
|
||||
status.mention_books.set(mention_books)
|
||||
status.save(created=True)
|
||||
return status
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue