import uuid from fastapi import HTTPException, status def UserNotFound(user_id: uuid.UUID | None = None) -> HTTPException: if user_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'User not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'User {user_id} not found') def UserByUsernameNotFound(username: str) -> HTTPException: return HTTPException(status.HTTP_404_NOT_FOUND, f'User @{username} not found') def LoginTokenNotFound() -> HTTPException: return HTTPException(status.HTTP_404_NOT_FOUND, 'Login token not found') def LoginTokenExpired() -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, 'Login token has expired') def LoginTokenAlreadyUsed() -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, 'Login token has already been used') def ChannelNotFound(channel_id: uuid.UUID | None = None) -> HTTPException: if channel_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Channel not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Channel {channel_id} not found') def TelegramChannelNotFound(username: str) -> HTTPException: return HTTPException( status.HTTP_404_NOT_FOUND, f'Telegram channel @{username} not found or is not a public channel' ) def ProjectNotFound(project_id: uuid.UUID | None = None) -> HTTPException: if project_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Project not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Project {project_id} not found') def ProjectChannelConflict() -> HTTPException: return HTTPException(status.HTTP_409_CONFLICT, 'Project channel already exists in target workspace') def PlacementNotFound(placement_id: uuid.UUID | None = None) -> HTTPException: if placement_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Placement not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Placement {placement_id} not found') def PlacementPostNotFound(placement_post_id: uuid.UUID | None = None) -> HTTPException: if placement_post_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'PlacementPost not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'PlacementPost {placement_post_id} not found') def PlacementHasPosts(placement_id: uuid.UUID) -> HTTPException: return HTTPException( status.HTTP_400_BAD_REQUEST, f'Placement {placement_id} has placement_posts and cannot remove creative', ) def ChannelAlreadyExists(telegram_id: int) -> HTTPException: return HTTPException(status.HTTP_409_CONFLICT, f'Channel {telegram_id} already exists in the system') def ChannelNoAdminRights() -> HTTPException: return HTTPException( status.HTTP_403_FORBIDDEN, 'Bot must be added as administrator with invite link creation rights' ) def CreativeNotFound(creative_id: uuid.UUID | None = None) -> HTTPException: if creative_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Creative not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Creative {creative_id} not found') def CreativeInviteLinkNotFound() -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, 'Creative text must contain one invite link (t.me/+xxx)') def CreativeMultipleInviteLinks() -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, 'Creative text must contain only one invite link') def CreativeMediaTooLarge(max_bytes: int) -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, f'Creative media is too large (max {max_bytes} bytes)') def CreativeInUse(creative_id: uuid.UUID) -> HTTPException: return HTTPException( status.HTTP_400_BAD_REQUEST, f'Creative {creative_id} is used in active placement_posts and cannot be deleted', ) def WorkspaceNotFound(workspace_id: uuid.UUID | None = None) -> HTTPException: if workspace_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Workspace not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Workspace {workspace_id} not found') def WorkspaceAccessDenied(workspace_id: uuid.UUID | None = None) -> HTTPException: if workspace_id is None: return HTTPException(status.HTTP_403_FORBIDDEN, 'Workspace access denied') return HTTPException(status.HTTP_403_FORBIDDEN, f'Workspace {workspace_id} access denied') def WorkspaceInviteNotFound(invite_id: uuid.UUID | None = None) -> HTTPException: if invite_id is None: return HTTPException(status.HTTP_404_NOT_FOUND, 'Workspace invite not found') return HTTPException(status.HTTP_404_NOT_FOUND, f'Workspace invite {invite_id} not found') def WorkspaceInviteAlreadyExists() -> HTTPException: return HTTPException(status.HTTP_409_CONFLICT, 'Workspace invite already exists for this user') def WorkspaceInviteAlreadyProcessed() -> HTTPException: return HTTPException(status.HTTP_400_BAD_REQUEST, 'Workspace invite has already been processed') def WorkspaceMemberAlreadyExists() -> HTTPException: return HTTPException(status.HTTP_409_CONFLICT, 'User is already a workspace member')