refactor: use shared truncate in mention and reply handlers

This commit is contained in:
CREDO23 2026-06-03 21:53:03 +02:00
parent 778ab9b254
commit 7a6fcfb29b
2 changed files with 4 additions and 2 deletions

View file

@ -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,

View file

@ -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,