feat: sanitize notification descriptions to display link types instead of raw URLs
This commit is contained in:
@@ -5,6 +5,17 @@ import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import { notificationsApiService, type AppNotification } from '@/services/notifications-api.service';
|
||||
|
||||
function formatDescription(description: string): string {
|
||||
const trimmed = description.trim();
|
||||
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
||||
const lower = trimmed.toLowerCase();
|
||||
if (lower.includes('.gif')) return 'Sent a GIF';
|
||||
if (lower.includes('.png') || lower.includes('.jpg') || lower.includes('.jpeg') || lower.includes('.webp')) return 'Sent an image';
|
||||
return 'Sent a link';
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
function getNotificationIcon(type: AppNotification['type']) {
|
||||
switch (type) {
|
||||
case 'connection':
|
||||
@@ -221,7 +232,7 @@ export default function AgentNotificationsPage() {
|
||||
{notification.title}
|
||||
</p>
|
||||
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
||||
{notification.description}
|
||||
{formatDescription(notification.description)}
|
||||
</p>
|
||||
</div>
|
||||
<span className="font-serif text-[12px] text-[#00293D]/50 flex-shrink-0">
|
||||
|
||||
@@ -5,6 +5,17 @@ import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import { notificationsApiService, type AppNotification } from '@/services/notifications-api.service';
|
||||
|
||||
function formatDescription(description: string): string {
|
||||
const trimmed = description.trim();
|
||||
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
||||
const lower = trimmed.toLowerCase();
|
||||
if (lower.includes('.gif')) return 'Sent a GIF';
|
||||
if (lower.includes('.png') || lower.includes('.jpg') || lower.includes('.jpeg') || lower.includes('.webp')) return 'Sent an image';
|
||||
return 'Sent a link';
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
function getNotificationIcon(type: AppNotification['type']) {
|
||||
switch (type) {
|
||||
case 'connection':
|
||||
@@ -213,7 +224,7 @@ export default function UserNotificationsPage() {
|
||||
{notification.title}
|
||||
</p>
|
||||
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
||||
{notification.description}
|
||||
{formatDescription(notification.description)}
|
||||
</p>
|
||||
</div>
|
||||
<span className="font-serif text-[12px] text-[#00293D]/50 flex-shrink-0">
|
||||
|
||||
Reference in New Issue
Block a user