Apply validate_profile_image_url to ChannelWebhookForm.profile_image_url (#24370)
This commit is contained in:
1 parent
8b78821ba4
commit
d06e6d6ddc
1 file changed
+10
-1
@@ -4,6 +4,8 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from open_webui.utils.validate import validate_profile_image_url
|
||||||
|
|
||||||
from sqlalchemy import select, delete, update, func, case, or_, and_
|
from sqlalchemy import select, delete, update, func, case, or_, and_
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from open_webui.internal.db import Base, JSONField, get_async_db_context
|
from open_webui.internal.db import Base, JSONField, get_async_db_context
|
||||||
@@ -13,7 +15,7 @@ from open_webui.models.access_grants import (
|
|||||||
AccessGrants,
|
AccessGrants,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||||
from sqlalchemy.dialects.postgresql import JSONB
|
from sqlalchemy.dialects.postgresql import JSONB
|
||||||
|
|
||||||
|
|
||||||
@@ -244,6 +246,13 @@ class ChannelWebhookForm(BaseModel):
|
|||||||
name: str
|
name: str
|
||||||
profile_image_url: Optional[str] = None
|
profile_image_url: Optional[str] = None
|
||||||
|
|
||||||
|
@field_validator('profile_image_url', mode='before')
|
||||||
|
@classmethod
|
||||||
|
def check_profile_image_url(cls, v: Optional[str]) -> Optional[str]:
|
||||||
|
if v is None:
|
||||||
|
return v
|
||||||
|
return validate_profile_image_url(v)
|
||||||
|
|
||||||
|
|
||||||
class ChannelTable:
|
class ChannelTable:
|
||||||
async def _get_access_grants(self, channel_id: str, db: Optional[AsyncSession] = None) -> list[AccessGrantModel]:
|
async def _get_access_grants(self, channel_id: str, db: Optional[AsyncSession] = None) -> list[AccessGrantModel]:
|
||||||
|
|||||||
Reference in new issue
Block a user