Add default slack bot disabling (#3935)

* add slack bot disabling

* update

* k

* minor
This commit is contained in:
pablonyx
2025-02-17 20:08:33 -08:00
committed by GitHub
parent e3bc7cc747
commit 045a41d929
10 changed files with 43 additions and 3 deletions

View File

@@ -1742,6 +1742,7 @@ class ChannelConfig(TypedDict):
# If empty list, follow up with no tags
follow_up_tags: NotRequired[list[str]]
show_continue_in_web_ui: NotRequired[bool] # defaults to False
disabled: NotRequired[bool] # defaults to False
class SlackChannelConfig(Base):
@@ -1765,6 +1766,7 @@ class SlackChannelConfig(Base):
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
persona: Mapped[Persona | None] = relationship("Persona")
slack_bot: Mapped["SlackBot"] = relationship(
"SlackBot",
back_populates="slack_channel_configs",

View File

@@ -151,6 +151,7 @@ def update_slack_channel_config(
channel_config: ChannelConfig,
standard_answer_category_ids: list[int],
enable_auto_filters: bool,
disabled: bool,
) -> SlackChannelConfig:
slack_channel_config = db_session.scalar(
select(SlackChannelConfig).where(

View File

@@ -180,6 +180,13 @@ def handle_message(
)
return False
if slack_channel_config.channel_config.get("disabled") and not bypass_filters:
logger.info(
"Skipping message since the channel is configured such that "
"OnyxBot is disabled"
)
return False
# List of user id to send message to, if None, send to everyone in channel
send_to: list[str] | None = None
missing_users: list[str] | None = None

View File

@@ -806,6 +806,7 @@ def process_message(
and slack_channel_config.channel_config.get("follow_up_tags")
is not None
)
feedback_reminder_id = schedule_feedback_reminder(
details=details, client=client.web_client, include_followup=follow_up
)

View File

@@ -187,6 +187,7 @@ class SlackChannelConfigCreationRequest(BaseModel):
response_type: SlackBotResponseType
# XXX this is going away soon
standard_answer_categories: list[int] = Field(default_factory=list)
disabled: bool = False
@field_validator("answer_filters", mode="before")
@classmethod

View File

@@ -93,6 +93,8 @@ def _form_channel_config(
"respond_to_bots"
] = slack_channel_config_creation_request.respond_to_bots
channel_config["disabled"] = slack_channel_config_creation_request.disabled
return channel_config
@@ -194,6 +196,7 @@ def patch_slack_channel_config(
channel_config=channel_config,
standard_answer_category_ids=slack_channel_config_creation_request.standard_answer_categories,
enable_auto_filters=slack_channel_config_creation_request.enable_auto_filters,
disabled=slack_channel_config_creation_request.disabled,
)
return SlackChannelConfig.from_model(slack_channel_config_model)