File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,9 @@ async def get_messages(self):
14
14
async def clear_messages (self ):
15
15
async with AsyncClient (verify = False ) as client :
16
16
response = await client .post (f"{ self .url } /clear" )
17
- return response .json ().get ("ok" )
17
+ return response .json ().get ("ok" )
18
+
19
+ async def delete_message (self , id : str ):
20
+ async with AsyncClient (verify = False ) as client :
21
+ response = await client .delete (f"{ self .url } /inbox/{ id } " )
22
+ return response .json ().get ("ok" )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
5
5
[project ]
6
6
name = " appwrite-lab"
7
- version = " 0.1.3 "
7
+ version = " 0.1.4 "
8
8
description = " Zero-click Appwrite test environments."
9
9
readme = " README.md"
10
10
requires-python = " >=3.11"
Original file line number Diff line number Diff line change 1
1
from fastapi import FastAPI , Body , Form , Request
2
2
from fastapi .responses import HTMLResponse , JSONResponse
3
- from typing import List , Dict
4
3
from datetime import datetime
4
+ from uuid import uuid4
5
5
6
6
app = FastAPI ()
7
- MESSAGES : List [ Dict ] = []
7
+ MESSAGES : list [ dict ] = []
8
8
9
9
10
10
@app .post ("/inbox" )
11
- async def inbox (payload : Dict = Body (...)):
11
+ async def inbox (payload : dict = Body (...)):
12
12
payload ["ts" ] = datetime .utcnow ().isoformat () + "Z"
13
13
MESSAGES .append (payload )
14
14
if len (MESSAGES ) > 100 :
@@ -27,6 +27,13 @@ def clear_inbox():
27
27
return {"ok" : True }
28
28
29
29
30
+ @app .delete ("/inbox/{id}" )
31
+ def delete_message (id : str ):
32
+ global MESSAGES
33
+ MESSAGES = [m for m in MESSAGES if m .get ("id" ) != id ]
34
+ return {"ok" : True }
35
+
36
+
30
37
# Twilio-compatible endpoint
31
38
@app .post ("/2010-04-01/Accounts/{sid}/Messages.json" )
32
39
async def send_sms (sid : str , request : Request ):
@@ -45,6 +52,7 @@ async def send_sms(sid: str, request: Request):
45
52
"frm" : from_ ,
46
53
"body" : body ,
47
54
"ts" : datetime .utcnow ().isoformat () + "Z" ,
55
+ "id" : str (uuid4 ()),
48
56
}
49
57
)
50
58
You can’t perform that action at this time.
0 commit comments