feat(notification): Telegram add support for topics in groups (#894)

* feat(notification): send Telegram messages to a specific topic of a group

* Convert settings.Topic to integer once and reuse it as part of the
telegramSender struct.

* feat(notifications): add migrations for topic

* fix(notifications): find null string

* fix(notifications): form initial values

---------

Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
Yuchen Ying 2023-05-07 08:30:07 -07:00 committed by GitHub
parent e5692fefc7
commit fdc957c571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 16 deletions

View file

@ -121,6 +121,11 @@ function FormFieldsTelegram() {
label="Chat ID"
help="Chat ID"
/>
<PasswordFieldWide
name="topic"
label="Message Thread ID"
help="Message Thread (topic) of a Supergroup"
/>
</div>
);
}
@ -436,6 +441,7 @@ interface InitialValues {
api_key?: string;
priority?: number;
channel?: string;
topic?: string;
events: NotificationEvent[];
}
@ -484,6 +490,7 @@ export function NotificationUpdateForm({ isOpen, toggle, notification }: UpdateP
api_key: notification.api_key,
priority: notification.priority,
channel: notification.channel,
topic: notification.topic,
events: notification.events || []
};
@ -567,4 +574,4 @@ export function NotificationUpdateForm({ isOpen, toggle, notification }: UpdateP
)}
</SlideOver>
);
}
}

View file

@ -4,7 +4,13 @@
*/
type NotificationType = "DISCORD" | "NOTIFIARR" | "TELEGRAM" | "PUSHOVER";
type NotificationEvent = "PUSH_APPROVED" | "PUSH_REJECTED" | "PUSH_ERROR" | "IRC_DISCONNECTED" | "IRC_RECONNECTED" | "APP_UPDATE_AVAILABLE";
type NotificationEvent =
"PUSH_APPROVED"
| "PUSH_REJECTED"
| "PUSH_ERROR"
| "IRC_DISCONNECTED"
| "IRC_RECONNECTED"
| "APP_UPDATE_AVAILABLE";
interface Notification {
id: number;
@ -17,4 +23,5 @@ interface Notification {
api_key?: string;
channel?: string;
priority?: number;
topic?: string;
}