feat(messages): use branded email template for message notifications
This commit is contained in:
parent
ce4d659279
commit
c926290a72
@ -15,7 +15,7 @@ from database import SessionLocal, User, Company, UserCompanyPermissions, Privat
|
||||
from extensions import limiter
|
||||
from utils.helpers import sanitize_input
|
||||
from utils.decorators import member_required
|
||||
from email_service import send_email
|
||||
from email_service import send_email, build_message_notification_email
|
||||
|
||||
|
||||
# ============================================================
|
||||
@ -220,22 +220,21 @@ def messages_send():
|
||||
try:
|
||||
message_url = url_for('.messages_view', message_id=message.id, _external=True)
|
||||
settings_url = url_for('auth.konto_prywatnosc', _external=True)
|
||||
subject_line = f'Nowa wiadomość od {sender_name} — Norda Biznes'
|
||||
sender_name = current_user.name or current_user.email.split('@')[0]
|
||||
preview = (content[:200] + '...') if len(content) > 200 else content
|
||||
email_html = f'''
|
||||
<h2>Masz nową wiadomość</h2>
|
||||
<p><strong>{sender_name}</strong> wysłał(a) Ci wiadomość na portalu Norda Biznes.</p>
|
||||
{f'<p><strong>Temat:</strong> {subject}</p>' if subject else ''}
|
||||
<div style="background: #f8fafc; border-left: 4px solid #3b82f6; padding: 16px; margin: 16px 0; border-radius: 4px;">
|
||||
<p style="margin: 0; color: #374151;">{preview}</p>
|
||||
</div>
|
||||
<p><a href="{message_url}" style="display: inline-block; padding: 10px 24px; background: #3b82f6; color: white; text-decoration: none; border-radius: 6px; font-weight: 500;">Odczytaj wiadomość</a></p>
|
||||
<p style="font-size: 12px; color: #9ca3af; margin-top: 24px;">Możesz wyłączyć powiadomienia e-mail w <a href="{settings_url}">ustawieniach prywatności</a>.</p>
|
||||
'''
|
||||
subject_line = f'Nowa wiadomość od {sender_name} — Norda Biznes'
|
||||
|
||||
email_html, email_text = build_message_notification_email(
|
||||
sender_name=sender_name,
|
||||
subject=subject,
|
||||
content_preview=preview,
|
||||
message_url=message_url,
|
||||
settings_url=settings_url
|
||||
)
|
||||
send_email(
|
||||
to=[recipient.email],
|
||||
subject=subject_line,
|
||||
body_text=f'{sender_name} wysłał(a) Ci wiadomość na portalu Norda Biznes. Odczytaj: {message_url}',
|
||||
body_text=email_text,
|
||||
body_html=email_html,
|
||||
email_type='message_notification',
|
||||
user_id=recipient.id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user