forked from mirrors/bookwyrm
Don't save duplicate boosts
This commit is contained in:
parent
9148f36719
commit
b457446f2f
2 changed files with 10 additions and 4 deletions
|
@ -204,10 +204,8 @@ class ObjectMixin(ActivitypubMixin):
|
|||
created = created or not bool(self.id)
|
||||
# first off, we want to save normally no matter what
|
||||
super().save(*args, **kwargs)
|
||||
if (
|
||||
not broadcast
|
||||
or hasattr(self, "status_type")
|
||||
and self.status_type == "Announce"
|
||||
if not broadcast or (
|
||||
hasattr(self, "status_type") and self.status_type == "Announce"
|
||||
):
|
||||
return
|
||||
|
||||
|
|
|
@ -351,6 +351,14 @@ class Boost(ActivityMixin, Status):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
""" save and notify """
|
||||
# This constraint can't work as it would cross tables.
|
||||
# class Meta:
|
||||
# unique_together = ('user', 'boosted_status')
|
||||
if Boost.objects.filter(
|
||||
boosted_status=self.boosted_status, user=self.user
|
||||
).exists():
|
||||
return
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
if not self.boosted_status.user.local or self.boosted_status.user == self.user:
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue