diff --git a/api/apps/restful_apis/chat_channel_api.py b/api/apps/restful_apis/chat_channel_api.py index 5c41a47508..8dd6bae799 100644 --- a/api/apps/restful_apis/chat_channel_api.py +++ b/api/apps/restful_apis/chat_channel_api.py @@ -43,8 +43,7 @@ async def create_chat_channel(): "name": req["name"], "channel": req["channel"], "config": req["config"], - "dialog_id": req.get("dialog_id") or None, - "status": "1", + "dialog_id": req.get("dialog_id") or None } ChatChannelService.insert(**channel) @@ -97,7 +96,7 @@ async def update_chat_channel(channel_id): if dia.tenant_id != conn.tenant_id: return _chat_channel_auth_error(channel_id, current_user.id) - update_fields = {fld: req[fld] for fld in ["name", "config", "dialog_id", "status"] if fld in req} + update_fields = {fld: req[fld] for fld in ["name", "config", "dialog_id"] if fld in req} if update_fields: ChatChannelService.update_by_id(channel_id, update_fields) diff --git a/api/db/db_models.py b/api/db/db_models.py index e274d1157d..8acf794739 100644 --- a/api/db/db_models.py +++ b/api/db/db_models.py @@ -1254,7 +1254,7 @@ class ChatChannel(DataBaseModel): channel = CharField(max_length=128, null=False, help_text="Chat channel type", index=True) config = JSONField(null=False, default={}, help_text="Channel credential & settings") dialog_id = CharField(max_length=32, null=True, default=None, help_text="connected dialog id", index=True) - status = CharField(max_length=16, null=True, help_text="1: valid, 0: invalid", default="1", index=True) + status = IntegerField(default=1, index=True) def __str__(self): return self.name @@ -1777,6 +1777,7 @@ def migrate_db(): alter_db_column_type(migrator, "document", "size", BigIntegerField(default=0, index=True)) alter_db_column_type(migrator, "file", "size", BigIntegerField(default=0, index=True)) alter_db_add_column(migrator, "tenant", "ocr_id", CharField(max_length=128, null=True, help_text="default ocr model ID", index=True)) + alter_db_column_type(migrator, "chat_channel", "status", IntegerField(default=1, index=True)) # Drop both the explicit "idx_*" name from later migrations AND the # Peewee-auto-derived "__" name from the # original TenantModelInstance definition (commit dc4b82523). Databases diff --git a/api/db/services/chat_channel_service.py b/api/db/services/chat_channel_service.py index 0e783ce2fa..8b64df66fc 100644 --- a/api/db/services/chat_channel_service.py +++ b/api/db/services/chat_channel_service.py @@ -54,7 +54,7 @@ class ChatChannelService(CommonService): @DB.connection_context() def list_active(cls): """Return all enabled chat channel bots across tenants (with credentials).""" - return list(cls.model.select().where(cls.model.status == "1")) + return list(cls.model.select().where(cls.model.status == 1)) @classmethod @DB.connection_context()