mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-15 19:14:01 +08:00
fix(agent): grant channel owners admin access
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from typing import Any, List, Optional, Tuple, Union
|
||||
|
||||
from app.core.context import Context, MediaInfo
|
||||
from app.helper.agent import register_channel_admin_resolver, resolve_config_principal_ids
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.feishu.feishu import Feishu
|
||||
@@ -8,6 +9,14 @@ from app.schemas import CommingMessage, MessageChannel, MessageResponse, Notific
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
register_channel_admin_resolver(
|
||||
MessageChannel.Feishu,
|
||||
lambda config: resolve_config_principal_ids(
|
||||
config, "FEISHU_ADMINS", "FEISHU_OPEN_ID"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class FeishuModule(_ModuleBase, _MessageBase[Feishu]):
|
||||
def init_module(self) -> None:
|
||||
super().init_service(service_name=Feishu.__name__.lower(), service_type=Feishu)
|
||||
|
||||
@@ -115,12 +115,14 @@ class Feishu:
|
||||
"""判断飞书命令或命令型按钮回调是否应因非管理员身份被拒绝。"""
|
||||
if not self._admins:
|
||||
return False
|
||||
candidates = [
|
||||
str(user_id).strip()
|
||||
for user_id in user_ids
|
||||
if user_id is not None and str(user_id).strip()
|
||||
]
|
||||
return not any(candidate in self._admins for candidate in candidates)
|
||||
return not matches_channel_admin(
|
||||
MessageChannel.Feishu,
|
||||
{
|
||||
"FEISHU_ADMINS": ",".join(self._admins),
|
||||
"FEISHU_OPEN_ID": self._default_open_id,
|
||||
},
|
||||
*user_ids,
|
||||
)
|
||||
|
||||
def _build_api_client(self) -> lark.Client:
|
||||
"""构建飞书 OpenAPI client,用于发送和编辑消息。"""
|
||||
@@ -689,8 +691,11 @@ class Feishu:
|
||||
userid=userid,
|
||||
username=username,
|
||||
is_channel_admin=matches_channel_admin(
|
||||
{"FEISHU_ADMINS": ",".join(self._admins)},
|
||||
"FEISHU_ADMINS",
|
||||
MessageChannel.Feishu,
|
||||
{
|
||||
"FEISHU_ADMINS": ",".join(self._admins),
|
||||
"FEISHU_OPEN_ID": self._default_open_id,
|
||||
},
|
||||
open_id,
|
||||
user_id,
|
||||
),
|
||||
@@ -732,8 +737,11 @@ class Feishu:
|
||||
userid=userid,
|
||||
username=username,
|
||||
is_channel_admin=matches_channel_admin(
|
||||
{"FEISHU_ADMINS": ",".join(self._admins)},
|
||||
"FEISHU_ADMINS",
|
||||
MessageChannel.Feishu,
|
||||
{
|
||||
"FEISHU_ADMINS": ",".join(self._admins),
|
||||
"FEISHU_OPEN_ID": self._default_open_id,
|
||||
},
|
||||
open_id,
|
||||
user_id,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user