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:
1 parent
56fb94ab81
commit
72394df1d7
2 files changed
+15
-2
No files matched your search
+5
-2
@@ -42,10 +42,13 @@ public class StaffNotifier {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
boolean named = contactName != null && !contactName.isBlank();
|
||||
Map<String, Object> params = new LinkedHashMap<>();
|
||||
params.put("name", contactName);
|
||||
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));
|
||||
|
||||
+10
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user