From 5898b5fe46403e0ce6113cfeaddcc96233c28709 Mon Sep 17 00:00:00 2001 From: syntaxsdev Date: Sun, 17 Aug 2025 16:37:09 -0400 Subject: [PATCH] feat: support for delete sms --- appwrite_lab/tools/sms.py | 7 ++++++- pyproject.toml | 2 +- twilio-shim/main.py | 14 +++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/appwrite_lab/tools/sms.py b/appwrite_lab/tools/sms.py index 6f21844..904ce3d 100644 --- a/appwrite_lab/tools/sms.py +++ b/appwrite_lab/tools/sms.py @@ -14,4 +14,9 @@ async def get_messages(self): async def clear_messages(self): async with AsyncClient(verify=False) as client: response = await client.post(f"{self.url}/clear") - return response.json().get("ok") \ No newline at end of file + return response.json().get("ok") + + async def delete_message(self, id: str): + async with AsyncClient(verify=False) as client: + response = await client.delete(f"{self.url}/inbox/{id}") + return response.json().get("ok") diff --git a/pyproject.toml b/pyproject.toml index 4e7c4e8..a4f178a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite-lab" -version = "0.1.3" +version = "0.1.4" description = "Zero-click Appwrite test environments." readme = "README.md" requires-python = ">=3.11" diff --git a/twilio-shim/main.py b/twilio-shim/main.py index 34bf0e2..791be06 100644 --- a/twilio-shim/main.py +++ b/twilio-shim/main.py @@ -1,14 +1,14 @@ from fastapi import FastAPI, Body, Form, Request from fastapi.responses import HTMLResponse, JSONResponse -from typing import List, Dict from datetime import datetime +from uuid import uuid4 app = FastAPI() -MESSAGES: List[Dict] = [] +MESSAGES: list[dict] = [] @app.post("/inbox") -async def inbox(payload: Dict = Body(...)): +async def inbox(payload: dict = Body(...)): payload["ts"] = datetime.utcnow().isoformat() + "Z" MESSAGES.append(payload) if len(MESSAGES) > 100: @@ -27,6 +27,13 @@ def clear_inbox(): return {"ok": True} +@app.delete("/inbox/{id}") +def delete_message(id: str): + global MESSAGES + MESSAGES = [m for m in MESSAGES if m.get("id") != id] + return {"ok": True} + + # Twilio-compatible endpoint @app.post("/2010-04-01/Accounts/{sid}/Messages.json") async def send_sms(sid: str, request: Request): @@ -45,6 +52,7 @@ async def send_sms(sid: str, request: Request): "frm": from_, "body": body, "ts": datetime.utcnow().isoformat() + "Z", + "id": str(uuid4()), } )