mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
refactor: use shared truncate in mention and reply handlers
This commit is contained in:
parent
778ab9b254
commit
7a6fcfb29b
2 changed files with 4 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.notifications.persistence import Notification
|
from app.notifications.persistence import Notification
|
||||||
from app.notifications.service.base import BaseNotificationHandler
|
from app.notifications.service.base import BaseNotificationHandler
|
||||||
|
from app.notifications.service.messages.text import truncate
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ class CommentReplyNotificationHandler(BaseNotificationHandler):
|
||||||
return existing
|
return existing
|
||||||
|
|
||||||
title = f"{author_name} replied in a thread"
|
title = f"{author_name} replied in a thread"
|
||||||
message = content_preview[:100] + ("..." if len(content_preview) > 100 else "")
|
message = truncate(content_preview, 100)
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
"reply_id": reply_id,
|
"reply_id": reply_id,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.notifications.persistence import Notification
|
from app.notifications.persistence import Notification
|
||||||
from app.notifications.service.base import BaseNotificationHandler
|
from app.notifications.service.base import BaseNotificationHandler
|
||||||
|
from app.notifications.service.messages.text import truncate
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ class MentionNotificationHandler(BaseNotificationHandler):
|
||||||
return existing
|
return existing
|
||||||
|
|
||||||
title = f"{author_name} mentioned you"
|
title = f"{author_name} mentioned you"
|
||||||
message = content_preview[:100] + ("..." if len(content_preview) > 100 else "")
|
message = truncate(content_preview, 100)
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
"mention_id": mention_id,
|
"mention_id": mention_id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue