mirror of https://github.com/zulip/zulip.git
thumbnail: Remove type: ignore.
(An alternate solution is message_classes: list[type[Message | ArchivedMessage]].) Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
912c1b5984
commit
1b4e02c5d0
|
@ -19,7 +19,7 @@ from zerver.lib.thumbnail import (
|
|||
rewrite_thumbnailed_images,
|
||||
)
|
||||
from zerver.lib.upload import save_attachment_contents, upload_backend
|
||||
from zerver.models import AbstractMessage, ArchivedMessage, ImageAttachment, Message
|
||||
from zerver.models import ArchivedMessage, ImageAttachment, Message
|
||||
from zerver.worker.base import QueueProcessingWorker, assign_queue
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -158,12 +158,9 @@ def ensure_thumbnails(image_attachment: ImageAttachment) -> int:
|
|||
def update_message_rendered_content(
|
||||
realm_id: int, path_id: str, image_data: MarkdownImageMetadata | None
|
||||
) -> None:
|
||||
message_classes: list[type[AbstractMessage]] = [Message, ArchivedMessage]
|
||||
for message_class in message_classes:
|
||||
for message_class in (Message, ArchivedMessage):
|
||||
messages_with_image = (
|
||||
message_class._default_manager.filter( # type: ignore[misc] # Both Message and ArchivedMessage have an "attachment" many-to-many, but this is not guaranteed by the type system
|
||||
realm_id=realm_id, attachment__path_id=path_id
|
||||
)
|
||||
message_class.objects.filter(realm_id=realm_id, attachment__path_id=path_id)
|
||||
.select_for_update(of=("self",))
|
||||
.order_by("id")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue