Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions internal/signaling/stores/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,9 @@ func (s *PostgresStore) listen(ctx context.Context) error {
}
rawCompressed = rawCompressed[:l]

var raw []byte
if util.IsGzipCompressed(rawCompressed) {
raw, err = util.GzipDecompress(rawCompressed)
if err != nil {
return fmt.Errorf("failed to decompress payload: %w", err)
}
} else {
logger := logging.GetLogger(ctx)
logger.Warn("received uncompressed notification", zap.String("topic", topic))
raw = rawCompressed
raw, err := util.GzipDecompress(rawCompressed)
if err != nil {
return fmt.Errorf("failed to decompress payload: %w", err)
}

s.notify(ctx, topic, raw)
Expand Down
5 changes: 0 additions & 5 deletions internal/util/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import (
"io"
)

func IsGzipCompressed(data []byte) bool {
// Gzip magic bytes: 0x1f 0x8b
return len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b
}

func GzipCompress(input []byte) ([]byte, error) {
var buf bytes.Buffer
writer, err := gzip.NewWriterLevel(&buf, gzip.BestSpeed)
Expand Down