From 072bdd61850f46ccab211d7b85ccd41154ae70d2 Mon Sep 17 00:00:00 2001 From: danielkyalo599 Date: Fri, 10 Feb 2023 23:42:28 +0300 Subject: [PATCH] Added a class of telegram destination to support a new channel and custom webhook to select message Signed-off-by: danielkyalo599 --- .../spi/model/destination/DestinationType.kt | 2 +- .../spi/model/destination/TelegramDestination.kt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/DestinationType.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/DestinationType.kt index f915e174..a989144e 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/DestinationType.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/DestinationType.kt @@ -8,5 +8,5 @@ package org.opensearch.notifications.spi.model.destination * Supported notification destinations */ enum class DestinationType { - CHIME, SLACK, CUSTOM_WEBHOOK, SMTP, SES, SNS + CHIME, SLACK, CUSTOM_WEBHOOK, SMTP, SES, SNS, TELEGRAM } diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/TelegramDestination.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/TelegramDestination.kt index e69de29b..5dfd957b 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/TelegramDestination.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/TelegramDestination.kt @@ -0,0 +1,14 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.notifications.spi.model.destination +/* +This class holds the contents of a Telegram destination + */ +class TelegramDestination( + val token: String, + val chatId: Long, + val url: String = "https://api.telegram.org/bot$token/sendMessage?chat_id=$chatId" +) : WebhookDestination(url, DestinationType.TELEGRAM)