Remove follow suggestion on request

This commit is contained in:
Mouse Reeve 2021-10-04 13:14:32 -07:00
commit 15105bda4f
4 changed files with 31 additions and 0 deletions

View file

@ -44,6 +44,7 @@ class BookDataModel(ObjectMixin, BookWyrmModel):
bnf_id = fields.CharField( # Bibliothèque nationale de France bnf_id = fields.CharField( # Bibliothèque nationale de France
max_length=255, blank=True, null=True, deduplication_field=True max_length=255, blank=True, null=True, deduplication_field=True
) )
links = fields.ManyToManyField("Link")
search_vector = SearchVectorField(null=True) search_vector = SearchVectorField(null=True)
last_edited_by = fields.ForeignKey( last_edited_by = fields.ForeignKey(
@ -104,6 +105,7 @@ class Book(BookDataModel):
objects = InheritanceManager() objects = InheritanceManager()
field_tracker = FieldTracker(fields=["authors", "title", "subtitle", "cover"]) field_tracker = FieldTracker(fields=["authors", "title", "subtitle", "cover"])
file_links = fields.ManyToManyField("FileLink")
if ENABLE_THUMBNAIL_GENERATION: if ENABLE_THUMBNAIL_GENERATION:
cover_bw_book_xsmall_webp = ImageSpecField( cover_bw_book_xsmall_webp = ImageSpecField(

17
bookwyrm/models/link.py Normal file
View file

@ -0,0 +1,17 @@
""" outlink data """
from .activitypub_mixin import CollectionItemMixin
from .base_model import BookWyrmModel
from . import fields
class Link(CollectionItemMixin, BookWyrmModel):
"""a link to a website"""
url = fields.CharField(max_length=255)
name = fields.CharField(max_length=255)
class FileLink(Link):
"""a link to a file"""
filetype = fields.CharField(max_length=5)
filetype_description = fields.CharField(max_length=100)

View file

@ -148,6 +148,17 @@ def update_suggestions_on_follow(sender, instance, created, *args, **kwargs):
rerank_user_task.delay(instance.user_object.id, update_only=False) rerank_user_task.delay(instance.user_object.id, update_only=False)
@receiver(signals.post_save, sender=models.UserFollowRequest)
# pylint: disable=unused-argument
def update_suggestions_on_follow_request(sender, instance, created, *args, **kwargs):
"""remove a follow from the recs and update the ranks"""
if not created or not instance.user_object.discoverable:
return
if instance.user_subject.local:
remove_suggestion_task.delay(instance.user_subject.id, instance.user_object.id)
@receiver(signals.post_save, sender=models.UserBlocks) @receiver(signals.post_save, sender=models.UserBlocks)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def update_suggestions_on_block(sender, instance, *args, **kwargs): def update_suggestions_on_block(sender, instance, *args, **kwargs):

View file

@ -48,6 +48,7 @@ from .isbn import Isbn
from .landing import About, Home, Landing from .landing import About, Home, Landing
from .list import Lists, SavedLists, List, Curate, UserLists from .list import Lists, SavedLists, List, Curate, UserLists
from .list import save_list, unsave_list, delete_list from .list import save_list, unsave_list, delete_list
from .link import Link, FileLink
from .login import Login, Logout from .login import Login, Logout
from .notifications import Notifications from .notifications import Notifications
from .outbox import Outbox from .outbox import Outbox