fix(#283): summarise the same GIF set the chat renders

formatNotificationText used GifHelper.parseGif (Giphy only) while the chat
renders via resolveGifUrl (Giphy + allowlisted Tenor CDN). An allowlisted
Tenor GIF therefore rendered inline but still dumped a raw URL into the
notification tray.

Point both at resolveGifUrl so the tray summarises exactly the set the chat
displays. Off-allowlist URLs still pass through as plain text, pinned by test.

This is the same duplicate-detection drift that caused #284; closing it at the
source rather than shipping a known inconsistency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pull/332/head
Strycher 2 days ago
parent 5b23549054
commit b4fe9c145b

@ -155,7 +155,9 @@ class NotificationService {
if (reaction != null) {
return 'Reacted ${reaction.emoji}';
}
if (GifHelper.parseGif(trimmed) != null) {
// resolveGifUrl, not parseGif: the tray must summarise exactly the set the
// chat renders inline, or an allowlisted Tenor GIF shows as a raw URL. (#283)
if (GifHelper.resolveGifUrl(trimmed) != null) {
return 'Sent a GIF';
}
return text;

@ -64,4 +64,33 @@ void main() {
);
});
});
group('allowlisted media URLs summarise too (#283 consistency)', () {
test('a pasted i.giphy.com link summarises', () {
expect(
NotificationService.formatNotificationText(
'https://i.giphy.com/$gifId.webp',
),
'Sent a GIF',
);
});
test('a pasted Tenor CDN link summarises', () {
expect(
NotificationService.formatNotificationText(
'https://media.tenor.com/abc123XYZ/happy-dance.gif',
),
'Sent a GIF',
);
});
test('an off-allowlist image URL does NOT summarise', () {
expect(
NotificationService.formatNotificationText(
'https://evil.example.com/tracker.gif',
),
'https://evil.example.com/tracker.gif',
);
});
});
}

Loading…
Cancel
Save

Powered by TurnKey Linux.