release / go (push) Successful in 2m7s
release / web (push) Successful in 1m25s
release / govulncheck (push) Successful in 21s
release / integration (push) Successful in 4m30s
release / android (push) Successful in 4m39s
release / Build signed APK (push) Successful in 5m10s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped
- Module path: github.com/Fabled-Sword/minstrel, in go.mod, every import and the Dockerfile's version ldflags. - buildinfo.ProjectURL, the contact outside services see in Minstrel's User-Agent: https://github.com/Fabled-Sword/minstrel. - README's compose example pulls ghcr.io/fabled-sword/minstrel:latest. - docs/security.md sends problem reports to the GitHub issues. - The demo-library stack builds Minstrel from the checkout, since :dev is not published to GHCR. - hygiene.go's same-site example uses example.com names. The workbench CI (.gitea/, ci/, export-ignored) still builds and publishes :dev to the private registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package playevents
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"log/slog"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"github.com/Fabled-Sword/minstrel/internal/db/dbq"
|
|
)
|
|
|
|
// CaptureContextualLikeIfPlaying snapshots the user's currently-playing
|
|
// session context into a new contextual_likes row. No-op if no open
|
|
// play_event exists or its session_vector is NULL. Failures are logged
|
|
// but never returned to the caller — contextual capture is best-effort
|
|
// and must not break the like response.
|
|
func CaptureContextualLikeIfPlaying(
|
|
ctx context.Context,
|
|
q *dbq.Queries,
|
|
userID, trackID pgtype.UUID,
|
|
logger *slog.Logger,
|
|
) error {
|
|
event, err := q.GetOpenPlayEventForUser(ctx, userID)
|
|
if err != nil {
|
|
if errors.Is(err, pgx.ErrNoRows) {
|
|
return nil // no play in progress; nothing to capture
|
|
}
|
|
logger.Error("playevents: get open play_event", "err", err)
|
|
return nil // best-effort
|
|
}
|
|
if event.SessionVectorAtPlay == nil {
|
|
return nil // event predates this slice; no vector to snapshot
|
|
}
|
|
if err := q.InsertContextualLike(ctx, dbq.InsertContextualLikeParams{
|
|
UserID: userID,
|
|
TrackID: trackID,
|
|
SessionVector: event.SessionVectorAtPlay,
|
|
SessionID: event.SessionID,
|
|
}); err != nil {
|
|
logger.Error("playevents: insert contextual_like", "err", err)
|
|
return nil
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// SoftDeleteContextualLikes marks all currently-active contextual_likes
|
|
// rows for (user, track) as deleted. Idempotent.
|
|
func SoftDeleteContextualLikes(
|
|
ctx context.Context,
|
|
q *dbq.Queries,
|
|
userID, trackID pgtype.UUID,
|
|
) error {
|
|
return q.SoftDeleteContextualLikesForUserTrack(ctx, dbq.SoftDeleteContextualLikesForUserTrackParams{
|
|
UserID: userID,
|
|
TrackID: trackID,
|
|
})
|
|
}
|