Skip to content

feat(whatsapp): support groups api payloads#1655

Merged
nbartels merged 2 commits into
devfrom
feat/whatsapp-groups-api
Apr 19, 2026
Merged

feat(whatsapp): support groups api payloads#1655
nbartels merged 2 commits into
devfrom
feat/whatsapp-groups-api

Conversation

@nbartels

@nbartels nbartels commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add WhatsApp Groups API payload models for group details, participants, and join requests including BSUID, parent BSUID, and username fields
  • add group_participants_update webhook support with ChangeValueFactory mapping and resource-based webhook tests
  • extend group-related message and send-response coverage with recipient_type and group-id response fixtures

Verification

  • mvn -Dtest=GroupApiJsonTest,SendMessageJsonTest,WebhookWhatsappTest,WebhookWhatsappGroupsTest test
  • mvn test

Summary by CodeRabbit

  • New Features

    • Added support for WhatsApp group management, including group participant updates, group information retrieval, and join request handling.
    • Added group messaging capabilities with recipient type tracking.
  • Tests

    • Added comprehensive test coverage for group webhook events, group metadata APIs, and group messaging responses.
    • Expanded existing tests to validate group-related fields.

@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0bf794bc-0b38-428f-b6c6-c8fcd26a8e4d

📥 Commits

Reviewing files that changed from the base of the PR and between 9ce14a1 and 445a3a1.

📒 Files selected for processing (1)
  • src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java

📝 Walkthrough

Walkthrough

The changes add comprehensive WhatsApp group participant webhook support, including a new GroupParticipantsUpdateValue webhook payload class, group-related domain types (GroupParticipant, GroupJoinRequest, GroupInfo), factory registration for the GROUP_PARTICIPANTS_UPDATE_WHATSAPP webhook event, a recipientType field to Status, and extensive test coverage with JSON fixtures.

Changes

Cohort / File(s) Summary
Webhook Group Event Support
src/main/lombok/com/restfb/types/webhook/ChangeValueFactory.java, src/main/lombok/com/restfb/types/webhook/whatsapp/GroupParticipantsUpdateValue.java
Added GROUP_PARTICIPANTS_UPDATE_WHATSAPP enum entry to factory and new GroupParticipantsUpdateValue class extending AbstractWhatsappBaseChangeValue with nested GroupEvent type to model group participant update webhook payloads, including participant additions, removals, and join request lifecycle events.
WhatsApp Group API Types
src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupParticipant.java, src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupJoinRequest.java, src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupInfo.java
Added three new group-related data types: GroupParticipant (base model with wa\_id, user\_id, parent\_user\_id, username), GroupJoinRequest extending GroupParticipant with join\_request\_id and creation\_timestamp, and GroupInfo aggregating group metadata with participant lists.
Status Enhancement
src/main/lombok/com/restfb/types/whatsapp/platform/Status.java
Added recipientType field with @Facebook("recipient_type") annotation to distinguish message statuses by recipient type (e.g., "group").
Webhook Group Tests
src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java, src/test/resources/json/whatsapp/webhook-group-participants-update.json
New test class validating deserialization of WhatsApp group participant update webhook events with comprehensive assertions on group events, participant lists, and join request details, paired with multi-event JSON fixture.
Group API Tests
src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java, src/test/resources/json/whatsapp/group-info.json, src/test/resources/json/whatsapp/group-join-requests.json
New test class verifying JSON deserialization for GroupInfo and GroupJoinRequest paginated responses, with corresponding fixture files.
Existing Test Updates
src/test/java/com/restfb/types/WebhookWhatsappTest.java, src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java, src/test/resources/json/whatsapp/webhook-incoming-message-status-group-bsuid.json, src/test/resources/json/whatsapp/message-response-group.json
Enhanced existing webhook test with additional contact field assertions, added group message response test, and updated fixtures to include contacts array with wa\_id/user\_id fields and recipient_type in status events.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

Hops of joy through group events flow 🐰
Participants dancing high and low
Join requests waltz and fade away
New webhooks guide the RestFB way
Rabbit rejoices—groups are here to stay! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding WhatsApp Groups API payload support. It aligns with the substantial additions of GroupInfo, GroupParticipant, GroupJoinRequest classes and group_participants_update webhook support.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/whatsapp-groups-api

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java (1)

77-78: Consider asserting the actual timestamp value.

The test only checks assertNotNull(firstRequest.getCreationTimestamp()) but doesn't verify the parsed value. Given the fixture has "creation_timestamp": "1751210000", asserting the expected Date value would strengthen coverage for epoch-to-Date conversion.

🔧 Suggested enhancement
+    // 1751210000 seconds since epoch = specific date
+    assertEquals(1751210000L * 1000L, firstRequest.getCreationTimestamp().getTime());
     assertNotNull(firstRequest.getCreationTimestamp());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java`
around lines 77 - 78, The test only checks non-null for creation timestamp;
update the GroupApiJsonTest to assert the exact parsed Date value from the
fixture by converting the fixture epoch string "1751210000" to the expected Date
and comparing it to firstRequest.getCreationTimestamp() (use the same
epoch-to-milliseconds conversion used in production) so the test verifies
correct epoch-to-Date conversion.
src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java (1)

74-83: Optionally assert message list/id in the new group response test.

Line 74 through Line 83 validates contact mapping well; adding messages assertions would make this test fully symmetric with the neighboring successful-response tests.

Suggested test tightening
   void checkSuccessfulResponseWithGroupId() {
     SuccessfulResponse response =
         createJsonMapper().toJavaObject(jsonFromClasspath("whatsapp/message-response-group"), SuccessfulResponse.class);
     assertNotNull(response);
     assertEquals("whatsapp", response.getMessagingProduct());
     assertEquals(1, response.getContacts().size());
+    assertEquals(1, response.getMessages().size());
+    assertEquals("wamid.foobar", response.getMessages().get(0).getId());
     assertEquals("[email protected]", response.getContacts().get(0).getInput());
     assertNull(response.getContacts().get(0).getWaId());
     assertNull(response.getContacts().get(0).getUserId());
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java`
around lines 74 - 83, The test checkSuccessfulResponseWithGroupId currently
asserts contact mapping but omits verifying the messages payload; update this
test (method checkSuccessfulResponseWithGroupId) to also assert that
response.getMessages() is non-null, has the expected size (e.g., 1) and that the
first message's id matches the expected id from whatsapp/message-response-group
(use response.getMessages().get(0).getId()). This mirrors neighboring
successful-response tests and ensures message list/id mapping is validated
alongside contacts.
src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java (1)

91-98: Optionally assert raw change-value type before conversion to validate factory routing.

Line 91 through Line 98 currently verifies conversion into GroupParticipantsUpdateValue, but it does not explicitly prove the ChangeValueFactory enum dispatch selected the correct type before conversion.

Suggested assertion to lock enum dispatch behavior
   private <T extends ChangeValue> T getWHObjectFromJson(String jsonName, Class<T> clazz) {
     WebhookObject webhookObject =
         createJsonMapper().toJavaObject(jsonFromClasspath("whatsapp/" + jsonName), WebhookObject.class);
     assertThat(webhookObject.isWhatsAppBusinessAccount()).isTrue();
     assertThat(webhookObject.getEntryList()).hasSize(1);
     WebhookEntry entry = webhookObject.getEntryList().get(0);
+    assertThat(entry.getChanges().get(0).getValue()).isInstanceOf(clazz);
     return entry.getChanges().get(0).getValue().convertChangeValue(clazz);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java` around lines
91 - 98, Update getWHObjectFromJson to assert the raw change-value type before
calling convertChangeValue: after getting WebhookEntry entry and before return,
fetch the raw ChangeValue (entry.getChanges().get(0).getValue()) and assert its
factory/enum-dispatch indicator equals the expected enum (e.g.,
ChangeValueFactory.GroupParticipantsUpdate or the appropriate enum constant) to
validate routing, then proceed to call convertChangeValue(clazz) as before;
reference getWHObjectFromJson, WebhookObject, WebhookEntry, ChangeValueFactory
and convertChangeValue/GroupParticipantsUpdateValue to locate where to insert
the check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java`:
- Around line 91-98: Update getWHObjectFromJson to assert the raw change-value
type before calling convertChangeValue: after getting WebhookEntry entry and
before return, fetch the raw ChangeValue (entry.getChanges().get(0).getValue())
and assert its factory/enum-dispatch indicator equals the expected enum (e.g.,
ChangeValueFactory.GroupParticipantsUpdate or the appropriate enum constant) to
validate routing, then proceed to call convertChangeValue(clazz) as before;
reference getWHObjectFromJson, WebhookObject, WebhookEntry, ChangeValueFactory
and convertChangeValue/GroupParticipantsUpdateValue to locate where to insert
the check.

In `@src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java`:
- Around line 77-78: The test only checks non-null for creation timestamp;
update the GroupApiJsonTest to assert the exact parsed Date value from the
fixture by converting the fixture epoch string "1751210000" to the expected Date
and comparing it to firstRequest.getCreationTimestamp() (use the same
epoch-to-milliseconds conversion used in production) so the test verifies
correct epoch-to-Date conversion.

In `@src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java`:
- Around line 74-83: The test checkSuccessfulResponseWithGroupId currently
asserts contact mapping but omits verifying the messages payload; update this
test (method checkSuccessfulResponseWithGroupId) to also assert that
response.getMessages() is non-null, has the expected size (e.g., 1) and that the
first message's id matches the expected id from whatsapp/message-response-group
(use response.getMessages().get(0).getId()). This mirrors neighboring
successful-response tests and ensures message list/id mapping is validated
alongside contacts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ded4890-8316-4d71-be8c-ad9c45bcacfa

📥 Commits

Reviewing files that changed from the base of the PR and between b2a3d99 and 9ce14a1.

📒 Files selected for processing (16)
  • src/main/lombok/com/restfb/types/webhook/ChangeValueFactory.java
  • src/main/lombok/com/restfb/types/webhook/whatsapp/GroupParticipantsUpdateValue.java
  • src/main/lombok/com/restfb/types/whatsapp/platform/Status.java
  • src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupInfo.java
  • src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupJoinRequest.java
  • src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupJoinRequests.java
  • src/main/lombok/com/restfb/types/whatsapp/platform/group/GroupParticipant.java
  • src/test/java/com/restfb/types/WebhookWhatsappGroupsTest.java
  • src/test/java/com/restfb/types/WebhookWhatsappTest.java
  • src/test/java/com/restfb/types/whatsapp/platform/GroupApiJsonTest.java
  • src/test/java/com/restfb/types/whatsapp/platform/SendMessageJsonTest.java
  • src/test/resources/json/whatsapp/group-info.json
  • src/test/resources/json/whatsapp/group-join-requests.json
  • src/test/resources/json/whatsapp/message-response-group.json
  • src/test/resources/json/whatsapp/webhook-group-participants-update.json
  • src/test/resources/json/whatsapp/webhook-incoming-message-status-group-bsuid.json

@nbartels nbartels self-assigned this Apr 19, 2026
@nbartels
nbartels merged commit 60abdd1 into dev Apr 19, 2026
4 checks passed
@nbartels nbartels added this to the 2026.2.0 milestone Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant