feat: fraud and shipcertqueue macros

This commit is contained in:
Oliver Potter 2025-07-29 18:43:44 +00:00 committed by transcental
parent 3649ac9371
commit ecad7cbf0a
3 changed files with 65 additions and 1 deletions

View file

@ -4,13 +4,15 @@ from nephthys.macros.faq import FAQ
from nephthys.macros.hello_world import HelloWorld
from nephthys.macros.identity import Identity
from nephthys.macros.resolve import Resolve
from nephthys.macros.fraud import Fraud
from nephthys.macros.shipcertqueue import ShipCertQueue
from nephthys.utils.env import env
from nephthys.utils.logging import send_heartbeat
from prisma.models import Ticket
from prisma.models import User
macros = [Resolve, HelloWorld, FAQ, Identity]
macros = [Resolve, HelloWorld, FAQ, Identity, Fraud, ShipCertQueue]
async def run_macro(

31
nephthys/macros/fraud.py Normal file
View file

@ -0,0 +1,31 @@
from nephthys.actions.resolve import resolve
from nephthys.macros.types import Macro
from nephthys.utils.env import env
class Fraud(Macro):
name = "fraud"
async def run(self, ticket, helper, **kwargs):
"""
A simple macro telling people to use Fraudpheus
"""
sender = await env.db.user.find_first(where={"id": ticket.openedById})
if not sender:
return
user_info = await env.slack_client.users_info(user=sender.slackId)
name = (
user_info["user"]["profile"].get("display_name")
or user_info["user"]["profile"].get("real_name")
or user_info["user"]["name"]
)
await env.slack_client.chat_postMessage(
text=f"Hiya {name}! Would you mind directing any fraud related queries to <@U091HC53CE8>? :rac_cute:\n\nIt'll keep your case confidential and make it easier for the fraud team to keep track of!",
channel=env.slack_help_channel,
thread_ts=ticket.msgTs,
)
await resolve(
ts=ticket.msgTs,
resolver=helper.slackId,
client=env.slack_client,
)

View file

@ -0,0 +1,31 @@
from nephthys.actions.resolve import resolve
from nephthys.macros.types import Macro
from nephthys.utils.env import env
class ShipCertQueue(Macro):
name = "shipcertqueue"
async def run(self, ticket, helper, **kwargs):
"""
A simple macro telling people about the ship certification backlog
"""
sender = await env.db.user.find_first(where={"id": ticket.openedById})
if not sender:
return
user_info = await env.slack_client.users_info(user=sender.slackId)
name = (
user_info["user"]["profile"].get("display_name")
or user_info["user"]["profile"].get("real_name")
or user_info["user"]["name"]
)
await env.slack_client.chat_postMessage(
text=f"Hi {name}! Unfortunately, there is a backlog of projects awaiting ship certification; please be patient. \n\n *pssst... voting more will move your project further towards the front of the queue.*",
channel=env.slack_help_channel,
thread_ts=ticket.msgTs,
)
await resolve(
ts=ticket.msgTs,
resolver=helper.slackId,
client=env.slack_client,
)