Skip to content

Commit dc28d91

Browse files
authored
fix: deliveryChannels is not persisted (40) (#23640)
* fix: deliveryChannels is not persisted * minor * minor * minor
1 parent 177ebe8 commit dc28d91

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/objectbundle/hooks/ProgramNotificationTemplateObjectBundleHook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private void postProcess(ProgramNotificationTemplate template) {
115115
ValueType valueType = toValueType == null ? null : toValueType.apply(template);
116116

117117
Set<DeliveryChannel> deliveryChannels =
118-
valueType == null ? null : CHANNEL_MAPPER.get(valueType);
118+
valueType == null ? template.getDeliveryChannels() : CHANNEL_MAPPER.get(valueType);
119119
template.setDeliveryChannels(deliveryChannels == null ? new HashSet<>() : deliveryChannels);
120120
}
121121
}

dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/MetadataImportExportControllerTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,28 @@ void removeDataSetIndicatorTest() {
756756
.contains("IndUid000x1"));
757757
}
758758

759+
@Test
760+
void testSaveNotificationTemplateWithDeliveryChannels() {
761+
POST("/metadata", WebClient.Body("program/program_notification_template.json"))
762+
.content(HttpStatus.OK);
763+
JsonObject template =
764+
GET("/programNotificationTemplates/uivYkvFEOss")
765+
.content(HttpStatus.OK)
766+
.as(JsonObject.class);
767+
assertNotNull(template);
768+
assertEquals(1, template.getArray("deliveryChannels").size());
769+
770+
// Update the template with an additional delivery channel
771+
POST("/metadata", WebClient.Body("program/program_notification_template_update.json"))
772+
.content(HttpStatus.OK);
773+
template =
774+
GET("/programNotificationTemplates/uivYkvFEOss")
775+
.content(HttpStatus.OK)
776+
.as(JsonObject.class);
777+
assertNotNull(template);
778+
assertEquals(2, template.getArray("deliveryChannels").size());
779+
}
780+
759781
private void setupDataElementsWithCatCombos(CategoryCombo... categoryCombos) {
760782
DataElement deA = createDataElement('A', categoryCombos[0]);
761783
DataElement deB = createDataElement('B', categoryCombos[1]);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"programNotificationTemplates": [
3+
{
4+
"notificationTrigger": "SCHEDULED_DAYS_DUE_DATE",
5+
"lastUpdated": "2026-04-14T04:24:42.392",
6+
"relativeScheduledDays": -3,
7+
"subjectTemplate": "Immunization visit reminder",
8+
"id": "uivYkvFEOss",
9+
"notifyUsersInHierarchyOnly": false,
10+
"created": "2016-10-11T10:32:58.490",
11+
"sendRepeatable": false,
12+
"notificationRecipient": "TRACKED_ENTITY_INSTANCE",
13+
"notifyParentOrganisationUnitOnly": false,
14+
"name": "Immunization visit reminder",
15+
"messageTemplate": "Dear A{w75KJ2mc4zz}. This to remind you that you have an upcoming visit in V{days_until_due_date} days for your second immunization visit at V{program_stage_name} health facility. Please ensure to bring your immunization card with you.",
16+
"translations": [],
17+
"deliveryChannels": [
18+
"SMS"
19+
]
20+
}
21+
]
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"programNotificationTemplates": [
3+
{
4+
"notificationTrigger": "SCHEDULED_DAYS_DUE_DATE",
5+
"lastUpdated": "2026-04-14T04:24:42.392",
6+
"relativeScheduledDays": -3,
7+
"subjectTemplate": "Immunization visit reminder",
8+
"id": "uivYkvFEOss",
9+
"notifyUsersInHierarchyOnly": false,
10+
"created": "2016-10-11T10:32:58.490",
11+
"sendRepeatable": false,
12+
"notificationRecipient": "TRACKED_ENTITY_INSTANCE",
13+
"notifyParentOrganisationUnitOnly": false,
14+
"name": "Immunization visit reminder",
15+
"messageTemplate": "Dear A{w75KJ2mc4zz}. This to remind you that you have an upcoming visit in V{days_until_due_date} days for your second immunization visit at V{program_stage_name} health facility. Please ensure to bring your immunization card with you.",
16+
"translations": [],
17+
"deliveryChannels": [
18+
"SMS",
19+
"EMAIL"
20+
]
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)