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 Link from 'next/link';
|
||||||
import { notificationsApiService, type AppNotification } from '@/services/notifications-api.service';
|
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']) {
|
function getNotificationIcon(type: AppNotification['type']) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'connection':
|
case 'connection':
|
||||||
@@ -221,7 +232,7 @@ export default function AgentNotificationsPage() {
|
|||||||
{notification.title}
|
{notification.title}
|
||||||
</p>
|
</p>
|
||||||
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
||||||
{notification.description}
|
{formatDescription(notification.description)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="font-serif text-[12px] text-[#00293D]/50 flex-shrink-0">
|
<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 Link from 'next/link';
|
||||||
import { notificationsApiService, type AppNotification } from '@/services/notifications-api.service';
|
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']) {
|
function getNotificationIcon(type: AppNotification['type']) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'connection':
|
case 'connection':
|
||||||
@@ -213,7 +224,7 @@ export default function UserNotificationsPage() {
|
|||||||
{notification.title}
|
{notification.title}
|
||||||
</p>
|
</p>
|
||||||
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
<p className="font-serif text-[14px] text-[#00293D]/60 mt-1">
|
||||||
{notification.description}
|
{formatDescription(notification.description)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="font-serif text-[12px] text-[#00293D]/50 flex-shrink-0">
|
<span className="font-serif text-[12px] text-[#00293D]/50 flex-shrink-0">
|
||||||
|
|||||||
Reference in New Issue
Block a user