diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go index a46c036..174a4dc 100644 --- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go +++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go @@ -71,7 +71,8 @@ func (uc *CreatePostgresqlBackupUsecase) Execute( // Use zstd compression level 5 for PostgreSQL 15+ (better compression and speed) // Fall back to gzip compression level 5 for older versions - if pg.Version == tools.PostgresqlVersion13 || pg.Version == tools.PostgresqlVersion14 || pg.Version == tools.PostgresqlVersion15 { + if pg.Version == tools.PostgresqlVersion13 || pg.Version == tools.PostgresqlVersion14 || + pg.Version == tools.PostgresqlVersion15 { args = append(args, "-Z", "5") uc.logger.Info("Using gzip compression level 5 (zstd not available)", "version", pg.Version) } else { diff --git a/backend/internal/features/notifiers/models/telegram/model.go b/backend/internal/features/notifiers/models/telegram/model.go index be8a4d8..5611407 100644 --- a/backend/internal/features/notifiers/models/telegram/model.go +++ b/backend/internal/features/notifiers/models/telegram/model.go @@ -7,6 +7,7 @@ import ( "log/slog" "net/http" "net/url" + "strconv" "strings" "github.com/google/uuid" @@ -16,6 +17,7 @@ type TelegramNotifier struct { NotifierID uuid.UUID `json:"notifierId" gorm:"primaryKey;column:notifier_id"` BotToken string `json:"botToken" gorm:"not null;column:bot_token"` TargetChatID string `json:"targetChatId" gorm:"not null;column:target_chat_id"` + ThreadID *int64 `json:"threadId" gorm:"column:thread_id"` } func (t *TelegramNotifier) TableName() string { @@ -47,6 +49,10 @@ func (t *TelegramNotifier) Send(logger *slog.Logger, heading string, message str data.Set("text", fullMessage) data.Set("parse_mode", "HTML") + if t.ThreadID != nil && *t.ThreadID != 0 { + data.Set("message_thread_id", strconv.FormatInt(*t.ThreadID, 10)) + } + req, err := http.NewRequest("POST", apiURL, strings.NewReader(data.Encode())) if err != nil { return fmt.Errorf("failed to create request: %w", err) diff --git a/backend/migrations/20250809062256_add_telegram_thread_id.sql b/backend/migrations/20250809062256_add_telegram_thread_id.sql new file mode 100644 index 0000000..1085d53 --- /dev/null +++ b/backend/migrations/20250809062256_add_telegram_thread_id.sql @@ -0,0 +1,15 @@ +-- +goose Up +-- +goose StatementBegin + +ALTER TABLE telegram_notifiers + ADD COLUMN thread_id BIGINT; + +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin + +ALTER TABLE telegram_notifiers + DROP COLUMN IF EXISTS thread_id; + +-- +goose StatementEnd diff --git a/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts b/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts index 0647bb8..b2a58f0 100644 --- a/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts +++ b/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts @@ -1,4 +1,8 @@ export interface TelegramNotifier { botToken: string; targetChatId: string; + threadId?: number; + + // temp field + isSendToThreadEnabled?: boolean; } diff --git a/frontend/src/entity/notifiers/models/telegram/validateTelegramNotifier.ts b/frontend/src/entity/notifiers/models/telegram/validateTelegramNotifier.ts index 36fe2eb..f827bd8 100644 --- a/frontend/src/entity/notifiers/models/telegram/validateTelegramNotifier.ts +++ b/frontend/src/entity/notifiers/models/telegram/validateTelegramNotifier.ts @@ -9,5 +9,10 @@ export const validateTelegramNotifier = (notifier: TelegramNotifier): boolean => return false; } + // If thread is enabled, thread ID must be present and valid + if (notifier.isSendToThreadEnabled && (!notifier.threadId || notifier.threadId <= 0)) { + return false; + } + return true; }; diff --git a/frontend/src/features/notifiers/ui/edit/EditNotifierComponent.tsx b/frontend/src/features/notifiers/ui/edit/EditNotifierComponent.tsx index 3244f8b..e36da97 100644 --- a/frontend/src/features/notifiers/ui/edit/EditNotifierComponent.tsx +++ b/frontend/src/features/notifiers/ui/edit/EditNotifierComponent.tsx @@ -208,7 +208,7 @@ export function EditNotifierComponent({ )}