feat: update file download url

This commit is contained in:
Junyan Qin
2025-02-25 16:12:45 +08:00
parent 4db1d2b3a3
commit 9401a79b2b
8 changed files with 45 additions and 17 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class GewechatConfigMigration(migration.Migration):
"adapter": "gewechat",
"enable": False,
"gewechat_url": "http://your-gewechat-server:2531",
"gewechat_downloadImage_port": 2532,
"gewechat_file_url": "http://your-gewechat-server:2532",
"port": 2286,
"callback_url": "http://your-callback-url:2286/gewechat/callback",
"app_id": "",
@@ -0,0 +1,29 @@
from __future__ import annotations
from urllib.parse import urlparse
from .. import migration
@migration.migration_class("gewechat-file-url-config", 34)
class GewechatFileUrlConfigMigration(migration.Migration):
"""迁移"""
async def need_migrate(self) -> bool:
"""判断当前环境是否需要运行此迁移"""
for adapter in self.ap.platform_cfg.data['platform-adapters']:
if adapter['adapter'] == 'gewechat':
if 'gewechat_file_url' not in adapter:
return True
return False
async def run(self):
"""执行迁移"""
for adapter in self.ap.platform_cfg.data['platform-adapters']:
if adapter['adapter'] == 'gewechat':
if 'gewechat_file_url' not in adapter:
parsed_url = urlparse(adapter['gewechat_url'])
adapter['gewechat_file_url'] = f"{parsed_url.scheme}://{parsed_url.hostname}:2532"
await self.ap.platform_cfg.dump_config()