Stop logging message contents in the database for privacy reasons. Please remove the 'content' column in the 'messages' table:
This commit is contained in:
parent
cae394b4e8
commit
ca662bd502
@ -4,6 +4,17 @@ from pluralkit.bot.commands import *
|
||||
logger = logging.getLogger("pluralkit.commands")
|
||||
|
||||
|
||||
async def get_message_contents(client: discord.Client, channel_id: int, message_id: int):
|
||||
channel = client.get_channel(str(channel_id))
|
||||
if channel:
|
||||
try:
|
||||
original_message = await client.get_message(channel, str(message_id))
|
||||
return original_message.content or None
|
||||
except (discord.errors.Forbidden, discord.errors.NotFound):
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
async def message_info(ctx: CommandContext):
|
||||
mid_str = ctx.pop_str(CommandError("You must pass a message ID.", help=help.message_lookup))
|
||||
|
||||
@ -43,8 +54,9 @@ async def message_info(ctx: CommandContext):
|
||||
|
||||
embed.add_field(name="Sent by", value=sender_name)
|
||||
|
||||
if message.content: # Content can be empty string if there's an attachment
|
||||
embed.add_field(name="Content", value=message.content, inline=False)
|
||||
message_content = await get_message_contents(ctx.client, message.channel, message.mid)
|
||||
if message_content:
|
||||
embed.description = message_content
|
||||
|
||||
embed.set_author(name=message.name, icon_url=message.avatar_url or discord.Embed.Empty)
|
||||
|
||||
|
@ -175,8 +175,7 @@ class Proxy:
|
||||
# Report webhook stats to Influx
|
||||
await self.stats.report_webhook(time.perf_counter() - time_before, True)
|
||||
|
||||
await db.add_message(conn, message["id"], message["channel_id"], member.id, original_message.author.id,
|
||||
text or "")
|
||||
await db.add_message(conn, message["id"], message["channel_id"], member.id, original_message.author.id)
|
||||
|
||||
try:
|
||||
await self.client.delete_message(original_message)
|
||||
|
@ -171,10 +171,10 @@ async def delete_webhook(conn, channel_id: str):
|
||||
await conn.execute("delete from webhooks where channel = $1", int(channel_id))
|
||||
|
||||
@db_wrap
|
||||
async def add_message(conn, message_id: str, channel_id: str, member_id: int, sender_id: str, content: str):
|
||||
async def add_message(conn, message_id: str, channel_id: str, member_id: int, sender_id: str):
|
||||
logger.debug("Adding new message (id={}, channel={}, member={}, sender={})".format(
|
||||
message_id, channel_id, member_id, sender_id))
|
||||
await conn.execute("insert into messages (mid, channel, member, sender, content) values ($1, $2, $3, $4, $5)", int(message_id), int(channel_id), member_id, int(sender_id), content)
|
||||
await conn.execute("insert into messages (mid, channel, member, sender) values ($1, $2, $3, $4)", int(message_id), int(channel_id), member_id, int(sender_id))
|
||||
|
||||
class ProxyMember(namedtuple("ProxyMember", ["id", "hid", "prefix", "suffix", "color", "name", "avatar_url", "tag", "system_name", "system_hid"])):
|
||||
id: int
|
||||
@ -202,11 +202,10 @@ async def get_members_by_account(conn, account_id: str) -> List[ProxyMember]:
|
||||
and members.system = systems.id""", int(account_id))
|
||||
return [ProxyMember(**row) for row in rows]
|
||||
|
||||
class MessageInfo(namedtuple("MemberInfo", ["mid", "channel", "member", "content", "sender", "name", "hid", "avatar_url", "system_name", "system_hid"])):
|
||||
class MessageInfo(namedtuple("MemberInfo", ["mid", "channel", "member", "sender", "name", "hid", "avatar_url", "system_name", "system_hid"])):
|
||||
mid: int
|
||||
channel: int
|
||||
member: int
|
||||
content: str
|
||||
sender: int
|
||||
name: str
|
||||
hid: str
|
||||
@ -221,7 +220,6 @@ class MessageInfo(namedtuple("MemberInfo", ["mid", "channel", "member", "content
|
||||
"member": self.hid,
|
||||
"system": self.system_hid,
|
||||
"message_sender": str(self.sender),
|
||||
"content": self.content,
|
||||
"timestamp": snowflake_time(self.mid).isoformat()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user