mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 07:42:39 +02:00
refactor: Remove deprecated create_connector_indexed_notification method and add notification types
- Removed the deprecated create_connector_indexed_notification method from NotificationService. - Introduced new notification types and schemas in notification.types.ts to standardize notification handling. - Updated useNotifications hook to utilize the new notification type definitions.
This commit is contained in:
parent
e38e6d90e0
commit
59a8ef5d64
5 changed files with 115 additions and 60 deletions
|
|
@ -505,49 +505,3 @@ class NotificationService:
|
|||
},
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
async def create_connector_indexed_notification(
|
||||
session: AsyncSession,
|
||||
user_id: UUID,
|
||||
connector_name: str,
|
||||
connector_type: str,
|
||||
status: str,
|
||||
search_space_id: int,
|
||||
indexed_count: int | None = None,
|
||||
) -> Notification:
|
||||
"""
|
||||
Create notification when connector indexing completes.
|
||||
DEPRECATED: Use NotificationService.connector_indexing methods instead.
|
||||
|
||||
Args:
|
||||
session: Database session
|
||||
user_id: User to notify
|
||||
connector_name: Name of the connector
|
||||
connector_type: Type of connector
|
||||
status: Indexing status ('SUCCESS', 'FAILED')
|
||||
search_space_id: Search space ID
|
||||
indexed_count: Number of items indexed (optional)
|
||||
|
||||
Returns:
|
||||
Notification: The created notification
|
||||
"""
|
||||
status_lower = status.lower()
|
||||
title = f"Connector indexed: {connector_name}"
|
||||
message = f'Your connector "{connector_name}" has finished indexing ({status_lower}).'
|
||||
if indexed_count is not None:
|
||||
message += f" {indexed_count} items indexed."
|
||||
|
||||
return await NotificationService.create_notification(
|
||||
session=session,
|
||||
user_id=user_id,
|
||||
notification_type="connector_indexed",
|
||||
title=title,
|
||||
message=message,
|
||||
search_space_id=search_space_id,
|
||||
notification_metadata={
|
||||
"connector_name": connector_name,
|
||||
"connector_type": connector_type,
|
||||
"status": status,
|
||||
"indexed_count": indexed_count,
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue