update function
This commit is contained in:
@@ -4,7 +4,16 @@ import json
|
|||||||
import time
|
import time
|
||||||
from minio import Minio
|
from minio import Minio
|
||||||
|
|
||||||
DEFAULT_STATE = {"text": "", "image_url": ""}
|
DEFAULT_STATE = {
|
||||||
|
"text": {
|
||||||
|
"showing": False,
|
||||||
|
"title": "Wassup"
|
||||||
|
},
|
||||||
|
"image_popup": {
|
||||||
|
"showing": False,
|
||||||
|
"image_url": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MINIO_CLIENT = Minio(
|
MINIO_CLIENT = Minio(
|
||||||
"content2.reversed.dev",
|
"content2.reversed.dev",
|
||||||
@@ -34,7 +43,13 @@ def main(args):
|
|||||||
if route.startswith("push"):
|
if route.startswith("push"):
|
||||||
if route == "push_text":
|
if route == "push_text":
|
||||||
current = _read_state()
|
current = _read_state()
|
||||||
current["text"] = body.get("text", "")
|
current["text"]["title"] = body.get("title", "")
|
||||||
|
current["text"]["showing"] = True
|
||||||
|
_write_state(current)
|
||||||
|
return {"status": "success"}
|
||||||
|
elif route == "push_dismiss_text":
|
||||||
|
current = _read_state()
|
||||||
|
current["text"]["showing"] = False
|
||||||
_write_state(current)
|
_write_state(current)
|
||||||
return {"status": "success"}
|
return {"status": "success"}
|
||||||
elif route == "push_image":
|
elif route == "push_image":
|
||||||
@@ -46,17 +61,23 @@ def main(args):
|
|||||||
)
|
)
|
||||||
public_url = f"https://content2.reversed.dev/{BUCKET}/{file_name}"
|
public_url = f"https://content2.reversed.dev/{BUCKET}/{file_name}"
|
||||||
current = _read_state()
|
current = _read_state()
|
||||||
current["image_url"] = public_url
|
current["image_popup"]["image_url"] = public_url
|
||||||
|
current["image_popup"]["showing"] = True
|
||||||
_write_state(current)
|
_write_state(current)
|
||||||
return {"status": "success", "image_url": public_url}
|
return {"status": "success", "image_url": public_url}
|
||||||
|
elif route == "push_dismiss_image":
|
||||||
|
current = _read_state()
|
||||||
|
current["image_popup"]["showing"] = False
|
||||||
|
_write_state(current)
|
||||||
|
return {"status": "success"}
|
||||||
else:
|
else:
|
||||||
return {"status": "error", "message": "Unknown push route"}
|
return {"status": "error", "message": "Unknown push route"}
|
||||||
elif route.startswith("pull"):
|
elif route.startswith("pull"):
|
||||||
current = _read_state()
|
current = _read_state()
|
||||||
if route == "pull_text":
|
if route == "pull_text":
|
||||||
return {"status": "success", "text": current.get("text", "")}
|
return {"status": "success", "text": current.get("text", {})}
|
||||||
elif route == "pull_image_url":
|
elif route == "pull_image":
|
||||||
return {"status": "success", "image_url": current.get("image_url", "")}
|
return {"status": "success", "image_popup": current.get("image_popup", {})}
|
||||||
elif route == "pull_full":
|
elif route == "pull_full":
|
||||||
return {"status": "success", "state": current}
|
return {"status": "success", "state": current}
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user