forked from mirrors/bookwyrm
Set thread id on parent status
This commit is contained in:
parent
7ff040470f
commit
0cd55147ee
2 changed files with 18 additions and 4 deletions
|
@ -76,6 +76,10 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
if not self.reply_parent:
|
||||
self.thread_id = self.id
|
||||
super().save(broadcast=False, update_fields=["thread_id"])
|
||||
|
||||
def delete(self, *args, **kwargs): # pylint: disable=unused-argument
|
||||
""" "delete" a status"""
|
||||
if hasattr(self, "boosted_status"):
|
||||
|
|
|
@ -14,6 +14,7 @@ from bookwyrm import activitypub, models, settings
|
|||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
# pylint: disable=line-too-long
|
||||
@patch("bookwyrm.models.Status.broadcast")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||
|
@ -58,16 +59,20 @@ class Status(TestCase):
|
|||
|
||||
def test_replies(self, *_):
|
||||
"""get a list of replies"""
|
||||
parent = models.Status.objects.create(content="hi", user=self.local_user)
|
||||
child = models.Status.objects.create(
|
||||
parent = models.Status(content="hi", user=self.local_user)
|
||||
parent.save(broadcast=False)
|
||||
child = models.Status(
|
||||
content="hello", reply_parent=parent, user=self.local_user
|
||||
)
|
||||
models.Review.objects.create(
|
||||
child.save(broadcast=False)
|
||||
sibling = models.Review(
|
||||
content="hey", reply_parent=parent, user=self.local_user, book=self.book
|
||||
)
|
||||
models.Status.objects.create(
|
||||
sibling.save(broadcast=False)
|
||||
grandchild = models.Status(
|
||||
content="hi hello", reply_parent=child, user=self.local_user
|
||||
)
|
||||
grandchild.save(broadcast=False)
|
||||
|
||||
replies = models.Status.replies(parent)
|
||||
self.assertEqual(replies.count(), 2)
|
||||
|
@ -75,6 +80,11 @@ class Status(TestCase):
|
|||
# should select subclasses
|
||||
self.assertIsInstance(replies.last(), models.Review)
|
||||
|
||||
self.assertEqual(parent.thread_id, parent.id)
|
||||
self.assertEqual(child.thread_id, parent.id)
|
||||
self.assertEqual(sibling.thread_id, parent.id)
|
||||
self.assertEqual(grandchild.thread_id, parent.id)
|
||||
|
||||
def test_status_type(self, *_):
|
||||
"""class name"""
|
||||
self.assertEqual(models.Status().status_type, "Note")
|
||||
|
|
Loading…
Reference in a new issue