From 10002c505d8576dac1c05819b60f9bb63a65143b Mon Sep 17 00:00:00 2001 From: Quishot WADEV <70950705+Darker935@users.noreply.github.com> Date: Sun, 19 May 2024 21:53:43 -0300 Subject: [PATCH] Changes on sendMessage structure --- src/main/java/it/auties/whatsapp/api/Whatsapp.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/auties/whatsapp/api/Whatsapp.java b/src/main/java/it/auties/whatsapp/api/Whatsapp.java index b8c05869..bc3c9de1 100644 --- a/src/main/java/it/auties/whatsapp/api/Whatsapp.java +++ b/src/main/java/it/auties/whatsapp/api/Whatsapp.java @@ -503,8 +503,7 @@ public CompletableFuture sendNewsletterMessage(JidProvide * @return a CompletableFuture */ public CompletableFuture sendMessage(JidProvider chat, ContextualMessage message, MessageInfo quotedMessage) { - var contextInfo = ContextInfo.of(quotedMessage); - message.setContextInfo(contextInfo); + message.contextInfo().ifPresentOrElse(contextInfo -> message.setContextInfo(ContextInfo.of(contextInfo, quotedMessage)), () -> message.setContextInfo(ContextInfo.of(quotedMessage))); return sendMessage(chat, MessageContainer.of(message)); } @@ -517,8 +516,7 @@ public CompletableFuture sendMessage(JidProvider chat, Co * @return a CompletableFuture */ public CompletableFuture sendChatMessage(JidProvider chat, ContextualMessage message, MessageInfo quotedMessage) { - var contextInfo = ContextInfo.of(quotedMessage); - message.setContextInfo(contextInfo); + message.contextInfo().ifPresentOrElse(contextInfo -> message.setContextInfo(ContextInfo.of(contextInfo, quotedMessage)), () -> message.setContextInfo(ContextInfo.of(quotedMessage))); return sendChatMessage(chat, MessageContainer.of(message)); } @@ -532,8 +530,7 @@ public CompletableFuture sendChatMessage(JidProvider chat, Cont * @return a CompletableFuture */ public CompletableFuture sendNewsletterMessage(JidProvider chat, ContextualMessage message, MessageInfo quotedMessage) { - var contextInfo = ContextInfo.of(quotedMessage); - message.setContextInfo(contextInfo); + message.contextInfo().ifPresentOrElse(contextInfo -> message.setContextInfo(ContextInfo.of(contextInfo, quotedMessage)), () -> message.setContextInfo(ContextInfo.of(quotedMessage))); return sendNewsletterMessage(chat, MessageContainer.of(message)); }