fix(notifications): a WhatsApp notice without a contact name uses its own text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-02 20:06:06 +08:00
1 parent 56fb94ab81
commit 72394df1d7
2 files changed
+14 -1

No files matched your search

@@ -42,10 +42,13 @@ public class StaffNotifier {
return;
}
try {
boolean named = contactName != null && !contactName.isBlank();
Map<String, Object> params = new LinkedHashMap<>();
if (named) {
params.put("name", contactName);
}
Map<String, Object> message = new LinkedHashMap<>();
message.put("code", "NoticeWhatsappBody");
message.put("code", named ? "NoticeWhatsappBody" : "NoticeWhatsappBodyNoName");
message.put("params", params);
Map<String, Object> row = new LinkedHashMap<>();
row.put("receiver", String.valueOf(c.ownerUserId));
@@ -45,6 +45,16 @@ class StaffNotifierTest {
server.verify();
}
@Test
void withoutAContactNameTheBodySaysSoInsteadOfShowingThePhone() {
server.expect(requestTo(URL)).andExpect(content().json("[{\"message\":\"{\\\"code\\\":\\\"NoticeWhatsappBodyNoName\\\",\\\"params\\\":{}}\"}]"))
.andRespond(withSuccess());
notifier.whatsappMessage(chat(7L), " ");
server.verify();
}
@Test
void aChatWithoutAnOwnerNotifiesNobody() {
notifier.whatsappMessage(chat(null), "Aisyah");