feat: applied coderabbit suggestions

This commit is contained in:
Muhamad Aji Wibisono 2025-06-02 21:03:50 +07:00
parent afc1100f6d
commit 42cc1b8fbe
5 changed files with 11 additions and 21 deletions

View file

@ -954,7 +954,6 @@ async def index_discord_messages(
return 0, "Discord token not found in connector config"
logger.info(f"Starting Discord indexing for connector {connector_id}")
logger.info(f"discord token is: {discord_token[:4]}... (truncated for security)")
# Initialize Discord client
discord_client = DiscordConnector(token=discord_token)

View file

@ -1026,9 +1026,12 @@ class ConnectorService:
if len(description) == 100:
description += "..."
# For URL, we can use a placeholder or construct a URL to the Discord channel if available
url = ""
if channel_id:
guild_id = metadata.get('guild_id', '')
if guild_id and channel_id:
url = f"https://discord.com/channels/{guild_id}/{channel_id}"
elif channel_id:
# Fallback for DM channels or when guild_id is not available
url = f"https://discord.com/channels/@me/{channel_id}"
source = {

View file

@ -8,7 +8,7 @@ dependencies = [
"alembic>=1.13.0",
"asyncpg>=0.30.0",
"chonkie[all]>=1.0.6",
"discord>=2.3.2",
"discord-py>=2.5.2",
"fastapi>=0.115.8",
"fastapi-users[oauth,sqlalchemy]>=14.0.1",
"firecrawl-py>=1.12.0",

View file

@ -649,18 +649,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/68/69/1bcf70f81de1b4a9f21b3a62ec0c83bdff991c88d6cc2267d02408457e88/dirtyjson-1.0.8-py3-none-any.whl", hash = "sha256:125e27248435a58acace26d5c2c4c11a1c0de0a9c5124c5a94ba78e517d74f53", size = 25197, upload-time = "2022-11-28T23:32:31.219Z" },
]
[[package]]
name = "discord"
version = "2.3.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "discord-py" },
]
sdist = { url = "https://files.pythonhosted.org/packages/7e/9f/0763429949416aeff9c6f33051270831b72e5582273acd28053b9b949462/discord-2.3.2.tar.gz", hash = "sha256:cc1ee2dbe6df218ca51519af355b97e87309f8230f58c7f34885feb8e8a76145", size = 1137, upload-time = "2023-08-10T21:45:07.93Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/2d/38/d91ac49e8169b6c0f724f7aad26704eec07c4ecf31e067ca3d46a87e33d6/discord-2.3.2-py3-none-any.whl", hash = "sha256:d7959418799dd3b1e896685812d880169c193468b061b3431fa2a4664febd3da", size = 1132, upload-time = "2023-08-10T21:45:06.334Z" },
]
[[package]]
name = "discord-py"
version = "2.5.2"
@ -3587,7 +3575,7 @@ dependencies = [
{ name = "alembic" },
{ name = "asyncpg" },
{ name = "chonkie", extra = ["all"] },
{ name = "discord" },
{ name = "discord-py" },
{ name = "fastapi" },
{ name = "fastapi-users", extra = ["oauth", "sqlalchemy"] },
{ name = "firecrawl-py" },
@ -3620,7 +3608,7 @@ requires-dist = [
{ name = "alembic", specifier = ">=1.13.0" },
{ name = "asyncpg", specifier = ">=0.30.0" },
{ name = "chonkie", extras = ["all"], specifier = ">=1.0.6" },
{ name = "discord", specifier = ">=2.3.2" },
{ name = "discord-py", specifier = ">=2.5.2" },
{ name = "fastapi", specifier = ">=0.115.8" },
{ name = "fastapi-users", extras = ["oauth", "sqlalchemy"], specifier = ">=14.0.1" },
{ name = "firecrawl-py", specifier = ">=1.12.0" },

View file

@ -47,9 +47,9 @@ const discordConnectorFormSchema = z.object({
name: z.string().min(3, {
message: "Connector name must be at least 3 characters.",
}),
bot_token: z.string().min(10, {
message: "Discord Bot Token is required and must be valid.",
}),
bot_token: z.string()
.min(50, { message: "Discord Bot Token appears to be too short." })
.regex(/^[A-Za-z0-9._-]+$/, { message: "Discord Bot Token contains invalid characters." }),
});
// Define the type for the form values