Skip to content

feat(message): map generic template attachments#1657

Merged
nbartels merged 2 commits into
devfrom
feat/message-generic-template-attachment
Apr 23, 2026
Merged

feat(message): map generic template attachments#1657
nbartels merged 2 commits into
devfrom
feat/message-generic-template-attachment

Conversation

@nbartels

@nbartels nbartels commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Support for Facebook generic template attachments in messages, exposing title, subtitle, media URL and call-to-action (title, type, URL) fields and a predicate to identify generic-template attachments.
  • Tests

    • Added unit tests validating deserialization of generic template attachments and ensuring backward compatibility with older attachment formats.

@nbartels nbartels self-assigned this Apr 23, 2026
@coderabbitai

coderabbitai Bot commented Apr 23, 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: 492bd82e-2f0b-4b5d-ad71-df643bcb9160

📥 Commits

Reviewing files that changed from the base of the PR and between 91ac61f and ae8918b.

📒 Files selected for processing (1)
  • src/test/java/com/restfb/types/MessageTest.java

📝 Walkthrough

Walkthrough

Adds support for Facebook "generic template" message attachments: a new genericTemplate field and isGenericTemplate() on Message.Attachment, plus nested GenericTemplate and GenericTemplateCallToAction classes; includes unit test and JSON fixture for deserialization.

Changes

Cohort / File(s) Summary
Model Extension
src/main/lombok/com/restfb/types/Message.java
Added Message.Attachment.genericTemplate field and isGenericTemplate() predicate; introduced nested Message.GenericTemplate and Message.GenericTemplateCallToAction classes with @Facebook-annotated fields (title, subtitle, mediaUrl, cta, type, url).
Test & Fixture
src/test/java/com/restfb/types/MessageTest.java, src/test/resources/json/v10_0/message-with-generic-template.json
Added test that deserializes a generic-template fixture and asserts attachment is recognized as generic template; verifies template fields and nested CTA values; new JSON fixture provides sample generic_template payload.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping through fields with glee,

I found a template on a tree.
Nested CTAs, titles bright,
Deserialized by moonlight.
Cheers for attachments, snug and right! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(message): map generic template attachments' clearly and concisely summarizes the main change—adding support for mapping Facebook generic template attachments to the Message type.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/message-generic-template-attachment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/com/restfb/types/MessageTest.java`:
- Around line 98-119: The test messageWithGenericTemplateAttachment in
MessageTest verifies the generic-template success path but lacks a negative
assertion for non-generic attachments; update the test to also assert the false
branch by checking another attachment (or the same attachment when applicable)
using attachment.isGenericTemplate() == false for a non-generic case or by
creating/reading a known non-generic fixture from jsonFromClasspath and
asserting its attachment.isGenericTemplate() is false and related getters (e.g.,
getGenericTemplate()) are null to cover the failure path; refer to the
MessageTest class and the messageWithGenericTemplateAttachment method, and the
Attachment methods isGenericTemplate(), getGenericTemplate(), and
getAttachments() to locate where to add the assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd838f53-9a50-48bc-bf9d-8d73b2f3a00a

📥 Commits

Reviewing files that changed from the base of the PR and between d3c6b92 and 91ac61f.

📒 Files selected for processing (3)
  • src/main/lombok/com/restfb/types/Message.java
  • src/test/java/com/restfb/types/MessageTest.java
  • src/test/resources/json/v10_0/message-with-generic-template.json

Comment thread src/test/java/com/restfb/types/MessageTest.java
@nbartels nbartels added this to the 2026.3.0 milestone Apr 23, 2026
@nbartels
nbartels merged commit bdbe014 into dev Apr 23, 2026
4 checks passed
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