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 '''
|
''' Handle user activity '''
|
||||||
|
from django.db import transaction
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
|
@ -19,16 +20,20 @@ def create_generated_note(user, content, mention_books=None, privacy='public'):
|
||||||
parser.feed(content)
|
parser.feed(content)
|
||||||
content = parser.get_output()
|
content = parser.get_output()
|
||||||
|
|
||||||
status = models.GeneratedNote.objects.create(
|
with transaction.atomic():
|
||||||
user=user,
|
# create but don't save
|
||||||
content=content,
|
status = models.GeneratedNote(
|
||||||
privacy=privacy
|
user=user,
|
||||||
)
|
content=content,
|
||||||
|
privacy=privacy
|
||||||
if mention_books:
|
)
|
||||||
for book in mention_books:
|
# we have to save it to set the related fields, but hold off on telling
|
||||||
status.mention_books.add(book)
|
# 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
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue