From 35834b47cb7f4174d01bc6ac9391a8bf2017ac83 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Mon, 15 Aug 2022 19:52:00 +0200 Subject: [PATCH] add missing endpoints --- bumper/web/plugins/api/appsvr.py | 178 +++++++++++++++++- bumper/web/plugins/api/homed.py | 52 +++++ bumper/web/plugins/v2/private/__init__.py | 3 + bumper/web/plugins/v2/private/common.py | 68 +++++++ bumper/web/plugins/v2/private/message.py | 29 +++ .../v2/{private_user.py => private/user.py} | 14 +- 6 files changed, 335 insertions(+), 9 deletions(-) create mode 100644 bumper/web/plugins/api/homed.py create mode 100644 bumper/web/plugins/v2/private/__init__.py create mode 100644 bumper/web/plugins/v2/private/common.py create mode 100644 bumper/web/plugins/v2/private/message.py rename bumper/web/plugins/v2/{private_user.py => private/user.py} (54%) diff --git a/bumper/web/plugins/api/appsvr.py b/bumper/web/plugins/api/appsvr.py index 2e0ddad..3ebeb4a 100644 --- a/bumper/web/plugins/api/appsvr.py +++ b/bumper/web/plugins/api/appsvr.py @@ -32,14 +32,29 @@ class AppsvrPlugin(WebserverPlugin): ), web.route( "*", - "/appsvr/service/list", - _handle_appsvr_service_list, + "/appsvr/app/config", + _handle_appsvr_app_config, + ), + web.route( + "*", + "/appsvr/improve/accept", + _handle_appsvr_improve_accept, + ), + web.route( + "*", + "/appsvr/notice/home", + _handle_appsvr_notice_home, ), web.route( "*", "/appsvr/oauth_callback", _handle_appsvr_oauth_callback, ), + web.route( + "*", + "/appsvr/service/list", + _handle_appsvr_service_list, + ), ] @@ -56,7 +71,7 @@ async def _handle_appsvr_app(request: Request) -> Response: todo = postbody["todo"] - if todo == "GetGlobalDeviceList": # EcoVacs Home + if todo == "GetGlobalDeviceList": bots = db_get().table("bots").all() devices = [] for bot in bots: @@ -74,6 +89,15 @@ async def _handle_appsvr_app(request: Request) -> Response: } return web.json_response(body) + if todo == "GetCodepush": + return web.json_response( + { + "code": 0, + "data": {"extend": {}, "type": "microsoft", "url": ""}, + "ret": "ok", + "todo": "result", + } + ) except Exception: # pylint: disable=broad-except logging.error("Unexpected exception occurred", exc_info=True) @@ -171,3 +195,151 @@ async def _handle_appsvr_oauth_callback(request: Request) -> Response: logging.error("Unexpected exception occurred", exc_info=True) raise HTTPInternalServerError + + +async def _handle_appsvr_improve_accept(_: Request) -> Response: + return web.json_response({"code": 0}) + + +async def _handle_appsvr_notice_home(_: Request) -> Response: + return web.json_response({"code": 0, "data": [], "ret": "ok", "todo": "result"}) + + +async def _handle_appsvr_app_config(_: Request) -> Response: + body = { + "todo": "result", + "ret": "ok", + "code": 0, + "data": [ + { + "resId": "614d73873d80d1deed8be299", + "code": "codepush_config", + "name": "", + "description": "", + "type": "jsonObject", + "content": { + "netDiagno": { + "deploymentKey": { + "production": "1YhT34XSJJ-iUPtrBsi-zXA1LPCyAtLjsEW7IU", + "staging": "Cqn5Kl-UYcru2RYKN9xJvMHaA7lWAmd7d-vli", + "current": "production", + }, + "version": "1.0.0", + }, + "robotDiscovery": { + "deploymentKey": { + "production": "z94xCOc2FnBqdw6IJMFvMoWFLALxVNGsK0wHuJ", + "staging": "w3nVjj2mBV1JdO8tBO2JcU8EL4W6nBrv8KOVo", + "current": "production", + }, + "version": "1.0.0", + }, + "language": { + "deploymentKey": { + "production": "mQ7b_ImAD5t_hapi17Dt_CK0ZU1nArKrTYdCTI", + "staging": "IPbEkwK4wD9MCzWtncXQ8C0lDdLQxOMn13Owg", + "current": "production", + }, + "version": "1.0.0", + }, + "winbot": { + "deploymentKey": { + "production": "QEdpHlrNp1ANHhYFbEJ63dYo1bcsZCShQ9H938", + "staging": "uYmbjPDsvnfIBjjY9pM0PdESrZX8_QxMpm-bH", + "current": "production", + }, + "version": "1.0.0", + }, + "beluga": { + "deploymentKey": { + "production": "vhaH5f2nNpKiXPFDhVq6yf4gr6xFGAOKoMGTFT", + "staging": "RT1aLYD7YwQms9vs539Qn5GjRlExVWeMTOHeF", + }, + "version": "1.0.0", + }, + "hwPush": { + "deploymentKey": { + "production": "4cPMrbntK2vbs-KRgsrJq4HI0W-hrTHP1BMTKq", + "staging": "dXgPCPco60Fc_JlZ5S_bS0ZanhlaNiU9elFaj", + "current": "production", + }, + "version": "1.0.0", + }, + "t10More": { + "deploymentKey": { + "production": "RSYAx668chaf0tpKvf1kJNaVJmDzi4g83wsg78", + "staging": "yQeevYX5q1yVhr_dH0VwKNJ3x3iDBSxJ-E91G", + "current": "production", + }, + "version": "1.0.0", + }, + "test20": { + "deploymentKey": { + "production": "n1MBCZHFWVi3PFdxg-u6N7yF6CStEXtlKms3O", + "staging": "vCmfAvE-g-OkOvLm8ckIfjLwf1c9a-fBGI6u2", + "current": "production", + }, + "version": "1.0.0", + }, + "at90": { + "deploymentKey": { + "production": "1W2Lw4KvqTz0D-UMxzfZSEcv2yWpoD7SZyGzb4", + "staging": "bokwAmqkL-svCnwI8Fd1pGSHBSf-aBoXWtNyi", + "current": "production", + }, + "version": "1.0.0", + }, + "bruceMore": { + "deploymentKey": { + "production": "P5sN80W6TdO5nQ63CJWvtTgnu-BKYqxQmf8IEi", + "staging": "1FXFufgsGXUcHc2F7eLWPPDXDsVySG9sj5VKc", + "current": "production", + }, + "version": "1.0.0", + }, + "furniture": { + "deploymentKey": { + "production": "VKfJlwYCG58sJN3FfCjYGqRd2M81HCIn2kOBrw", + "staging": "M7lyba6OXxVBG_KrkIgbv569Jnwz6V1gdk0oA", + "current": "production", + }, + "version": "1.0.0", + }, + "bruce3dRes": { + "deploymentKey": { + "production": "uOtNaTLAbWAFiQhovEqW4nyhvUbSxFNF92vdiV", + "staging": "4mm6F3Jak4JtMwO2AMHlbTHElUOMWZd_IzL5P", + "current": "production", + }, + "version": "2.1.4", + }, + "t10H5": { + "deploymentKey": { + "production": "mackERM5dTh8cqiAk9MEBuRhdgLEytf1emmE4H", + "staging": "f93aQ5QrspoyG5vYvPTICrfmS65YJVNFuNJ0o", + "current": "production", + }, + "version": "1.0.0", + }, + "x1proH5": { + "deploymentKey": { + "production": "Wt3wZa8Hs69dbZgtNXsiNVcda9P-GBSBDm4lDw", + "staging": "UvSn3tgPRYfmhwT7YOwP4WO5Us6HKC-sq91HS", + "current": "production", + }, + "version": "1.0.0", + }, + "andyproH5": { + "deploymentKey": { + "production": "SmTGB14wfXJnTZ0iHh03tEq83S9j6vK_B0zI9s", + "staging": "zhiPemGhbl0FV3V8_kBY9luOBgLd55YwYuImG", + "current": "production", + }, + "version": "1.0.0", + }, + }, + } + ], + } + + return web.json_response(body) diff --git a/bumper/web/plugins/api/homed.py b/bumper/web/plugins/api/homed.py new file mode 100644 index 0000000..e5bbca6 --- /dev/null +++ b/bumper/web/plugins/api/homed.py @@ -0,0 +1,52 @@ +"""Homed plugin module.""" +import logging +from typing import Iterable + +from aiohttp import web +from aiohttp.web_exceptions import HTTPInternalServerError +from aiohttp.web_request import Request +from aiohttp.web_response import Response +from aiohttp.web_routedef import AbstractRouteDef + +from .. import WebserverPlugin + + +class HomedPlugin(WebserverPlugin): + """Homed plugin.""" + + @property + def routes(self) -> Iterable[AbstractRouteDef]: + """Plugin routes.""" + return [ + web.route( + "*", + "(homed/home/list", + _handle_home_list, + ), + ] + + +async def _handle_home_list(request: Request) -> Response: + try: + body = { + "code": 0, + "data": [ + { + "createTime": 1650545319746, + "createUser": request.query["userid"], + "createUserName": request.query["userid"], + "firstCreate": False, + "homeId": "781a0733923f2240cf304757", + "name": "My Home", + "type": "own", + } + ], + "message": "success", + } + + return web.json_response(body) + + except Exception: # pylint: disable=broad-except + logging.error("Unexpected exception occurred", exc_info=True) + + raise HTTPInternalServerError diff --git a/bumper/web/plugins/v2/private/__init__.py b/bumper/web/plugins/v2/private/__init__.py new file mode 100644 index 0000000..a7b8a5d --- /dev/null +++ b/bumper/web/plugins/v2/private/__init__.py @@ -0,0 +1,3 @@ +"""Private plugins module.""" + +BASE_URL = "/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/" diff --git a/bumper/web/plugins/v2/private/common.py b/bumper/web/plugins/v2/private/common.py new file mode 100644 index 0000000..2fcb4ea --- /dev/null +++ b/bumper/web/plugins/v2/private/common.py @@ -0,0 +1,68 @@ +"""Common plugin module.""" +from typing import Iterable + +from aiohttp import web +from aiohttp.web_request import Request +from aiohttp.web_response import Response +from aiohttp.web_routedef import AbstractRouteDef + +from ... import WebserverPlugin, get_success_response +from . import BASE_URL + + +class CommonPlugin(WebserverPlugin): + """Common plugin.""" + + @property + def routes(self) -> Iterable[AbstractRouteDef]: + """Plugin routes.""" + return [ + web.route( + "*", + f"{BASE_URL}common/getBottomNavigateInfoList", + _handle_get_bottom_navigate_info_list, + ), + ] + + +async def _handle_get_bottom_navigate_info_list(_: Request) -> Response: + return get_success_response( + [ + { + "iconId": "20220630090128_a52665b919e83a96326cfd8d1500989b", + "iconName": "Roboter", + "iconType": "ROBOT", + "defaultImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302010444_8b161f90b4245f740e439fe5eee49de5.png", + "lightImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302010449_8f17ad41995c874d4fe1028f8c61a233.png", + "lightNameRgb": "#005EB8", + "mediaType": None, + "mediaUrl": "NULL", + "positionType": "Robot", + "tabItemActionUrl": None, + }, + { + "iconId": "20220630090128_0c7424cf783de485ca15a43fb1f4ddf8", + "iconName": "Geschäft", + "iconType": "MALL", + "defaultImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302010612_7db1c568c734cfb708e55b9f1eb3d71c.png", + "lightImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302010617_0da5c81774dcf27bb2e37c44a1691d88.png", + "lightNameRgb": "#005EB8", + "mediaType": None, + "mediaUrl": "NULL", + "positionType": "Store", + "tabItemActionUrl": "https://www.ecovacs.com/it?utm_source=ecovacsGlobalApp&utm_medium=Appshopclick_IT&utm_campaign=Menu_IT", + }, + { + "iconId": "20220630090128_67c33cb9c3120c5448e2cda230a7abd1", + "iconName": "Mein", + "iconType": "MINE", + "defaultImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302011202_a79a79b85247a6dff7e27356de1293bb.png", + "lightImgUrl": "https://gl-us-pub.ecovacs.com/upload/global/2022/03/02/20220302011209_ff6592b7ae5b286f1bc3df52d9d5e7e3.png", + "lightNameRgb": "#005EB8", + "mediaType": None, + "mediaUrl": "NULL", + "positionType": "Mine", + "tabItemActionUrl": None, + }, + ] + ) diff --git a/bumper/web/plugins/v2/private/message.py b/bumper/web/plugins/v2/private/message.py new file mode 100644 index 0000000..0273b19 --- /dev/null +++ b/bumper/web/plugins/v2/private/message.py @@ -0,0 +1,29 @@ +"""Message plugin module.""" +from typing import Iterable + +from aiohttp import web +from aiohttp.web_request import Request +from aiohttp.web_response import Response +from aiohttp.web_routedef import AbstractRouteDef + +from ... import WebserverPlugin, get_success_response +from . import BASE_URL + + +class MessagePlugin(WebserverPlugin): + """Message plugin.""" + + @property + def routes(self) -> Iterable[AbstractRouteDef]: + """Plugin routes.""" + return [ + web.route( + "*", + f"{BASE_URL}message/hasMoreUnReadMsg", + _handle_has_more_unread_message, + ), + ] + + +async def _handle_has_more_unread_message(_: Request) -> Response: + return get_success_response({"moreUnReadMsg": "N"}) diff --git a/bumper/web/plugins/v2/private_user.py b/bumper/web/plugins/v2/private/user.py similarity index 54% rename from bumper/web/plugins/v2/private_user.py rename to bumper/web/plugins/v2/private/user.py index 4de51f8..d53d814 100644 --- a/bumper/web/plugins/v2/private_user.py +++ b/bumper/web/plugins/v2/private/user.py @@ -1,15 +1,17 @@ -"""Private user module.""" +"""User plugin module.""" from typing import Iterable from aiohttp import web from aiohttp.web_routedef import AbstractRouteDef -from ... import auth_util -from .. import WebserverPlugin +from bumper.web import auth_util + +from ... import WebserverPlugin +from . import BASE_URL -class PrivateUserPlugin(WebserverPlugin): - """Private user plugin.""" +class UserPlugin(WebserverPlugin): + """User plugin.""" @property def routes(self) -> Iterable[AbstractRouteDef]: @@ -17,7 +19,7 @@ class PrivateUserPlugin(WebserverPlugin): return [ web.route( "*", - "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkLogin", + f"{BASE_URL}user/checkLogin", auth_util.login, ), ]