import logging import httpx logger = logging.getLogger(__name__) API_V3_BASE = "https://api.clickup.com/api/v3" async def add_reaction( workspace_id: str, message_id: str, reaction: str, api_token: str, ) -> bool: url = f"{API_V3_BASE}/workspaces/{workspace_id}/chat/messages/{message_id}/reactions" headers = {"Authorization": api_token, "Content-Type": "application/json"} payload = {"reaction": reaction.lower()} async with httpx.AsyncClient(timeout=15.0) as client: try: resp = await client.post(url, json=payload, headers=headers) if resp.status_code == 201: return True logger.error("ClickUp add_reaction failed: status=%d", resp.status_code) return False except Exception as e: logger.exception("ClickUp add_reaction exception: %s", e) return False async def get_reactions( workspace_id: str, message_id: str, api_token: str, ) -> list[dict]: url = f"{API_V3_BASE}/workspaces/{workspace_id}/chat/messages/{message_id}/reactions" headers = {"Authorization": api_token} async with httpx.AsyncClient(timeout=15.0) as client: try: resp = await client.get(url, headers=headers) if resp.status_code == 200: data = resp.json() return data.get("reactions", []) return [] except Exception as e: logger.exception("ClickUp get_reactions exception: %s", e) return [] async def remove_reaction( workspace_id: str, message_id: str, reaction: str, api_token: str, ) -> bool: url = f"{API_V3_BASE}/workspaces/{workspace_id}/chat/messages/{message_id}/reactions/{reaction.lower()}" headers = {"Authorization": api_token} async with httpx.AsyncClient(timeout=15.0) as client: try: resp = await client.delete(url, headers=headers) return resp.status_code == 204 except Exception as e: logger.exception("ClickUp remove_reaction exception: %s", e) return False