Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): mark a channel post's media as unavailable
Yudhi Armyndharis7f6dc7b11571
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 9b143e772..2ee7fd9cc 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -1487,7 +1487,8 @@object-fit: cover;}-/* Status viewer: shown in place of the image while a status media blob fails to load. */+/* Shown in place of media that cannot be shown: a status media blob that fails to load, or a+ channel post whose media has no URL. */.chats-page .status-media-placeholder {display: block;font-size: 0.85rem;diff --git a/dashboard/src/pages/Chats.test.ts b/dashboard/src/pages/Chats.test.tsindex 1bd91e350..ad2c0ff8d 100644--- a/dashboard/src/pages/Chats.test.ts+++ b/dashboard/src/pages/Chats.test.ts@@ -2196,6 +2196,26 @@ test('the media viewer saves an image under its file name, not its caption', asyassert.equal(links[0].download, 'photo.png');});+// whatsapp-web.js reports that a channel post has media but gives no URL for it.+test('a channel post with media and no URL says the media is unavailable', async () => {+ const { screen, fireEvent, within, waitFor } = rtl;+ engineType = 'whatsapp-web.js';+ window.sessionStorage.setItem('openwa_engine_type', engineType);+ channels = [{ id: '120363000000000001@newsletter', name: 'News' }];+ channelPosts = [{ id: 'post-1', body: '', timestamp: 1_700_000_000, hasMedia: true }];+ const { container } = renderChats();+ await screen.findByText('Alice');++ fireEvent.click(screen.getByRole('tab', { name: 'Channels' }));+ fireEvent.click(await screen.findByText('News'));+ const bubble = await waitFor(() => {+ const found = container.querySelector('.channel-room .message-bubble');+ assert.ok(found, 'the post did not render');+ return found;+ });+ assert.ok(within(bubble as HTMLElement).queryByText('Media unavailable'), 'the media post rendered empty');+});+test('a channel post or status caption carrying mention delimiters renders them as nothing, not as a mention', async () => {const { screen, fireEvent, waitFor } = rtl;// Only resolveMentions may place the delimiters; raw text carrying them is stripped before render.diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsxindex 7eaeb1447..8566a2ece 100644--- a/dashboard/src/pages/Chats.tsx+++ b/dashboard/src/pages/Chats.tsx@@ -1180,7 +1180,13 @@ export function Chats() {) : ((channelMessages.data ?? []).map(m => (<div key={m.id} className="message-bubble incoming">- {m.hasMedia && m.mediaUrl && <img className="channel-media" src={m.mediaUrl} alt="" />}+ {/* whatsapp-web.js flags a post's media but gives no URL for it. */}+ {m.hasMedia &&+ (m.mediaUrl ? (+ <img className="channel-media" src={m.mediaUrl} alt="" />+ ) : (+ <span className="status-media-placeholder">{t('chats.status.mediaUnavailable')}</span>+ ))}{m.body && <MessageBody text={stripMentionDelimiters(m.body)} className="message-text" />}<span className="message-time">{formatChatTime(m.timestamp)}</span></div>