Files
pipu-music/services/api/internal/social/presence.go
T
mrleo1nid cd84ceecb2
ci / api / api (push) Successful in 1m11s
ci / db / db (push) Failing after 23s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m29s
ci / ts / ts (packages + web) (push) Successful in 3m15s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m27s
feat(social): show friend presence and require online listening
2026-10-23 12:52:00 +03:00

17 lines
546 B
Go

package social
import (
"context"
"github.com/google/uuid"
)
// Existing authenticated social/listening polls serve as heartbeats, including
// while playback is paused or music visibility is off. Coalesce frequent polls
// to one write per account per ten seconds; abandoned clients expire in 45s.
func (s *Store) markPresent(ctx context.Context, id uuid.UUID) error {
_, e := s.pool.Exec(ctx, `UPDATE users SET social_seen_at=now()
WHERE id=$1 AND (social_seen_at IS NULL OR social_seen_at<now()-interval '10 seconds')`, id)
return e
}