Commit 1c7dfc0
committed
feat(text): suporte a linkPreviewOverride (fork v2.3.7-lp)
Contorna a lib de link-preview do Baileys que falha com shorteners
(amzn.to, bit.ly, etc) permitindo o caller pre-montar o preview
(title, description, canonicalUrl, thumbnail).
Se data.linkPreviewOverride vier no body de POST /message/sendText,
textMessage monta um WAUrlInfo pronto e entrega ao sock.sendMessage
como linkPreview objeto (em vez de boolean), fazendo Baileys renderizar
extendedTextMessage com card preview -- igual WhatsApp oficial.
Preserva a URL original do texto (nao altera o que o usuario ve) --
canonicalUrl eh so o campo interno do card do WhatsApp.
Arquivos:
- src/api/dto/sendMessage.dto.ts: LinkPreviewOverride + Metadata
- src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:
textMessage monta WAUrlInfo; sendMessageWithTyping prioriza override
- src/validate/message.schema.ts: linkPreviewOverride no schema do text
Uso (body POST /message/sendText/:instance):
{
"number": "553196018045",
"text": "Oferta: https://amzn.to/ABC",
"linkPreviewOverride": {
"title": "Produto na Amazon",
"description": "Descricao og:description",
"canonicalUrl": "https://www.amazon.com.br/dp/XXX",
"thumbnailUrl": "https://.../og-image.jpg"
}
}
Mantem compatibilidade: se linkPreviewOverride ausente, comportamento
original (Baileys decide via linkPreview boolean).1 parent cd800f2 commit 1c7dfc0
4 files changed
Lines changed: 65 additions & 27 deletions
File tree
- src
- api
- dto
- integrations/channel/whatsapp
- validate
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
8 | 25 | | |
9 | 26 | | |
10 | 27 | | |
11 | 28 | | |
12 | 29 | | |
| 30 | + | |
13 | 31 | | |
14 | 32 | | |
15 | 33 | | |
| |||
41 | 59 | | |
42 | 60 | | |
43 | 61 | | |
| 62 | + | |
| 63 | + | |
44 | 64 | | |
45 | 65 | | |
46 | 66 | | |
| |||
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2338 | 2338 | | |
2339 | 2339 | | |
2340 | 2340 | | |
2341 | | - | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
2342 | 2349 | | |
2343 | 2350 | | |
2344 | 2351 | | |
| |||
2633 | 2640 | | |
2634 | 2641 | | |
2635 | 2642 | | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
2636 | 2668 | | |
2637 | 2669 | | |
2638 | 2670 | | |
| |||
2641 | 2673 | | |
2642 | 2674 | | |
2643 | 2675 | | |
| 2676 | + | |
2644 | 2677 | | |
2645 | 2678 | | |
2646 | 2679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
| |||
0 commit comments