Files
LangBot/pkg/audit/center/groups/plugin.py

66 lines
1.6 KiB
Python
Raw Normal View History

from __future__ import annotations
2024-01-29 21:22:27 +08:00
from ....core import app
from .. import apigroup
class V2PluginDataAPI(apigroup.APIGroup):
"""插件数据相关 API"""
2024-01-29 21:22:27 +08:00
def __init__(self, prefix: str, ap: app.Application):
self.ap = ap
2024-01-31 00:02:19 +08:00
super().__init__(prefix+"/plugin", ap)
2024-01-29 21:58:47 +08:00
async def do(self, *args, **kwargs):
2024-02-06 21:26:03 +08:00
if not self.ap.system_cfg.data['report-usage']:
2024-01-12 17:20:39 +08:00
return None
2024-01-29 21:58:47 +08:00
return await super().do(*args, **kwargs)
2024-01-12 17:20:39 +08:00
2024-01-29 21:58:47 +08:00
async def post_install_record(
self,
plugin: dict
):
"""提交插件安装记录"""
2024-01-29 21:58:47 +08:00
return await self.do(
"POST",
"/install",
data={
"basic": self.basic_info(),
"plugin": plugin,
}
)
2024-01-29 21:58:47 +08:00
async def post_remove_record(
self,
plugin: dict
):
"""提交插件卸载记录"""
2024-01-29 21:58:47 +08:00
return await self.do(
"POST",
"/remove",
data={
"basic": self.basic_info(),
"plugin": plugin,
}
)
2024-01-29 21:58:47 +08:00
async def post_update_record(
self,
plugin: dict,
old_version: str,
new_version: str,
):
"""提交插件更新记录"""
2024-01-29 21:58:47 +08:00
return await self.do(
"POST",
"/update",
data={
"basic": self.basic_info(),
"plugin": plugin,
"update_info": {
"old_version": old_version,
"new_version": new_version,
}
}
)