mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(notif): include poster image in Telegram notifications (#1112)
This commit is contained in:
@@ -4,13 +4,21 @@ import logger from '../../../logger';
|
|||||||
import { getSettings, NotificationAgentTelegram } from '../../settings';
|
import { getSettings, NotificationAgentTelegram } from '../../settings';
|
||||||
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||||
|
|
||||||
interface TelegramPayload {
|
interface TelegramMessagePayload {
|
||||||
text: string;
|
text: string;
|
||||||
parse_mode: string;
|
parse_mode: string;
|
||||||
chat_id: string;
|
chat_id: string;
|
||||||
disable_notification: boolean;
|
disable_notification: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TelegramPhotoPayload {
|
||||||
|
photo: string;
|
||||||
|
caption: string;
|
||||||
|
parse_mode: string;
|
||||||
|
chat_id: string;
|
||||||
|
disable_notification: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
class TelegramAgent
|
class TelegramAgent
|
||||||
extends BaseAgent<NotificationAgentTelegram>
|
extends BaseAgent<NotificationAgentTelegram>
|
||||||
implements NotificationAgent {
|
implements NotificationAgent {
|
||||||
@@ -125,14 +133,22 @@ class TelegramAgent
|
|||||||
try {
|
try {
|
||||||
const endpoint = `${this.baseUrl}bot${
|
const endpoint = `${this.baseUrl}bot${
|
||||||
this.getSettings().options.botAPI
|
this.getSettings().options.botAPI
|
||||||
}/sendMessage`;
|
}/${payload.image ? 'sendPhoto' : 'sendMessage'}`;
|
||||||
|
|
||||||
await axios.post(endpoint, {
|
await (payload.image
|
||||||
text: this.buildMessage(type, payload),
|
? axios.post(endpoint, {
|
||||||
parse_mode: 'MarkdownV2',
|
photo: payload.image,
|
||||||
chat_id: `${this.getSettings().options.chatId}`,
|
caption: this.buildMessage(type, payload),
|
||||||
disable_notification: this.getSettings().options.sendSilently,
|
parse_mode: 'MarkdownV2',
|
||||||
} as TelegramPayload);
|
chat_id: `${this.getSettings().options.chatId}`,
|
||||||
|
disable_notification: this.getSettings().options.sendSilently,
|
||||||
|
} as TelegramPhotoPayload)
|
||||||
|
: axios.post(endpoint, {
|
||||||
|
text: this.buildMessage(type, payload),
|
||||||
|
parse_mode: 'MarkdownV2',
|
||||||
|
chat_id: `${this.getSettings().options.chatId}`,
|
||||||
|
disable_notification: this.getSettings().options.sendSilently,
|
||||||
|
} as TelegramMessagePayload));
|
||||||
|
|
||||||
if (
|
if (
|
||||||
payload.notifyUser.settings?.enableNotifications &&
|
payload.notifyUser.settings?.enableNotifications &&
|
||||||
@@ -140,13 +156,22 @@ class TelegramAgent
|
|||||||
payload.notifyUser.settings?.telegramChatId !==
|
payload.notifyUser.settings?.telegramChatId !==
|
||||||
this.getSettings().options.chatId
|
this.getSettings().options.chatId
|
||||||
) {
|
) {
|
||||||
await axios.post(endpoint, {
|
await (payload.image
|
||||||
text: this.buildMessage(type, payload),
|
? axios.post(endpoint, {
|
||||||
parse_mode: 'MarkdownV2',
|
photo: payload.image,
|
||||||
chat_id: `${payload.notifyUser.settings.telegramChatId}`,
|
caption: this.buildMessage(type, payload),
|
||||||
disable_notification:
|
parse_mode: 'MarkdownV2',
|
||||||
payload.notifyUser.settings.telegramSendSilently,
|
chat_id: `${payload.notifyUser.settings.telegramChatId}`,
|
||||||
} as TelegramPayload);
|
disable_notification:
|
||||||
|
payload.notifyUser.settings.telegramSendSilently,
|
||||||
|
} as TelegramPhotoPayload)
|
||||||
|
: axios.post(endpoint, {
|
||||||
|
text: this.buildMessage(type, payload),
|
||||||
|
parse_mode: 'MarkdownV2',
|
||||||
|
chat_id: `${payload.notifyUser.settings.telegramChatId}`,
|
||||||
|
disable_notification:
|
||||||
|
payload.notifyUser.settings.telegramSendSilently,
|
||||||
|
} as TelegramMessagePayload));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user