crf exempt on echo bot
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
34d8809bd1
commit
1a80d6be24
@ -6,22 +6,16 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
def health(request):
|
||||
return JsonResponse({"ok": True, "service": "pxy_bots", "schema_ready": ["req.v1", "render.v1"]})
|
||||
|
||||
# pxy_bots/api/views.py
|
||||
import json
|
||||
from django.http import JsonResponse
|
||||
|
||||
@csrf_exempt
|
||||
def echo_render(request):
|
||||
"""
|
||||
Accepts req.v1 and returns a simple render_spec so you can validate the router.
|
||||
"""
|
||||
try:
|
||||
data = json.loads(request.body.decode("utf-8") or "{}")
|
||||
except Exception:
|
||||
data = {}
|
||||
|
||||
text = (((data.get("input") or {}).get("text")) or "Hola 👋")
|
||||
who = (((data.get("user") or {}).get("id")) or "user")
|
||||
cmd = (((data.get("command") or {}).get("name")) or "none")
|
||||
who = (((data.get("user") or {}).get("id")) or "user")
|
||||
cmd = (((data.get("command") or {}).get("name")) or "none")
|
||||
|
||||
spec = {
|
||||
"schema_version": "render.v1",
|
||||
@ -29,9 +23,5 @@ def echo_render(request):
|
||||
{"type": "text", "text": f"echo: user={who} cmd={cmd}"},
|
||||
{"type": "text", "text": f"you said: {text}"},
|
||||
],
|
||||
"buttons": [
|
||||
{"label": "Abrir Dashboard", "kind": "open_url", "url": "https://app.polisplexity.tech/"},
|
||||
{"label": "Re-ejecutar 10’", "kind": "callback_api", "action": "rerun", "params": {"minutes": 10}},
|
||||
],
|
||||
}
|
||||
return JsonResponse(spec)
|
||||
return JsonResponse(spec)
|
||||
|
Loading…
x
Reference in New Issue
Block a user