Fix redacted media events keeping their thumbnails

This commit is contained in:
miruka 2020-09-04 14:47:47 -04:00
parent 65a1324eb0
commit ebfc3d3ee2
2 changed files with 22 additions and 5 deletions

View File

@ -43,7 +43,8 @@ from .errors import (
from .html_markdown import HTML_PROCESSOR as HTML
from .media_cache import Media, Thumbnail
from .models.items import (
ZERO_DATE, Account, Event, Member, Room, Upload, UploadStatus,
ZERO_DATE, Account, Event, Member, Room, TypeSpecifier, Upload,
UploadStatus,
)
from .models.model_store import ModelStore
from .nio_callbacks import NioCallbacks
@ -1337,11 +1338,20 @@ class MatrixClient(nio.AsyncClient):
event.is_local_echo = True
event.content = await self.get_redacted_event_content(
event.event_type, self.user_id, event.sender_id, reason,
)
event.set_fields(
content = await self.get_redacted_event_content(
event.event_type, self.user_id, event.sender_id,reason,
),
event.event_type = nio.RedactedEvent
event_type = nio.RedactedEvent,
mentions = [],
type_specifier = TypeSpecifier.Unset,
media_url = "",
media_http_url = "",
media_title = "",
media_local_path = "",
thumbnail_url = "",
)
await self.pause_while_offline()
return await asyncio.gather(*tasks)

View File

@ -284,6 +284,13 @@ class NioCallbacks:
type(ev), ev.redacter, ev.sender, ev.reason,
),
mentions = [],
type_specifier = TypeSpecifier.Unset,
media_url = "",
media_http_url = "",
media_title = "",
media_local_path = "",
thumbnail_url = "",
redacter_id = ev.redacter or "",
redacter_name = redacter_name,
override_fetch_profile = True,