diff --git a/tests/integration_test.go b/tests/integration_test.go index 7e9987815..8b7436642 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -200,14 +200,14 @@ func TestSendSMS_RateLimit(t *testing.T) { assert.GreaterOrEqual(t, gapMs, int64(5500), "rate limit gap should be >= 5500ms (6s minus timing tolerance), got %dms", gapMs) fireEvent(ctx, t, phone.PhoneAPIKey, msgID1, "SENT") - pollMessageStatus(ctx, t, msgID1, "sent", 15*time.Second) + pollMessageStatus(ctx, t, msgID1, "sent", 30*time.Second) fireEvent(ctx, t, phone.PhoneAPIKey, msgID2, "SENT") - pollMessageStatus(ctx, t, msgID2, "sent", 15*time.Second) + pollMessageStatus(ctx, t, msgID2, "sent", 30*time.Second) fireEvent(ctx, t, phone.PhoneAPIKey, msgID1, "DELIVERED") fireEvent(ctx, t, phone.PhoneAPIKey, msgID2, "DELIVERED") - msg1 := pollMessageStatus(ctx, t, msgID1, "delivered", 15*time.Second) - msg2 := pollMessageStatus(ctx, t, msgID2, "delivered", 15*time.Second) + msg1 := pollMessageStatus(ctx, t, msgID1, "delivered", 30*time.Second) + msg2 := pollMessageStatus(ctx, t, msgID2, "delivered", 30*time.Second) assert.Equal(t, "delivered", msg1.Status) assert.Equal(t, "delivered", msg2.Status) diff --git a/web/app/components/MessageThread.vue b/web/app/components/MessageThread.vue index 93c77324d..2a699408a 100644 --- a/web/app/components/MessageThread.vue +++ b/web/app/components/MessageThread.vue @@ -8,6 +8,10 @@ import { mdiAccount, } from '@mdi/js' import type { EntitiesMessageThread } from '~~/shared/types/api' +import { + isUrlNotificationToken, + formatWhatsappText, +} from '~/utils/whatsapp-format' const threadsStore = useThreadsStore() const phonesStore = usePhonesStore() @@ -45,6 +49,19 @@ function onInstallApp() { }) } +function isWhatsappFormatted(thread: EntitiesMessageThread): boolean { + const phone = phonesStore.phones.find((x) => x.phone_number === thread.owner) + return isUrlNotificationToken(phone?.fcm_token) +} + +function threadPreviewHtml(thread: EntitiesMessageThread): string { + // Links are unwrapped because the preview sits inside a router link. + return formatWhatsappText(thread.last_message_content ?? '').replace( + /]*>(.*?)<\/a>/g, + '$1', + ) +} + function threadContactName(thread: EntitiesMessageThread): string { return thread.contact_details?.name?.trim() ?? '' } @@ -160,7 +177,13 @@ function threadAvatarInitial(thread: EntitiesMessageThread): string { }" style="max-width: 250px" > - {{ thread.last_message_content }} + + + +