Proper fix for deleting messages in the backend channel (#78)

* Actually fix deleting messages in the backend channel

* Always impersonate in backend channel

- Yeah turns out deleting impersonated messages still works with a bot token
- Partially reverts #74
This commit is contained in:
MMK21 2025-10-26 16:11:54 +00:00 committed by GitHub
parent b53e1c57fa
commit a10d0d4627
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View file

@ -6,6 +6,7 @@ from nephthys.utils.delete_thread import add_thread_to_delete_queue
from nephthys.utils.env import env
from nephthys.utils.logging import send_heartbeat
from nephthys.utils.permissions import can_resolve
from nephthys.utils.ticket_methods import delete_message
from nephthys.utils.ticket_methods import reply_to_ticket
from prisma.enums import TicketStatus
@ -84,6 +85,11 @@ async def resolve(
timestamp=ts,
)
await add_thread_to_delete_queue(
channel_id=env.slack_ticket_channel, thread_ts=tkt.ticketTs
)
if await env.workspace_admin_available():
await add_thread_to_delete_queue(
channel_id=env.slack_ticket_channel, thread_ts=tkt.ticketTs
)
else:
await delete_message(
channel_id=env.slack_ticket_channel, message_ts=tkt.ticketTs
)

View file

@ -115,8 +115,6 @@ async def on_message(event: Dict[str, Any], client: AsyncWebClient):
profile_pic = user_info["profile"].get("image_512", "")
display_name = user_info["profile"]["display_name"] or user_info["real_name"]
# If we don't have admin perms, don't take on the user's pfp and name, because that'd make it impossible to delete the message later
use_impersonation = await env.workspace_admin_available()
ticket_message = await client.chat_postMessage(
channel=env.slack_ticket_channel,
text=f"New message from <@{user}>: {text}",
@ -141,8 +139,8 @@ async def on_message(event: Dict[str, Any], client: AsyncWebClient):
],
},
],
username=display_name if use_impersonation else None,
icon_url=profile_pic if use_impersonation else None,
username=display_name,
icon_url=profile_pic,
unfurl_links=True,
unfurl_media=True,
)