diff --git a/js/docs/src/content/docs/lex-reference/live/place-stream-live-viewcount.md b/js/docs/src/content/docs/lex-reference/live/place-stream-live-viewercount.md similarity index 80% rename from js/docs/src/content/docs/lex-reference/live/place-stream-live-viewcount.md rename to js/docs/src/content/docs/lex-reference/live/place-stream-live-viewercount.md index d25feb40..b1f629d9 100644 --- a/js/docs/src/content/docs/lex-reference/live/place-stream-live-viewcount.md +++ b/js/docs/src/content/docs/lex-reference/live/place-stream-live-viewercount.md @@ -1,6 +1,6 @@ --- -title: place.stream.live.viewCount -description: Reference for the place.stream.live.viewCount lexicon +title: place.stream.live.viewerCount +description: Reference for the place.stream.live.viewerCount lexicon --- **Lexicon Version:** 1 @@ -13,7 +13,7 @@ description: Reference for the place.stream.live.viewCount lexicon **Type:** `record` -Current view count for a livestream on a particular server. +Current viewer count for a livestream on a particular server. Record keys are streamer_did::server_did by convention. **Record Key:** `any` @@ -33,12 +33,12 @@ Current view count for a livestream on a particular server. ```json { "lexicon": 1, - "id": "place.stream.live.viewCount", + "id": "place.stream.live.viewerCount", "defs": { "main": { "type": "record", "key": "any", - "description": "Current view count for a livestream on a particular server.", + "description": "Current viewer count for a livestream on a particular server. Record keys are streamer_did::server_did by convention.", "record": { "type": "object", "required": ["streamer", "server", "count"], diff --git a/lexicons/place/stream/live/viewCount.json b/lexicons/place/stream/live/viewerCount.json similarity index 82% rename from lexicons/place/stream/live/viewCount.json rename to lexicons/place/stream/live/viewerCount.json index b2cfd726..54cf87ad 100644 --- a/lexicons/place/stream/live/viewCount.json +++ b/lexicons/place/stream/live/viewerCount.json @@ -1,11 +1,11 @@ { "lexicon": 1, - "id": "place.stream.live.viewCount", + "id": "place.stream.live.viewerCount", "defs": { "main": { "type": "record", "key": "any", - "description": "Current view count for a livestream on a particular server.", + "description": "Current viewer count for a livestream on a particular server. Record keys are streamer_did::server_did by convention.", "record": { "type": "object", "required": ["streamer", "server", "count"], diff --git a/pkg/atproto/server_repo_test.go b/pkg/atproto/server_repo_test.go index c2abd485..975f818c 100644 --- a/pkg/atproto/server_repo_test.go +++ b/pkg/atproto/server_repo_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "stream.place/streamplace/pkg/config" + "stream.place/streamplace/pkg/constants" "stream.place/streamplace/pkg/model" "stream.place/streamplace/pkg/statedb" "stream.place/streamplace/pkg/streamplace" @@ -44,29 +45,29 @@ func TestServerRepo(t *testing.T) { // Put a LiveViewCount record updatedAt := "2026-03-21T00:00:00Z" - vc := &streamplace.LiveViewCount{ - LexiconTypeID: "place.stream.live.viewCount", + vc := &streamplace.LiveViewerCount{ + LexiconTypeID: constants.PLACE_STREAM_LIVE_VIEWERCOUNT, Count: 42, Server: "did:web:server1.example.com", Streamer: "did:plc:abc123", UpdatedAt: &updatedAt, } - err = CommitServerRepoRecord(context.Background(), &cli, "place.stream.live.viewCount", "did:plc:abc123", vc) + err = CommitServerRepoRecord(context.Background(), &cli, constants.PLACE_STREAM_LIVE_VIEWERCOUNT, "did:plc:abc123", vc) require.NoError(t, err) // Read it back - out, err := ServerRepoGetRecord(context.Background(), "did:web:server1.example.com", "place.stream.live.viewCount", "did:plc:abc123") + out, err := ServerRepoGetRecord(context.Background(), "did:web:server1.example.com", constants.PLACE_STREAM_LIVE_VIEWERCOUNT, "did:plc:abc123") require.NoError(t, err) require.NotNil(t, out) - require.Contains(t, out.Uri, "place.stream.live.viewCount") + require.Contains(t, out.Uri, constants.PLACE_STREAM_LIVE_VIEWERCOUNT) // List records - listOut, err := ServerRepoListRecords(context.Background(), "place.stream.live.viewCount", "", 100, "did:web:server1.example.com", nil) + listOut, err := ServerRepoListRecords(context.Background(), constants.PLACE_STREAM_LIVE_VIEWERCOUNT, "", 100, "did:web:server1.example.com", nil) require.NoError(t, err) require.Len(t, listOut.Records, 1) // Merkle proof - proof, err := ServerRepoMerkleProof(context.Background(), "place.stream.live.viewCount", "did:plc:abc123") + proof, err := ServerRepoMerkleProof(context.Background(), constants.PLACE_STREAM_LIVE_VIEWERCOUNT, "did:plc:abc123") require.NoError(t, err) require.NotEmpty(t, proof) @@ -88,7 +89,7 @@ func TestServerRepo(t *testing.T) { require.NotNil(t, ServerRepo) // The record should still be there (file-backed carstore) - out, err = ServerRepoGetRecord(context.Background(), "did:web:server1.example.com", "place.stream.live.viewCount", "did:plc:abc123") + out, err = ServerRepoGetRecord(context.Background(), "did:web:server1.example.com", constants.PLACE_STREAM_LIVE_VIEWERCOUNT, "did:plc:abc123") require.NoError(t, err) require.NotNil(t, out) diff --git a/pkg/atproto/sync.go b/pkg/atproto/sync.go index f02bb376..78cc0755 100644 --- a/pkg/atproto/sync.go +++ b/pkg/atproto/sync.go @@ -559,7 +559,7 @@ func (atsync *ATProtoSynchronizer) handleCreateUpdate(ctx context.Context, userD // This allows moderators to see their permissions instantly without page refresh go atsync.Bus.Publish(userDID, view) - case *streamplace.LiveViewCount: + case *streamplace.LiveViewerCount: log.Debug(ctx, "indexing view count", "streamer", rec.Streamer, "server", rec.Server, "count", rec.Count) // Check if the reporting server's DID is labeled as banned or !no-viewers serverLabels, err := atsync.Model.GetActiveLabels(rec.Server) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 0d6d07a7..744c663f 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -15,7 +15,7 @@ var APP_BSKY_ACTOR_PROFILE = "app.bsky.actor.profile" // var PLACE_STREAM_CHAT_GATE = "place.stream.chat.gate" //nolint:all var PLACE_STREAM_DEFAULT_METADATA = "place.stream.metadata.configuration" //nolint:all var PLACE_STREAM_LIVE_RECOMMENDATIONS = "place.stream.live.recommendations" //nolint:all -var PLACE_STREAM_LIVE_VIEWCOUNT = "place.stream.live.viewCount" //nolint:all +var PLACE_STREAM_LIVE_VIEWERCOUNT = "place.stream.live.viewerCount" //nolint:all // Streamplace badge types const ( diff --git a/pkg/director/stream_session.go b/pkg/director/stream_session.go index f0d6a082..ff242177 100644 --- a/pkg/director/stream_session.go +++ b/pkg/director/stream_session.go @@ -21,6 +21,7 @@ import ( "stream.place/streamplace/pkg/atproto" "stream.place/streamplace/pkg/bus" "stream.place/streamplace/pkg/config" + "stream.place/streamplace/pkg/constants" "stream.place/streamplace/pkg/livepeer" "stream.place/streamplace/pkg/localdb" "stream.place/streamplace/pkg/log" @@ -734,15 +735,15 @@ func (ss *StreamSession) doUpdateViewCount(ctx context.Context, repoDID string) now := time.Now().UTC().Format(util.ISO8601) rkey := fmt.Sprintf("%s::%s", repoDID, ss.cli.ServerDID()) - vc := &streamplace.LiveViewCount{ - LexiconTypeID: "place.stream.live.viewCount", + vc := &streamplace.LiveViewerCount{ + LexiconTypeID: constants.PLACE_STREAM_LIVE_VIEWERCOUNT, Count: int64(count), Server: ss.cli.ServerDID(), Streamer: repoDID, UpdatedAt: &now, } - err := atproto.CommitServerRepoRecord(ctx, ss.cli, "place.stream.live.viewCount", rkey, vc) + err := atproto.CommitServerRepoRecord(ctx, ss.cli, constants.PLACE_STREAM_LIVE_VIEWERCOUNT, rkey, vc) if err != nil { return fmt.Errorf("could not commit view count record: %w", err) } diff --git a/pkg/gen/gen.go b/pkg/gen/gen.go index 08851684..34f99558 100644 --- a/pkg/gen/gen.go +++ b/pkg/gen/gen.go @@ -36,7 +36,7 @@ func main() { streamplace.ModerationPermission{}, streamplace.LiveTeleport{}, streamplace.LiveRecommendations{}, - streamplace.LiveViewCount{}, + streamplace.LiveViewerCount{}, ); err != nil { panic(err) } diff --git a/pkg/spxrpc/com_atproto_repo.go b/pkg/spxrpc/com_atproto_repo.go index cbc2ec84..5969cca4 100644 --- a/pkg/spxrpc/com_atproto_repo.go +++ b/pkg/spxrpc/com_atproto_repo.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/otel" "stream.place/streamplace/pkg/aqhttp" "stream.place/streamplace/pkg/atproto" + "stream.place/streamplace/pkg/constants" "stream.place/streamplace/pkg/log" ) @@ -96,7 +97,7 @@ func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context, repo stri Did: s.cli.ServerDID(), DidDoc: atproto.DIDDoc(s.cli.ServerHost, atproto.ServerPubMultibase), Collections: []string{ - "place.stream.live.viewCount", + constants.PLACE_STREAM_LIVE_VIEWERCOUNT, }, HandleIsCorrect: true, }, nil diff --git a/pkg/streamplace/cbor_gen.go b/pkg/streamplace/cbor_gen.go index 230323b0..81a1c9a0 100644 --- a/pkg/streamplace/cbor_gen.go +++ b/pkg/streamplace/cbor_gen.go @@ -6152,7 +6152,7 @@ func (t *LiveRecommendations) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *LiveViewCount) MarshalCBOR(w io.Writer) error { +func (t *LiveViewerCount) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err @@ -6181,10 +6181,10 @@ func (t *LiveViewCount) MarshalCBOR(w io.Writer) error { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("place.stream.live.viewCount"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("place.stream.live.viewerCount"))); err != nil { return err } - if _, err := cw.WriteString(string("place.stream.live.viewCount")); err != nil { + if _, err := cw.WriteString(string("place.stream.live.viewerCount")); err != nil { return err } @@ -6290,8 +6290,8 @@ func (t *LiveViewCount) MarshalCBOR(w io.Writer) error { return nil } -func (t *LiveViewCount) UnmarshalCBOR(r io.Reader) (err error) { - *t = LiveViewCount{} +func (t *LiveViewerCount) UnmarshalCBOR(r io.Reader) (err error) { + *t = LiveViewerCount{} cr := cbg.NewCborReader(r) @@ -6310,7 +6310,7 @@ func (t *LiveViewCount) UnmarshalCBOR(r io.Reader) (err error) { } if extra > cbg.MaxLength { - return fmt.Errorf("LiveViewCount: map struct too large (%d)", extra) + return fmt.Errorf("LiveViewerCount: map struct too large (%d)", extra) } n := extra diff --git a/pkg/streamplace/liveviewCount.go b/pkg/streamplace/liveviewerCount.go similarity index 79% rename from pkg/streamplace/liveviewCount.go rename to pkg/streamplace/liveviewerCount.go index f3f8f8f9..48d72d7b 100644 --- a/pkg/streamplace/liveviewCount.go +++ b/pkg/streamplace/liveviewerCount.go @@ -1,6 +1,6 @@ // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. -// Lexicon schema: place.stream.live.viewCount +// Lexicon schema: place.stream.live.viewerCount package streamplace @@ -9,11 +9,11 @@ import ( ) func init() { - lexutil.RegisterType("place.stream.live.viewCount", &LiveViewCount{}) + lexutil.RegisterType("place.stream.live.viewerCount", &LiveViewerCount{}) } -type LiveViewCount struct { - LexiconTypeID string `json:"$type" cborgen:"$type,const=place.stream.live.viewCount"` +type LiveViewerCount struct { + LexiconTypeID string `json:"$type" cborgen:"$type,const=place.stream.live.viewerCount"` // count: The current view count for the livestream. Count int64 `json:"count" cborgen:"count"` // server: The DID of the server to get the view count for.