Add WhatsApp message title field to export and import processes#472
Add WhatsApp message title field to export and import processes#472erikh360 wants to merge 1 commit into
Conversation
| assert body["total_messages"] == 1 | ||
| assert body["text"]["type"] == "Whatsapp_Message" | ||
| assert body["text"]["value"]["message"] == "*Default whatsapp Content 1* 🏥" | ||
| assert body["text"]["value"].get("title", "") == "" |
There was a problem hiding this comment.
If we expect this field to always be in the response, we should index it directly like we do with the other fields.
| return { | ||
| "whatsapp_template_slug": "", | ||
| **entry, | ||
| "whatsapp_message_title": entry.get("whatsapp_message_title") or "", |
There was a problem hiding this comment.
| "whatsapp_message_title": entry.get("whatsapp_message_title") or "", | |
| "whatsapp_message_title": entry.get("whatsapp_message_title", ""), |
| ( | ||
| "Whatsapp_Message", | ||
| { | ||
| "title": "", |
There was a problem hiding this comment.
Do we need a test with a non-empty title?
| expected_result = { | ||
| "type": "Whatsapp_Message", | ||
| "value": { | ||
| "title": "", |
There was a problem hiding this comment.
Do we need a test with a non-empty title?
| else: | ||
| self.whatsapp_body = whatsapp.value["message"].strip() | ||
| # Per-message WhatsApp title (not the page-level whatsapp_title) | ||
| self.whatsapp_message_title = whatsapp.value.get("title", "") |
There was a problem hiding this comment.
Since title should always exist, I think we want value["title"] here.
There was a problem hiding this comment.
Since we've done a django migration, but not a streamfield migration, that field might not exist on messages that haven't been updated. I don't think adding a field requires us to add a streamfield migration, although we might have to deal with the field being missing on old messages: https://docs.wagtail.org/en/v4.2/advanced_topics/streamfield_migrations.html#streamfield-data-migrations
| # Provide a minimal snippet_viewset interface for chooser widgets when the | ||
| # snippet isn't registered in the admin (feature-flagged). Wagtail's | ||
| # SnippetChooserBlock accesses `target_model.snippet_viewset.icon`. | ||
| class snippet_viewset: | ||
| icon = "order" | ||
|
|
There was a problem hiding this comment.
Is this related to the WA title?
There was a problem hiding this comment.
no idea why it added this
| else: | ||
| self.whatsapp_body = whatsapp.value["message"].strip() | ||
| # Per-message WhatsApp title (not the page-level whatsapp_title) | ||
| self.whatsapp_message_title = whatsapp.value.get("title", "") |
There was a problem hiding this comment.
Since we've done a django migration, but not a streamfield migration, that field might not exist on messages that haven't been updated. I don't think adding a field requires us to add a streamfield migration, although we might have to deal with the field being missing on old messages: https://docs.wagtail.org/en/v4.2/advanced_topics/streamfield_migrations.html#streamfield-data-migrations
| # to retain the v2 api behaviour. We also return some fields as null or empty values, for the same reason | ||
| "type": "Whatsapp_Message", | ||
| "value": { | ||
| "title": "", |
There was a problem hiding this comment.
We don't need to add this to the v2 API, especially just a hardcoded empty string, since we can keep the v2 API the same and just add this to the v3 API.
|
|
||
| if str(text["type"]) == "Whatsapp_Message": | ||
| # Ensure the new title field always exists in API output | ||
| text["value"].setdefault("title", "") |
There was a problem hiding this comment.
Same here, we don't need this in the v2 API. What we do need, however, is for this to be present in the new v3 API, in serializers_v3.py
Purpose
Why does this exist?
Solution
_What changed, and does this address the problem? _
Checklist