diff --git a/tg_parser/internal/adapter/database/update_channel.go b/tg_parser/internal/adapter/database/update_channel.go index 286503a..fc25b69 100644 --- a/tg_parser/internal/adapter/database/update_channel.go +++ b/tg_parser/internal/adapter/database/update_channel.go @@ -3,6 +3,7 @@ package database import ( "context" "fmt" + "strings" "github.com/jackc/pgx/v5/pgtype" @@ -22,10 +23,13 @@ WHERE id = $1;` txOrPool := transaction.TryExtractTX(ctx) + username := strings.TrimSpace(channel.Username) + usernameValid := username != "" + dto := updateChannelDTO{ ID: pgtype.UUID{Bytes: channel.ID, Valid: true}, TelegramID: pgtype.Int8{Int64: channel.TelegramID, Valid: true}, - Username: pgtype.Text{String: channel.Username, Valid: true}, + Username: pgtype.Text{String: username, Valid: usernameValid}, Title: pgtype.Text{String: channel.Title, Valid: true}, AccessHash: pgtype.Int8{Int64: channel.AccessHash, Valid: true}, Pts: pgtype.Int4{Int32: int32(channel.Pts), Valid: true},