from __future__ import annotations from yuxi.channels.models import DeliveryResult from yuxi.utils.logging_config import logger async def send_pairing_notification( client, user_id: str, pairing_code: str, *, expires_in_minutes: int = 10, ) -> DeliveryResult: try: text = ( f"*Security Pairing Request*\n\n" f"Your pairing code is: `{pairing_code}`\n" f"This code expires in {expires_in_minutes} minutes.\n\n" f"Use `/yuxi pair {pairing_code}` to complete pairing." ) result = await client.chat_postMessage( channel=user_id, text=text, mrkdwn=True, ) ok = result.get("ok", False) return DeliveryResult( success=ok, message_id=result.get("ts"), error=result.get("error") if not ok else None, ) except Exception as e: logger.error(f"Failed to send pairing notification: {e}") return DeliveryResult(success=False, error=str(e)) async def send_pairing_approved_notification( client, user_id: str, ) -> DeliveryResult: try: text = "✅ *Pairing Approved!*\n\nYou are now authorized to interact with the bot." result = await client.chat_postMessage( channel=user_id, text=text, mrkdwn=True, ) ok = result.get("ok", False) return DeliveryResult( success=ok, message_id=result.get("ts"), error=result.get("error") if not ok else None, ) except Exception as e: logger.error(f"Failed to send pairing approval notification: {e}") return DeliveryResult(success=False, error=str(e))