Skip to content

Commit

Permalink
Overriding defaultTitle with subject for SNS notifications (opensearc…
Browse files Browse the repository at this point in the history
…h-project#708) (opensearch-project#723)

* Overriding defaultTitle with subject for SNS notifications

Signed-off-by: uros <[email protected]>

* Overriding defaultTitle with subject for SNS notifications - condition fix

Signed-off-by: uros <[email protected]>

Signed-off-by: uros <[email protected]>
(cherry picked from commit 88536b2)

Co-authored-by: uroskarama <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
2 people authored and AWSHurneyt committed Jun 6, 2023
1 parent 96154ba commit 68100d7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 68100d7

Please sign in to comment.