mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Fix updating instance with sqlalchemy core
This commit is contained in:
parent
4d7fa10382
commit
bbbb92782f
@ -85,13 +85,14 @@ async def _update_client(client: Client, data: dict) -> web.Response:
|
|||||||
return resp.bad_client_connection_details
|
return resp.bad_client_connection_details
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return resp.mxid_mismatch(str(e)[len("MXID mismatch: "):])
|
return resp.mxid_mismatch(str(e)[len("MXID mismatch: "):])
|
||||||
await client.update_avatar_url(data.get("avatar_url", None))
|
with client.db_instance.edit_mode():
|
||||||
await client.update_displayname(data.get("displayname", None))
|
await client.update_avatar_url(data.get("avatar_url", None))
|
||||||
await client.update_started(data.get("started", None))
|
await client.update_displayname(data.get("displayname", None))
|
||||||
client.enabled = data.get("enabled", client.enabled)
|
await client.update_started(data.get("started", None))
|
||||||
client.autojoin = data.get("autojoin", client.autojoin)
|
client.enabled = data.get("enabled", client.enabled)
|
||||||
client.sync = data.get("sync", client.sync)
|
client.autojoin = data.get("autojoin", client.autojoin)
|
||||||
return resp.updated(client.to_dict())
|
client.sync = data.get("sync", client.sync)
|
||||||
|
return resp.updated(client.to_dict())
|
||||||
|
|
||||||
|
|
||||||
@routes.post("/client/new")
|
@routes.post("/client/new")
|
||||||
|
@ -64,13 +64,13 @@ async def _create_instance(instance_id: str, data: dict) -> web.Response:
|
|||||||
async def _update_instance(instance: PluginInstance, data: dict) -> web.Response:
|
async def _update_instance(instance: PluginInstance, data: dict) -> web.Response:
|
||||||
if not await instance.update_primary_user(data.get("primary_user", None)):
|
if not await instance.update_primary_user(data.get("primary_user", None)):
|
||||||
return resp.primary_user_not_found
|
return resp.primary_user_not_found
|
||||||
instance.update_id(data.get("id", None))
|
with instance.db_instance.edit_mode():
|
||||||
instance.update_enabled(data.get("enabled", None))
|
instance.update_id(data.get("id", None))
|
||||||
instance.update_config(data.get("config", None))
|
instance.update_enabled(data.get("enabled", None))
|
||||||
await instance.update_started(data.get("started", None))
|
instance.update_config(data.get("config", None))
|
||||||
await instance.update_type(data.get("type", None))
|
await instance.update_started(data.get("started", None))
|
||||||
instance.db.commit()
|
await instance.update_type(data.get("type", None))
|
||||||
return resp.updated(instance.to_dict())
|
return resp.updated(instance.to_dict())
|
||||||
|
|
||||||
|
|
||||||
@routes.put("/instance/{id}")
|
@routes.put("/instance/{id}")
|
||||||
@ -90,7 +90,7 @@ async def update_instance(request: web.Request) -> web.Response:
|
|||||||
@routes.delete("/instance/{id}")
|
@routes.delete("/instance/{id}")
|
||||||
async def delete_instance(request: web.Request) -> web.Response:
|
async def delete_instance(request: web.Request) -> web.Response:
|
||||||
instance_id = request.match_info.get("id", "").lower()
|
instance_id = request.match_info.get("id", "").lower()
|
||||||
instance = PluginInstance.get(instance_id, None)
|
instance = PluginInstance.get(instance_id)
|
||||||
if not instance:
|
if not instance:
|
||||||
return resp.instance_not_found
|
return resp.instance_not_found
|
||||||
if instance.started:
|
if instance.started:
|
||||||
|
2
setup.py
2
setup.py
@ -21,7 +21,7 @@ setuptools.setup(
|
|||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"mautrix>=0.4.dev67,<0.5",
|
"mautrix>=0.4.dev68,<0.5",
|
||||||
"aiohttp>=3.0.1,<4",
|
"aiohttp>=3.0.1,<4",
|
||||||
"SQLAlchemy>=1.2.3,<2",
|
"SQLAlchemy>=1.2.3,<2",
|
||||||
"alembic>=1.0.0,<2",
|
"alembic>=1.0.0,<2",
|
||||||
|
Loading…
Reference in New Issue
Block a user