mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Disable preview images generation for remote users
This commit is contained in:
parent
d86e6a6949
commit
8c34b23c35
2 changed files with 26 additions and 1 deletions
|
@ -459,6 +459,9 @@ def generate_user_preview_image_task(user_id):
|
|||
|
||||
user = models.User.objects.get(id=user_id)
|
||||
|
||||
if not user.local:
|
||||
return
|
||||
|
||||
texts = {
|
||||
"text_one": user.display_name,
|
||||
"text_three": f"@{user.localname}@{settings.DOMAIN}",
|
||||
|
|
|
@ -46,6 +46,19 @@ class PreviewImages(TestCase):
|
|||
),
|
||||
)
|
||||
|
||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||
self.remote_user = models.User.objects.create_user(
|
||||
"rat",
|
||||
"rat@rat.com",
|
||||
"ratword",
|
||||
local=False,
|
||||
remote_id="https://example.com/users/rat",
|
||||
inbox="https://example.com/users/rat/inbox",
|
||||
outbox="https://example.com/users/rat/outbox",
|
||||
)
|
||||
|
||||
self.work = models.Work.objects.create(title="Test Work")
|
||||
self.edition = models.Edition.objects.create(
|
||||
title="Example Edition",
|
||||
|
@ -114,7 +127,7 @@ class PreviewImages(TestCase):
|
|||
self.local_user.refresh_from_db()
|
||||
|
||||
self.assertIsInstance(self.local_user.preview_image, ImageFieldFile)
|
||||
self.assertIsNotNone(self.local_user.preview_image)
|
||||
self.assertTrue(self.local_user.preview_image)
|
||||
self.assertEqual(
|
||||
self.local_user.preview_image.width, settings.PREVIEW_IMG_WIDTH
|
||||
)
|
||||
|
@ -122,6 +135,15 @@ class PreviewImages(TestCase):
|
|||
self.local_user.preview_image.height, settings.PREVIEW_IMG_HEIGHT
|
||||
)
|
||||
|
||||
def test_remote_user_preview(self, *args, **kwargs):
|
||||
"""a remote user doesn’t get a user preview"""
|
||||
generate_user_preview_image_task(self.remote_user.id)
|
||||
|
||||
self.remote_user.refresh_from_db()
|
||||
|
||||
self.assertFalse(self.remote_user.preview_image)
|
||||
|
||||
|
||||
def test_generate_user_preview_images_task(self, *args, **kwargs):
|
||||
"""test task's external calls"""
|
||||
with patch("bookwyrm.preview_images.generate_preview_image") as generate_mock:
|
||||
|
|
Loading…
Reference in a new issue