парсер

This commit is contained in:
Artem Tsyrulnikov
2026-01-06 21:04:42 +03:00
parent b77e4fd0b6
commit 2c0ae2dfc3
45 changed files with 2202 additions and 51 deletions

View File

@@ -0,0 +1,37 @@
package database
import (
"context"
"fmt"
"github.com/jackc/pgx/v5/pgtype"
"github.com/TelegramExchange/tgex-parser/internal/domain"
"github.com/TelegramExchange/tgex-parser/pkg/transaction"
)
func (d *Database) DeletePost(ctx context.Context, p domain.Post) error {
query := `UPDATE post
SET deleted_from_channel_at = CURRENT_TIMESTAMP,
updated_at = CURRENT_TIMESTAMP
WHERE channel_id = $1 AND message_id = $2;`
txOrPool := transaction.TryExtractTX(ctx)
dto := deletePostDTO{
ChannelID: pgtype.UUID{Bytes: p.ChannelID, Valid: true},
MessageID: pgtype.Int4{Int32: int32(p.MessageID), Valid: true},
}
_, err := txOrPool.Exec(ctx, query, dto.ChannelID, dto.MessageID)
if err != nil {
return fmt.Errorf("txOrPool.Exec: %w", err)
}
return nil
}
type deletePostDTO struct {
ChannelID pgtype.UUID
MessageID pgtype.Int4
}