1
0
Fork 0

Boosts - handle url, store in database, send, notify.

This commit is contained in:
Adam Kelly 2020-03-30 15:13:32 +01:00
parent 84d7e7c394
commit 745ca7d4ff
11 changed files with 133 additions and 2 deletions

View file

@ -1,6 +1,6 @@
''' bring all the models into the app namespace '''
from .book import Connector, Book, Work, Edition, Author
from .shelf import Shelf, ShelfBook
from .status import Status, Review, Comment, Favorite, Tag, Notification
from .status import Status, Review, Comment, Favorite, Boost, Tag, Notification
from .user import User, UserFollows, UserFollowRequest, UserBlocks
from .user import FederatedServer

View file

@ -89,6 +89,21 @@ class Favorite(FedireadsModel):
unique_together = ('user', 'status')
class Boost(Status):
''' boost'ing a post '''
boosted_status = models.ForeignKey(
'Status',
on_delete=models.PROTECT,
related_name="boosters")
def save(self, *args, **kwargs):
self.status_type = 'Boost'
self.activity_type = 'Announce'
super().save(*args, **kwargs)
# This constraint can't work as it would cross tables.
# class Meta:
# unique_together = ('user', 'boosted_status')
class Tag(FedireadsModel):
''' freeform tags for books '''
user = models.ForeignKey('User', on_delete=models.PROTECT)
@ -107,7 +122,7 @@ class Tag(FedireadsModel):
NotificationType = models.TextChoices(
'NotificationType', 'FAVORITE REPLY TAG FOLLOW FOLLOW_REQUEST')
'NotificationType', 'FAVORITE REPLY TAG FOLLOW FOLLOW_REQUEST BOOST')
class Notification(FedireadsModel):
''' you've been tagged, liked, followed, etc '''