diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/util/destinationmigration/NotificationApiUtils.kt b/alerting/src/main/kotlin/org/opensearch/alerting/util/destinationmigration/NotificationApiUtils.kt index 489aa59d6..ed8bd8fcb 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/util/destinationmigration/NotificationApiUtils.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/util/destinationmigration/NotificationApiUtils.kt @@ -26,6 +26,7 @@ import org.opensearch.commons.notifications.action.LegacyPublishNotificationRequ import org.opensearch.commons.notifications.action.LegacyPublishNotificationResponse import org.opensearch.commons.notifications.action.SendNotificationResponse import org.opensearch.commons.notifications.model.ChannelMessage +import org.opensearch.commons.notifications.model.ConfigType import org.opensearch.commons.notifications.model.EventSource import org.opensearch.commons.notifications.model.NotificationConfigInfo import org.opensearch.commons.notifications.model.SeverityType @@ -136,12 +137,14 @@ suspend fun NotificationConfigInfo.sendNotification(client: Client, title: Strin } /** - * A placeholder Alerting title will be used if no subject is passed in. + * For most channel types, a placeholder Alerting title will be used but the email channel/SNS notification will + * use the subject, so it appears as the actual subject of the email/SNS notification. */ fun NotificationConfigInfo.getTitle(subject: String?): String { val defaultTitle = "Alerting-Notification Action" - return if (subject.isNullOrEmpty()) defaultTitle else subject -} + if (this.notificationConfig.configType == ConfigType.EMAIL || this.notificationConfig.configType == ConfigType.SNS) { + return if (subject.isNullOrEmpty()) defaultTitle else subject + } /** * All valid response statuses.