confserver revamp #88
18 changed files with 1445 additions and 920 deletions
|
|
@ -12,6 +12,9 @@ from logging.handlers import RotatingFileHandler
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import importlib
|
||||||
|
import pkgutil
|
||||||
|
from pkgutil import extend_path
|
||||||
|
|
||||||
def strtobool(strbool):
|
def strtobool(strbool):
|
||||||
if str(strbool).lower() in ["true", "1", "t", "y", "on", "yes"]:
|
if str(strbool).lower() in ["true", "1", "t", "y", "on", "yes"]:
|
||||||
|
|
@ -32,6 +35,8 @@ os.makedirs(data_dir, exist_ok=True) # Ensure data directory exists or create
|
||||||
certs_dir = os.environ.get("BUMPER_CERTS") or os.path.join(bumper_dir, "certs")
|
certs_dir = os.environ.get("BUMPER_CERTS") or os.path.join(bumper_dir, "certs")
|
||||||
os.makedirs(certs_dir, exist_ok=True) # Ensure data directory exists or create
|
os.makedirs(certs_dir, exist_ok=True) # Ensure data directory exists or create
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Certs
|
# Certs
|
||||||
ca_cert = os.environ.get("BUMPER_CA") or os.path.join(certs_dir, "ca.crt")
|
ca_cert = os.environ.get("BUMPER_CA") or os.path.join(certs_dir, "ca.crt")
|
||||||
server_cert = os.environ.get("BUMPER_CERT") or os.path.join(certs_dir, "bumper.crt")
|
server_cert = os.environ.get("BUMPER_CERT") or os.path.join(certs_dir, "bumper.crt")
|
||||||
|
|
@ -57,6 +62,16 @@ conf_server = None
|
||||||
conf_server_2 = None
|
conf_server_2 = None
|
||||||
xmpp_server = None
|
xmpp_server = None
|
||||||
|
|
||||||
|
# Plugins
|
||||||
|
sys.path.append(os.path.join(bumper_dir, "bumper", "plugins"))
|
||||||
|
sys.path.append(os.path.join(data_dir, "plugins"))
|
||||||
|
|
||||||
|
discovered_plugins = {
|
||||||
|
name: importlib.import_module(name)
|
||||||
|
for finder, name, ispkg in pkgutil.iter_modules()
|
||||||
|
if name.startswith('bumper_')
|
||||||
|
}
|
||||||
|
|
||||||
shutting_down = False
|
shutting_down = False
|
||||||
|
|
||||||
# Set format for all logs
|
# Set format for all logs
|
||||||
|
|
@ -206,10 +221,8 @@ async def start():
|
||||||
|
|
||||||
# Start web servers
|
# Start web servers
|
||||||
conf_server.confserver_app()
|
conf_server.confserver_app()
|
||||||
asyncio.create_task(conf_server.start_server())
|
asyncio.create_task(conf_server.start_site(conf_server.app, address=bumper_listen, port=conf1_listen_port, usessl=True))
|
||||||
|
asyncio.create_task(conf_server.start_site(conf_server.app, address=bumper_listen, port=conf2_listen_port, usessl=False))
|
||||||
conf_server_2.confserver_app()
|
|
||||||
asyncio.create_task(conf_server_2.start_server())
|
|
||||||
|
|
||||||
# Start maintenance
|
# Start maintenance
|
||||||
while not shutting_down:
|
while not shutting_down:
|
||||||
|
|
|
||||||
1101
bumper/confserver.py
1101
bumper/confserver.py
File diff suppressed because it is too large
Load diff
13
bumper/plugins.py
Normal file
13
bumper/plugins.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
class ConfServerApp():
|
||||||
|
name = None
|
||||||
|
plugin_type = None
|
||||||
|
path_prefix = None
|
||||||
|
app = None
|
||||||
|
sub_api = None
|
||||||
|
routes = None
|
||||||
|
|
||||||
|
|
||||||
69
bumper/plugins/bumper_confserver_portal_appsvr.py
Normal file
69
bumper/plugins/bumper_confserver_portal_appsvr.py
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class portal_api_appsvr(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_appsvr"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/appsvr/app.do", self.handle_appsvr_api, name="portal_api_appsvr_app"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_appsvr_api(self, request):
|
||||||
|
if not request.method == "GET": # Skip GET for now
|
||||||
|
try:
|
||||||
|
|
||||||
|
body = {}
|
||||||
|
postbody = {}
|
||||||
|
if request.content_type == "application/x-www-form-urlencoded":
|
||||||
|
postbody = await request.post()
|
||||||
|
|
||||||
|
else:
|
||||||
|
postbody = json.loads(await request.text())
|
||||||
|
|
||||||
|
todo = postbody["todo"]
|
||||||
|
|
||||||
|
if todo == "GetGlobalDeviceList": # EcoVacs Home
|
||||||
|
bots = bumper.db_get().table("bots").all()
|
||||||
|
botlist = []
|
||||||
|
for bot in bots:
|
||||||
|
if bot["class"] != "":
|
||||||
|
b = bumper.bot_toEcoVacsHome_JSON(bot)
|
||||||
|
if (
|
||||||
|
not b is None
|
||||||
|
): # Happens if the bot isn't on the EcoVacs Home list
|
||||||
|
botlist.append(json.loads(b))
|
||||||
|
|
||||||
|
body = {
|
||||||
|
"code": 0,
|
||||||
|
"devices": botlist,
|
||||||
|
"ret": "ok",
|
||||||
|
"todo": "result",
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
# Return fail for GET
|
||||||
|
body = {"result": "fail", "todo": "result"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
plugin = portal_api_appsvr()
|
||||||
|
|
||||||
72
bumper/plugins/bumper_confserver_portal_dim.py
Normal file
72
bumper/plugins/bumper_confserver_portal_dim.py
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
class portal_api_dim(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_dimr"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/dim/devmanager.do", self.handle_dim_devmanager, name="portal_api_dim_devmanager"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_dim_devmanager(self, request): # Used in EcoVacs Home App
|
||||||
|
try:
|
||||||
|
json_body = json.loads(await request.text())
|
||||||
|
|
||||||
|
randomid = "".join(random.sample(string.ascii_letters, 6))
|
||||||
|
did = ""
|
||||||
|
if "toId" in json_body: # Its a command
|
||||||
|
did = json_body["toId"]
|
||||||
|
|
||||||
|
if did != "":
|
||||||
|
bot = bumper.bot_get(did)
|
||||||
|
if bot["company"] == "eco-ng" and bot["mqtt_connection"] == True:
|
||||||
|
retcmd = await bumper.mqtt_helperbot.send_command(
|
||||||
|
json_body, randomid
|
||||||
|
)
|
||||||
|
body = retcmd
|
||||||
|
logging.debug("Send Bot - {}".format(json_body))
|
||||||
|
logging.debug("Bot Response - {}".format(body))
|
||||||
|
return web.json_response(body)
|
||||||
|
else:
|
||||||
|
# No response, send error back
|
||||||
|
logging.error(
|
||||||
|
"No bots with DID: {} connected to MQTT".format(
|
||||||
|
json_body["toId"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
body = {"id": randomid, "errno": bumper.ERR_COMMON, "ret": "fail"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
else:
|
||||||
|
if "td" in json_body: # Seen when doing initial wifi config
|
||||||
|
if json_body["td"] == "PollSCResult":
|
||||||
|
body = {"ret": "ok"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
if json_body["td"] == "HasUnreadMsg": # EcoVacs Home
|
||||||
|
body = {"ret": "ok", "unRead": False}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = portal_api_dim()
|
||||||
|
|
||||||
76
bumper/plugins/bumper_confserver_portal_iot.py
Normal file
76
bumper/plugins/bumper_confserver_portal_iot.py
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
|
||||||
|
class portal_api_iot(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_iot"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/iot/devmanager.do", self.handle_devmanager_botcommand, name="portal_api_iot_devmanager"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_devmanager_botcommand(self, request):
|
||||||
|
try:
|
||||||
|
json_body = json.loads(await request.text())
|
||||||
|
|
||||||
|
randomid = "".join(random.sample(string.ascii_letters, 6))
|
||||||
|
did = ""
|
||||||
|
if "toId" in json_body: # Its a command
|
||||||
|
did = json_body["toId"]
|
||||||
|
|
||||||
|
if did != "":
|
||||||
|
bot = bumper.bot_get(did)
|
||||||
|
if bot["company"] == "eco-ng":
|
||||||
|
retcmd = await bumper.mqtt_helperbot.send_command(
|
||||||
|
json_body, randomid
|
||||||
|
)
|
||||||
|
body = retcmd
|
||||||
|
logging.debug("Send Bot - {}".format(json_body))
|
||||||
|
logging.debug("Bot Response - {}".format(body))
|
||||||
|
return web.json_response(body)
|
||||||
|
else:
|
||||||
|
# No response, send error back
|
||||||
|
logging.error(
|
||||||
|
"No bots with DID: {} connected to MQTT".format(
|
||||||
|
json_body["toId"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
body = {
|
||||||
|
"id": randomid,
|
||||||
|
"errno": 500,
|
||||||
|
"ret": "fail",
|
||||||
|
"debug": "wait for response timed out",
|
||||||
|
}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
else:
|
||||||
|
if "td" in json_body: # Seen when doing initial wifi config
|
||||||
|
if json_body["td"] == "PollSCResult":
|
||||||
|
body = {"ret": "ok"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
if json_body["td"] == "HasUnreadMsg": # EcoVacs Home
|
||||||
|
body = {"ret": "ok", "unRead": False}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = portal_api_iot()
|
||||||
|
|
||||||
108
bumper/plugins/bumper_confserver_portal_lg.py
Normal file
108
bumper/plugins/bumper_confserver_portal_lg.py
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import os
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
class portal_api_lg(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_lg"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/lg/log.do", self.handle_lg_log, name="portal_api_lg_log"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_lg_log(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
json_body = json.loads(await request.text())
|
||||||
|
|
||||||
|
randomid = "".join(random.sample(string.ascii_letters, 6))
|
||||||
|
did = json_body["did"]
|
||||||
|
|
||||||
|
botdetails = bumper.bot_get(did)
|
||||||
|
if botdetails:
|
||||||
|
if not "cmdName" in json_body:
|
||||||
|
if "td" in json_body:
|
||||||
|
json_body["cmdName"] = json_body["td"]
|
||||||
|
|
||||||
|
if not "toId" in json_body:
|
||||||
|
json_body["toId"] = did
|
||||||
|
|
||||||
|
if not "toType" in json_body:
|
||||||
|
json_body["toType"] = botdetails["class"]
|
||||||
|
|
||||||
|
if not "toRes" in json_body:
|
||||||
|
json_body["toRes"] = botdetails["resource"]
|
||||||
|
|
||||||
|
if not "payloadType" in json_body:
|
||||||
|
json_body["payloadType"] = "x"
|
||||||
|
|
||||||
|
if not "payload" in json_body:
|
||||||
|
#json_body["payload"] = ""
|
||||||
|
if json_body["td"] == "GetCleanLogs":
|
||||||
|
json_body["td"] = "q"
|
||||||
|
json_body["payload"] = '<ctl count="30"/>'
|
||||||
|
|
||||||
|
if did != "":
|
||||||
|
bot = bumper.bot_get(did)
|
||||||
|
if bot["company"] == "eco-ng":
|
||||||
|
retcmd = await bumper.mqtt_helperbot.send_command(
|
||||||
|
json_body, randomid
|
||||||
|
)
|
||||||
|
body = retcmd
|
||||||
|
logging.debug("Send Bot - {}".format(json_body))
|
||||||
|
logging.debug("Bot Response - {}".format(body))
|
||||||
|
logs = []
|
||||||
|
logsroot = ET.fromstring(retcmd["resp"])
|
||||||
|
if logsroot.attrib["ret"] == "ok":
|
||||||
|
cleanlogs = logsroot.getchildren()
|
||||||
|
for l in cleanlogs:
|
||||||
|
cleanlog = {
|
||||||
|
"ts": l.attrib['s'],
|
||||||
|
"area": l.attrib['a'],
|
||||||
|
"last": l.attrib['l'],
|
||||||
|
"cleanType": l.attrib['t'],
|
||||||
|
#imageUrl allows for providing images of cleanings, something to look into later
|
||||||
|
#"imageUrl": "https://localhost:8007",
|
||||||
|
}
|
||||||
|
logs.append(cleanlog)
|
||||||
|
body = {
|
||||||
|
"ret": "ok",
|
||||||
|
"logs": logs,
|
||||||
|
}
|
||||||
|
|
||||||
|
else:
|
||||||
|
body = {"ret": "ok", "logs": []}
|
||||||
|
|
||||||
|
logging.debug("lg logs return: {}".format(json.dumps(body)))
|
||||||
|
return web.json_response(body)
|
||||||
|
else:
|
||||||
|
# No response, send error back
|
||||||
|
logging.error(
|
||||||
|
"No bots with DID: {} connected to MQTT".format(
|
||||||
|
json_body["toId"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
body = {"id": randomid, "errno": bumper.ERR_COMMON, "ret": "fail"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = portal_api_lg()
|
||||||
|
|
||||||
37
bumper/plugins/bumper_confserver_portal_neng.py
Normal file
37
bumper/plugins/bumper_confserver_portal_neng.py
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class portal_api_neng(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_neng"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/neng/message/hasUnreadMsg", self.handle_neng_hasUnreadMessage, name="portal_api_neng_hasUnreadMessage"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_neng_hasUnreadMessage(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {"code": 0, "data": {"hasUnRead": True}}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = portal_api_neng()
|
||||||
|
|
||||||
49
bumper/plugins/bumper_confserver_portal_pim.py
Normal file
49
bumper/plugins/bumper_confserver_portal_pim.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import os
|
||||||
|
|
||||||
|
class portal_api_pim(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_pim"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/pim/product/getProductIotMap", self.handle_getProductIotMap, name="portal_api_pim_getProductIotMap"),
|
||||||
|
web.route("*", "/pim/file/get/{id}", self.handle_pimFile, name="portal_api_pim_file"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_getProductIotMap(self, request):
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": EcoVacsHomeProducts,
|
||||||
|
}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_pimFile(self, request):
|
||||||
|
try:
|
||||||
|
fileID = request.match_info.get("id", "")
|
||||||
|
|
||||||
|
return web.FileResponse(os.path.join(bumper.data_dir,"web","robotvac_image.jpg"))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = portal_api_pim()
|
||||||
|
|
||||||
120
bumper/plugins/bumper_confserver_portal_users.py
Normal file
120
bumper/plugins/bumper_confserver_portal_users.py
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class portal_api_users(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_users"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/users/user.do", self.handle_usersapi, name="portal_api_users_user"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_usersapi(self, request):
|
||||||
|
if not request.method == "GET": # Skip GET for now
|
||||||
|
try:
|
||||||
|
|
||||||
|
body = {}
|
||||||
|
postbody = {}
|
||||||
|
if request.content_type == "application/x-www-form-urlencoded":
|
||||||
|
postbody = await request.post()
|
||||||
|
|
||||||
|
else:
|
||||||
|
postbody = json.loads(await request.text())
|
||||||
|
|
||||||
|
todo = postbody["todo"]
|
||||||
|
if todo == "FindBest":
|
||||||
|
service = postbody["service"]
|
||||||
|
if service == "EcoMsgNew":
|
||||||
|
srvip = bumper.bumper_announce_ip
|
||||||
|
srvport = 5223
|
||||||
|
logging.info(
|
||||||
|
"Announcing EcoMsgNew Server to bot as: {}:{}".format(
|
||||||
|
srvip, srvport
|
||||||
|
)
|
||||||
|
)
|
||||||
|
msgserver = {"ip": srvip, "port": srvport, "result": "ok"}
|
||||||
|
msgserver = json.dumps(msgserver)
|
||||||
|
msgserver = msgserver.replace(
|
||||||
|
" ", ""
|
||||||
|
) # bot seems to be very picky about having no spaces, only way was with text
|
||||||
|
|
||||||
|
return web.json_response(text=msgserver)
|
||||||
|
|
||||||
|
elif service == "EcoUpdate":
|
||||||
|
srvip = "47.88.66.164" # EcoVacs Server
|
||||||
|
srvport = 8005
|
||||||
|
logging.info(
|
||||||
|
"Announcing EcoUpdate Server to bot as: {}:{}".format(
|
||||||
|
srvip, srvport
|
||||||
|
)
|
||||||
|
)
|
||||||
|
body = {"result": "ok", "ip": srvip, "port": srvport}
|
||||||
|
|
||||||
|
elif todo == "loginByItToken":
|
||||||
|
if "userId" in postbody:
|
||||||
|
if bumper.check_authcode(postbody["userId"], postbody["token"]):
|
||||||
|
body = {
|
||||||
|
"resource": postbody["resource"],
|
||||||
|
"result": "ok",
|
||||||
|
"todo": "result",
|
||||||
|
"token": postbody["token"],
|
||||||
|
"userId": postbody["userId"],
|
||||||
|
}
|
||||||
|
else: # EcoVacs Home LoginByITToken
|
||||||
|
loginToken = bumper.loginByItToken(postbody["token"])
|
||||||
|
if not loginToken == {}:
|
||||||
|
body = {
|
||||||
|
"resource": postbody["resource"],
|
||||||
|
"result": "ok",
|
||||||
|
"todo": "result",
|
||||||
|
"token": loginToken["token"],
|
||||||
|
"userId": loginToken["userid"],
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
body = {"result": "fail", "todo": "result"}
|
||||||
|
|
||||||
|
elif todo == "GetDeviceList":
|
||||||
|
body = {
|
||||||
|
"devices": bumper.db_get().table("bots").all(),
|
||||||
|
"result": "ok",
|
||||||
|
"todo": "result",
|
||||||
|
}
|
||||||
|
|
||||||
|
elif todo == "SetDeviceNick":
|
||||||
|
bumper.bot_set_nick(postbody["did"], postbody["nick"])
|
||||||
|
body = {"result": "ok", "todo": "result"}
|
||||||
|
|
||||||
|
elif todo == "AddOneDevice":
|
||||||
|
bumper.bot_set_nick(postbody["did"], postbody["nick"])
|
||||||
|
body = {"result": "ok", "todo": "result"}
|
||||||
|
|
||||||
|
elif todo == "DeleteOneDevice":
|
||||||
|
bumper.bot_remove(postbody["did"])
|
||||||
|
body = {"result": "ok", "todo": "result"}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
# Return fail for GET
|
||||||
|
body = {"result": "fail", "todo": "result"}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
plugin = portal_api_users()
|
||||||
|
|
||||||
28
bumper/plugins/bumper_confserver_v1_global_auth.py
Normal file
28
bumper/plugins/bumper_confserver_v1_global_auth.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_global_auth(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_global_auth"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
authhandler = bumper.ConfServer.ConfServer_AuthHandler()
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/global/auth/getAuthCode", authhandler.get_AuthCode, name="v1_global_auth_getAuthCode"),
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
|
||||||
|
plugin = v1_global_auth()
|
||||||
|
|
||||||
58
bumper/plugins/bumper_confserver_v1_private_ad.py
Normal file
58
bumper/plugins/bumper_confserver_v1_private_ad.py
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_ad(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_private_ad"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/ad/getAdByPositionType", self.handle_getAdByPositionType, name="v1_ad_getAdByPositionType"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/ad/getBootScreen", self.handle_getBootScreen, name="v1_ad_getBootScreen"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_getAdByPositionType(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": None,
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_getBootScreen(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": None,
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = v1_private_ad()
|
||||||
|
|
||||||
54
bumper/plugins/bumper_confserver_v1_private_campaign.py
Normal file
54
bumper/plugins/bumper_confserver_v1_private_campaign.py
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_campaign(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_private_campaign"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/campaign/homePageAlert", self.handle_homePageAlert, name="v1_campaign_homePageAlert"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_homePageAlert(self, request):
|
||||||
|
try:
|
||||||
|
nextAlert = self.get_milli_time(
|
||||||
|
(datetime.now() + timedelta(hours=12)).timestamp()
|
||||||
|
)
|
||||||
|
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {
|
||||||
|
"clickSchemeUrl": None,
|
||||||
|
"clickWebUrl": None,
|
||||||
|
"hasCampaign": "N",
|
||||||
|
"imageUrl": None,
|
||||||
|
"nextAlertTime": nextAlert,
|
||||||
|
"serverTime": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
plugin = v1_private_campaign()
|
||||||
|
|
||||||
115
bumper/plugins/bumper_confserver_v1_private_common.py
Normal file
115
bumper/plugins/bumper_confserver_v1_private_common.py
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_common(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_private_common"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/common/checkAPPVersion", self.handle_checkAPPVersion, name="v1_common_checkAppVersion"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/common/checkVersion", self.handle_checkVersion, name="v1_common_checkVersion"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/common/uploadDeviceInfo", self.handle_uploadDeviceInfo, name="v1_common_uploadDeviceInfo"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/common/getSystemReminder", self.handle_getSystemReminder, name="v1_common_getSystemReminder"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_checkVersion(self, request):
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {
|
||||||
|
"c": None,
|
||||||
|
"img": None,
|
||||||
|
"r": 0,
|
||||||
|
"t": None,
|
||||||
|
"u": None,
|
||||||
|
"ut": 0,
|
||||||
|
"v": None,
|
||||||
|
},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_checkAPPVersion(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {
|
||||||
|
"c": None,
|
||||||
|
"downPageUrl": None,
|
||||||
|
"img": None,
|
||||||
|
"nextAlertTime": None,
|
||||||
|
"r": 0,
|
||||||
|
"t": None,
|
||||||
|
"u": None,
|
||||||
|
"ut": 0,
|
||||||
|
"v": None,
|
||||||
|
},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_uploadDeviceInfo(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": None,
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_getSystemReminder(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {
|
||||||
|
"iosGradeTime": {"iodGradeFlag": "N"},
|
||||||
|
"openNotification": {
|
||||||
|
"openNotificationContent": None,
|
||||||
|
"openNotificationFlag": "N",
|
||||||
|
"openNotificationTitle": None,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
plugin = v1_private_common()
|
||||||
|
|
||||||
59
bumper/plugins/bumper_confserver_v1_private_message.py
Normal file
59
bumper/plugins/bumper_confserver_v1_private_message.py
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_message(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_private_message"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/message/hasUnreadMsg", self.handle_hasUnreadMessage, name="v1_message_hasUnreadMsg"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/message/getMsgList", self.handle_getMsgList, name="v1_message_getMsgList"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_hasUnreadMessage(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": "N",
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_getMsgList(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {"hasNextPage": 0, "items": []},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = v1_private_message()
|
||||||
|
|
||||||
48
bumper/plugins/bumper_confserver_v1_private_shop.py
Normal file
48
bumper/plugins/bumper_confserver_v1_private_shop.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_shop(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "v1_private_shop"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/shop/getCnWapShopConfig", self.handle_getCnWapShopConfig, name="v1_shop_getCnWapShopConfig"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_getCnWapShopConfig(self, request): # EcoVacs Home
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": {
|
||||||
|
"myShopShowFlag": "N",
|
||||||
|
"myShopUrl": "",
|
||||||
|
"shopIndexShowFlag": "N",
|
||||||
|
"shopIndexUrl": "",
|
||||||
|
},
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = v1_private_shop()
|
||||||
|
|
||||||
76
bumper/plugins/bumper_confserver_v1_private_user.py
Normal file
76
bumper/plugins/bumper_confserver_v1_private_user.py
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v1_private_user(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
self.name = "v1_private_user"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v1"
|
||||||
|
|
||||||
|
authhandler = bumper.ConfServer.ConfServer_AuthHandler()
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/login", authhandler.login, name="v1_user_login"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkLogin", authhandler.login, name="v1_user_checkLogin"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getAuthCode", authhandler.get_AuthCode, name="v1_user_getAuthCode"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/logout", authhandler.logout, name="v1_user_logout"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreement", self.handle_checkAgreement,name="v1_user_checkAgreement"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreementBatch", self.handle_checkAgreement,name="v1_user_checkAgreementBatch"),
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getUserAccountInfo", authhandler.getUserAccountInfo,name="v1_user_getUserAccountInfo"),
|
||||||
|
# Direct register from app:
|
||||||
|
# /{apiversion}/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/directRegister
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_checkAgreement(self, request):
|
||||||
|
try:
|
||||||
|
apptype = request.match_info.get("apptype", "")
|
||||||
|
if "global_" in apptype:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"force": "N",
|
||||||
|
"id": "20180804040641_7d746faf18b8cb22a50d145598fe4c90",
|
||||||
|
"type": "USER",
|
||||||
|
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN
|
||||||
|
"version": "1.01",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"force": "N",
|
||||||
|
"id": "20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac",
|
||||||
|
"type": "PRIVACY",
|
||||||
|
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN"
|
||||||
|
"version": "1.01",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
body = {
|
||||||
|
"code": bumper.RETURN_API_SUCCESS,
|
||||||
|
"data": [],
|
||||||
|
"msg": "操作成功",
|
||||||
|
"time": self.get_milli_time(datetime.utcnow().timestamp()),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
plugin = v1_private_user()
|
||||||
|
|
||||||
29
bumper/plugins/bumper_confserver_v2_private_user.py
Normal file
29
bumper/plugins/bumper_confserver_v2_private_user.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class v2_private_user(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
self.name = "v2_private_user"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "api_v2"
|
||||||
|
|
||||||
|
authhandler = bumper.ConfServer.ConfServer_AuthHandler()
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkLogin", authhandler.login, name="v2_user_checkLogin"),
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
|
||||||
|
plugin = v2_private_user()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue