Skip to content

Commit

Permalink
Don't cache messages
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed Apr 24, 2024
1 parent 33eedca commit 7b04127
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions logviewer/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
MessagePayload,
)

cache = {"users": {}, "dm_channels": {}, "messages": {}}
cache = {"users": {}, "dm_channels": {}}


class LogEntry:
Expand Down Expand Up @@ -261,7 +261,6 @@ async def refresh_attachment_url(self, attachments: Attachment):
return attachments
user = cache["users"][self.author.id] if self.author.id in cache["users"] else None
dm_channel = cache["dm_channels"][self.author.id] if self.author.id in cache["dm_channels"] else None
discord_message = cache["messages"][self.id] if self.id in cache["messages"] else None
update_attachments, to_save = False, []
for i, attachment in enumerate(attachments):
if not attachment.is_attachment_expired:
Expand All @@ -273,9 +272,7 @@ async def refresh_attachment_url(self, attachments: Attachment):
dm_channel: DMChannel = user.dm_channel or await user.create_dm()
cache["dm_channels"][self.author.id] = dm_channel
try:
if not discord_message:
discord_message = await user.dm_channel.fetch_message(self.id)
cache["messages"][self.id] = discord_message
discord_message = await user.dm_channel.fetch_message(self.id)
attachment.url = discord_message.attachments[i].url
logger.debug(f"Refreshed Attachment#{i+1} for Message ID {self.id}")
if not update_attachments:
Expand Down

0 comments on commit 7b04127

Please sign in to comment.