Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion appwrite_lab/tools/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 11 additions & 3 deletions twilio-shim/main.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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):
Expand All @@ -45,6 +52,7 @@ async def send_sms(sid: str, request: Request):
"frm": from_,
"body": body,
"ts": datetime.utcnow().isoformat() + "Z",
"id": str(uuid4()),
}
)

Expand Down
Loading