From 696fe95f35488b08a3a55dbf2d2b65fe3db88091 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Sun, 31 May 2026 16:10:10 -0700 Subject: [PATCH] =?UTF-8?q?likes:=20finish=20de-VOD-ing=20=E2=80=94=20rena?= =?UTF-8?q?me=20storage=20layer=20and=20getLikes=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to the place.stream.like record rename: likes aren't VOD-specific, so drop the "Vod" prefix everywhere. - Storage: model.VodLike -> model.Like, table vod_likes -> likes (index + raw SQL updated), Create/Delete/Get*VodLike* -> *Like*. - Query: place.stream.vod.getLikes -> place.stream.getLikes (regenerated types VodGetLikes_* -> GetLikes_*, stub, handler, docs/openapi). - Frontend: useCreateVodLike/useDeleteVodLike/useGetVodLikes/useVodLikeCount -> useCreateLike/useDeleteLike/useGetLikes/useLikeCount; VodLikeButton -> LikeButton; client path place.stream.vod.getLikes -> place.stream.getLikes. Safe since nothing uses likes in a live UI yet; the table rename re-indexes off the firehose. Co-Authored-By: Claude Opus 4.8 --- .../{vod-like-button.tsx => like-button.tsx} | 14 +-- .../components/vod/vod-mobile-metadata.tsx | 4 +- js/components/src/index.tsx | 2 +- .../src/vod-store/vod-interactions.tsx | 16 +-- .../content/docs/lex-reference/openapi.json | 102 +++++++++--------- ...d-getlikes.md => place-stream-getlikes.md} | 6 +- lexicons/place/stream/{vod => }/getLikes.json | 2 +- pkg/atproto/firehose.go | 2 +- pkg/atproto/sync.go | 4 +- pkg/model/{vod_like.go => like.go} | 34 +++--- pkg/model/model.go | 12 +-- pkg/spxrpc/place_stream_vod.go | 4 +- pkg/spxrpc/stubs.go | 54 +++++----- .../{vodgetLikes.go => streamgetLikes.go} | 26 ++--- 14 files changed, 141 insertions(+), 141 deletions(-) rename js/components/src/components/vod/{vod-like-button.tsx => like-button.tsx} (89%) rename js/docs/src/content/docs/lex-reference/{vod/place-stream-vod-getlikes.md => place-stream-getlikes.md} (97%) rename lexicons/place/stream/{vod => }/getLikes.json (98%) rename pkg/model/{vod_like.go => like.go} (72%) rename pkg/streamplace/{vodgetLikes.go => streamgetLikes.go} (53%) diff --git a/js/components/src/components/vod/vod-like-button.tsx b/js/components/src/components/vod/like-button.tsx similarity index 89% rename from js/components/src/components/vod/vod-like-button.tsx rename to js/components/src/components/vod/like-button.tsx index 3d381661..ec6d86f3 100644 --- a/js/components/src/components/vod/vod-like-button.tsx +++ b/js/components/src/components/vod/like-button.tsx @@ -3,22 +3,22 @@ import { TouchableOpacity, View } from "react-native"; import { useDID } from "../../streamplace-store/streamplace-store"; import { gap, layout, p, useTheme } from "../../ui"; import { - useCreateVodLike, - useDeleteVodLike, - useGetVodLikes, + useCreateLike, + useDeleteLike, + useGetLikes, } from "../../vod-store/vod-interactions"; import { Text } from "../ui/text"; -export function VodLikeButton({ subjectUri }: { subjectUri: string }) { +export function LikeButton({ subjectUri }: { subjectUri: string }) { const [likeCount, setLikeCount] = useState(0); const [userLiked, setUserLiked] = useState(false); const [userLikeUri, setUserLikeUri] = useState(null); const [loading, setLoading] = useState(false); const userDID = useDID(); - const getLikes = useGetVodLikes(); - const createLike = useCreateVodLike(); - const deleteLike = useDeleteVodLike(); + const getLikes = useGetLikes(); + const createLike = useCreateLike(); + const deleteLike = useDeleteLike(); const { theme } = useTheme(); const loadLikes = useCallback(async () => { diff --git a/js/components/src/components/vod/vod-mobile-metadata.tsx b/js/components/src/components/vod/vod-mobile-metadata.tsx index a8fa26b2..8752114e 100644 --- a/js/components/src/components/vod/vod-mobile-metadata.tsx +++ b/js/components/src/components/vod/vod-mobile-metadata.tsx @@ -4,7 +4,7 @@ import { useTitle } from "../../hooks/useTitle"; import { borders, gap, layout, mb, pb, useTheme } from "../../ui"; import { useVideoStore } from "../../video-store/video-store"; import { Text } from "../ui/text"; -import { VodLikeButton } from "./vod-like-button"; +import { LikeButton } from "./like-button"; export function VodMobileMetadata() { const video = useVideoStore((x) => x.video); @@ -46,7 +46,7 @@ export function VodMobileMetadata() { - + {viewCount.toLocaleString()} view{viewCount !== 1 ? "s" : ""} diff --git a/js/components/src/index.tsx b/js/components/src/index.tsx index 48888631..3ff10fed 100644 --- a/js/components/src/index.tsx +++ b/js/components/src/index.tsx @@ -83,8 +83,8 @@ export { } from "./lib/metadata-constants"; // VOD components and interaction hooks +export * from "./components/vod/like-button"; export * from "./components/vod/vod-comments"; -export * from "./components/vod/vod-like-button"; export * from "./components/vod/vod-mobile-metadata"; export * from "./components/vod/vod-player"; export * from "./components/vod/vod-section"; diff --git a/js/components/src/vod-store/vod-interactions.tsx b/js/components/src/vod-store/vod-interactions.tsx index 922c34b2..6a79e414 100644 --- a/js/components/src/vod-store/vod-interactions.tsx +++ b/js/components/src/vod-store/vod-interactions.tsx @@ -1,10 +1,10 @@ import { useCallback } from "react"; import { + PlaceStreamGetLikes, PlaceStreamLike, PlaceStreamVodComment, PlaceStreamVodDefs, PlaceStreamVodGetComments, - PlaceStreamVodGetLikes, } from "streamplace"; import { useDID } from "../streamplace-store/streamplace-store"; import { usePDSAgent } from "../streamplace-store/xrpc"; @@ -57,7 +57,7 @@ export const useDeleteVodComment = () => { ); }; -export const useCreateVodLike = () => { +export const useCreateLike = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); @@ -83,7 +83,7 @@ export const useCreateVodLike = () => { ); }; -export const useDeleteVodLike = () => { +export const useDeleteLike = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); @@ -127,7 +127,7 @@ export const useGetVodComments = () => { ); }; -export const useGetVodLikes = () => { +export const useGetLikes = () => { const pdsAgent = usePDSAgent(); return useCallback( @@ -135,11 +135,11 @@ export const useGetVodLikes = () => { subject: string, limit?: number, cursor?: string, - ): Promise => { + ): Promise => { if (!pdsAgent) { throw new Error("No PDS agent found"); } - const res = await pdsAgent.place.stream.vod.getLikes({ + const res = await pdsAgent.place.stream.getLikes({ subject, limit, cursor, @@ -150,7 +150,7 @@ export const useGetVodLikes = () => { ); }; -export const useVodLikeCount = () => { +export const useLikeCount = () => { const pdsAgent = usePDSAgent(); return useCallback( @@ -158,7 +158,7 @@ export const useVodLikeCount = () => { if (!pdsAgent) { throw new Error("No PDS agent found"); } - const res = await pdsAgent.place.stream.vod.getLikes({ + const res = await pdsAgent.place.stream.getLikes({ subject, limit: 1, }); diff --git a/js/docs/src/content/docs/lex-reference/openapi.json b/js/docs/src/content/docs/lex-reference/openapi.json index 58969855..7401f045 100644 --- a/js/docs/src/content/docs/lex-reference/openapi.json +++ b/js/docs/src/content/docs/lex-reference/openapi.json @@ -6,11 +6,11 @@ "description": "Autogenerated using lexmd" }, "paths": { - "/xrpc/place.stream.vod.getComments": { + "/xrpc/place.stream.getLikes": { "get": { - "summary": "Get comments for a place.stream.video record.", - "operationId": "place.stream.vod.getComments", - "tags": ["place.stream.vod"], + "summary": "Get likes for a subject (video or comment).", + "operationId": "place.stream.getLikes", + "tags": ["place.stream"], "responses": { "200": { "description": "Success", @@ -19,17 +19,26 @@ "schema": { "type": "object", "properties": { + "subject": { + "type": "string", + "format": "uri" + }, + "count": { + "type": "integer", + "description": "Total number of likes for this subject.", + "minimum": 0 + }, "cursor": { "type": "string" }, - "comments": { + "likes": { "type": "array", "items": { - "$ref": "#/components/schemas/place.stream.vod.defs_commentView" + "$ref": "#/components/schemas/place.stream.getLikes_likeView" } } }, - "required": ["comments"] + "required": ["subject", "count"] } } } @@ -37,13 +46,13 @@ }, "parameters": [ { - "name": "video", + "name": "subject", "in": "query", "required": true, - "description": "AT-URI of the place.stream.video record.", + "description": "AT-URI of the subject (video or comment).", "schema": { "type": "string", - "description": "AT-URI of the place.stream.video record.", + "description": "AT-URI of the subject (video or comment).", "format": "uri" } }, @@ -61,10 +70,10 @@ "name": "limit", "in": "query", "required": false, - "description": "Maximum number of comments to return.", + "description": "Maximum number of likes to return.", "schema": { "type": "integer", - "description": "Maximum number of comments to return.", + "description": "Maximum number of likes to return.", "default": 50, "minimum": 1, "maximum": 100 @@ -73,10 +82,10 @@ ] } }, - "/xrpc/place.stream.vod.getLikes": { + "/xrpc/place.stream.vod.getComments": { "get": { - "summary": "Get likes for a subject (video or comment).", - "operationId": "place.stream.vod.getLikes", + "summary": "Get comments for a place.stream.video record.", + "operationId": "place.stream.vod.getComments", "tags": ["place.stream.vod"], "responses": { "200": { @@ -86,26 +95,17 @@ "schema": { "type": "object", "properties": { - "subject": { - "type": "string", - "format": "uri" - }, - "count": { - "type": "integer", - "description": "Total number of likes for this subject.", - "minimum": 0 - }, "cursor": { "type": "string" }, - "likes": { + "comments": { "type": "array", "items": { - "$ref": "#/components/schemas/place.stream.vod.getLikes_likeView" + "$ref": "#/components/schemas/place.stream.vod.defs_commentView" } } }, - "required": ["subject", "count"] + "required": ["comments"] } } } @@ -113,13 +113,13 @@ }, "parameters": [ { - "name": "subject", + "name": "video", "in": "query", "required": true, - "description": "AT-URI of the subject (video or comment).", + "description": "AT-URI of the place.stream.video record.", "schema": { "type": "string", - "description": "AT-URI of the subject (video or comment).", + "description": "AT-URI of the place.stream.video record.", "format": "uri" } }, @@ -137,10 +137,10 @@ "name": "limit", "in": "query", "required": false, - "description": "Maximum number of likes to return.", + "description": "Maximum number of comments to return.", "schema": { "type": "integer", - "description": "Maximum number of likes to return.", + "description": "Maximum number of comments to return.", "default": 50, "minimum": 1, "maximum": 100 @@ -4931,7 +4931,7 @@ }, "components": { "schemas": { - "place.stream.vod.defs_commentView": { + "place.stream.getLikes_likeView": { "type": "object", "properties": { "uri": { @@ -4949,22 +4949,9 @@ "indexedAt": { "type": "string", "format": "date-time" - }, - "replyTo": { - "oneOf": [ - { - "$ref": "#/components/schemas/place.stream.vod.defs_commentViewBasic" - } - ], - "description": "The parent comment this one replies to, if any. A non-recursive view (it carries no replyTo of its own), so the thread is flattened to a single hop; walk `record.reply` to follow the chain further." - }, - "likeCount": { - "type": "integer", - "description": "Number of likes on this comment.", - "minimum": 0 } }, - "required": ["uri", "cid", "author", "record", "indexedAt", "likeCount"] + "required": ["uri", "cid", "author", "record", "indexedAt"] }, "app.bsky.actor.defs_profileViewBasic": { "type": "object", @@ -5303,9 +5290,8 @@ }, "required": ["uri", "title", "description"] }, - "place.stream.vod.defs_commentViewBasic": { + "place.stream.vod.defs_commentView": { "type": "object", - "description": "A comment view without its own `replyTo`, used to represent the parent of a reply without recursively nesting the whole thread.", "properties": { "uri": { "type": "string", @@ -5323,6 +5309,14 @@ "type": "string", "format": "date-time" }, + "replyTo": { + "oneOf": [ + { + "$ref": "#/components/schemas/place.stream.vod.defs_commentViewBasic" + } + ], + "description": "The parent comment this one replies to, if any. A non-recursive view (it carries no replyTo of its own), so the thread is flattened to a single hop; walk `record.reply` to follow the chain further." + }, "likeCount": { "type": "integer", "description": "Number of likes on this comment.", @@ -5331,8 +5325,9 @@ }, "required": ["uri", "cid", "author", "record", "indexedAt", "likeCount"] }, - "place.stream.vod.getLikes_likeView": { + "place.stream.vod.defs_commentViewBasic": { "type": "object", + "description": "A comment view without its own `replyTo`, used to represent the parent of a reply without recursively nesting the whole thread.", "properties": { "uri": { "type": "string", @@ -5349,9 +5344,14 @@ "indexedAt": { "type": "string", "format": "date-time" + }, + "likeCount": { + "type": "integer", + "description": "Number of likes on this comment.", + "minimum": 0 } }, - "required": ["uri", "cid", "author", "record", "indexedAt"] + "required": ["uri", "cid", "author", "record", "indexedAt", "likeCount"] }, "place.stream.server.defs_rewriteRule": { "type": "object", diff --git a/js/docs/src/content/docs/lex-reference/vod/place-stream-vod-getlikes.md b/js/docs/src/content/docs/lex-reference/place-stream-getlikes.md similarity index 97% rename from js/docs/src/content/docs/lex-reference/vod/place-stream-vod-getlikes.md rename to js/docs/src/content/docs/lex-reference/place-stream-getlikes.md index dae716a1..743fbd06 100644 --- a/js/docs/src/content/docs/lex-reference/vod/place-stream-vod-getlikes.md +++ b/js/docs/src/content/docs/lex-reference/place-stream-getlikes.md @@ -1,6 +1,6 @@ --- -title: place.stream.vod.getLikes -description: Reference for the place.stream.vod.getLikes lexicon +title: place.stream.getLikes +description: Reference for the place.stream.getLikes lexicon --- **Lexicon Version:** 1 @@ -62,7 +62,7 @@ Get likes for a subject (video or comment). ```json { "lexicon": 1, - "id": "place.stream.vod.getLikes", + "id": "place.stream.getLikes", "defs": { "main": { "type": "query", diff --git a/lexicons/place/stream/vod/getLikes.json b/lexicons/place/stream/getLikes.json similarity index 98% rename from lexicons/place/stream/vod/getLikes.json rename to lexicons/place/stream/getLikes.json index b63c64fc..abdb8b7d 100644 --- a/lexicons/place/stream/vod/getLikes.json +++ b/lexicons/place/stream/getLikes.json @@ -1,6 +1,6 @@ { "lexicon": 1, - "id": "place.stream.vod.getLikes", + "id": "place.stream.getLikes", "defs": { "main": { "type": "query", diff --git a/pkg/atproto/firehose.go b/pkg/atproto/firehose.go index 5c55a1a6..a5d76377 100644 --- a/pkg/atproto/firehose.go +++ b/pkg/atproto/firehose.go @@ -421,7 +421,7 @@ func (atsync *ATProtoSynchronizer) handleCommitEventOps(ctx context.Context, evt if collection.String() == constants.PLACE_STREAM_LIKE { log.Debug(ctx, "deleting like", "uri", uri) - if err := atsync.Model.DeleteVodLike(ctx, uri); err != nil { + if err := atsync.Model.DeleteLike(ctx, uri); err != nil { log.Error(ctx, "failed to delete like", "err", err) } } diff --git a/pkg/atproto/sync.go b/pkg/atproto/sync.go index d698e873..681bc186 100644 --- a/pkg/atproto/sync.go +++ b/pkg/atproto/sync.go @@ -889,7 +889,7 @@ func (atsync *ATProtoSynchronizer) handleCreateUpdate(ctx context.Context, userD log.Debug(ctx, "place.stream.like detected", "subject", rec.Subject, "repo", repo.Handle) - like := &model.VodLike{ + like := &model.Like{ CID: cid, URI: aturi.String(), Subject: rec.Subject, @@ -898,7 +898,7 @@ func (atsync *ATProtoSynchronizer) handleCreateUpdate(ctx context.Context, userD IndexedAt: &now, CreatedAt: now, } - err = atsync.Model.CreateVodLike(ctx, like) + err = atsync.Model.CreateLike(ctx, like) if err != nil { log.Error(ctx, "failed to create VOD like", "err", err) return nil diff --git a/pkg/model/vod_like.go b/pkg/model/like.go similarity index 72% rename from pkg/model/vod_like.go rename to pkg/model/like.go index 25945098..b2cb3652 100644 --- a/pkg/model/vod_like.go +++ b/pkg/model/like.go @@ -12,22 +12,22 @@ import ( "stream.place/streamplace/pkg/streamplace" ) -type VodLike struct { +type Like struct { CID string `json:"cid" gorm:"primaryKey;column:cid"` URI string `json:"uri" gorm:"column:uri"` - Subject string `json:"subject" gorm:"column:subject;index:idx_vod_likes_subject"` + Subject string `json:"subject" gorm:"column:subject;index:idx_likes_subject"` RepoDID string `json:"repoDID" gorm:"column:repo_did"` Repo *Repo `json:"repo,omitempty" gorm:"foreignKey:DID;references:RepoDID"` IndexedAt *time.Time `json:"indexedAt" gorm:"column:indexed_at"` CreatedAt time.Time `json:"createdAt" gorm:"column:created_at"` } -func (l *VodLike) ToStreamplaceLikeView() (*streamplace.VodGetLikes_LikeView, error) { +func (l *Like) ToStreamplaceLikeView() (*streamplace.GetLikes_LikeView, error) { rec, err := lexutil.CborDecodeValue([]byte{}) if err != nil { rec = &streamplace.Like{Subject: l.Subject, CreatedAt: l.CreatedAt.Format(time.RFC3339)} } - return &streamplace.VodGetLikes_LikeView{ + return &streamplace.GetLikes_LikeView{ Uri: l.URI, Cid: l.CID, Record: &lexutil.LexiconTypeDecoder{Val: rec}, @@ -44,20 +44,20 @@ func (l *VodLike) ToStreamplaceLikeView() (*streamplace.VodGetLikes_LikeView, er }, nil } -func (m *DBModel) CreateVodLike(ctx context.Context, like *VodLike) error { +func (m *DBModel) CreateLike(ctx context.Context, like *Like) error { return m.DB.Create(like).Error } -func (m *DBModel) DeleteVodLike(ctx context.Context, uri string) error { - tx := m.DB.Where("uri = ?", uri).Delete(&VodLike{}) +func (m *DBModel) DeleteLike(ctx context.Context, uri string) error { + tx := m.DB.Where("uri = ?", uri).Delete(&Like{}) if tx.Error != nil { return tx.Error } return nil } -func (m *DBModel) GetVodLike(uri string) (*VodLike, error) { - var like VodLike +func (m *DBModel) GetLike(uri string) (*Like, error) { + var like Like err := m.DB.Preload("Repo").Where("uri = ?", uri).First(&like).Error if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil @@ -68,8 +68,8 @@ func (m *DBModel) GetVodLike(uri string) (*VodLike, error) { return &like, nil } -func (m *DBModel) GetVodLikeBySubjectAndUser(ctx context.Context, subject string, repoDID string) (*VodLike, error) { - var like VodLike +func (m *DBModel) GetLikeBySubjectAndUser(ctx context.Context, subject string, repoDID string) (*Like, error) { + var like Like err := m.DB.Preload("Repo").Where("subject = ? AND repo_did = ?", subject, repoDID).First(&like).Error if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil @@ -77,21 +77,21 @@ func (m *DBModel) GetVodLikeBySubjectAndUser(ctx context.Context, subject string return &like, nil } -func (m *DBModel) GetLikesForSubject(ctx context.Context, subject string, limit int, cursor *time.Time) ([]*streamplace.VodGetLikes_LikeView, int64, *time.Time, error) { +func (m *DBModel) GetLikesForSubject(ctx context.Context, subject string, limit int, cursor *time.Time) ([]*streamplace.GetLikes_LikeView, int64, *time.Time, error) { count, err := m.GetLikeCount(ctx, subject) if err != nil { return nil, 0, nil, err } - dblikes := []VodLike{} + dblikes := []Like{} query := m.DB. Preload("Repo"). Where("subject = ?", subject) if cursor != nil { - query = query.Where("vod_likes.created_at < ?", *cursor) + query = query.Where("likes.created_at < ?", *cursor) } err = query. Limit(limit + 1). - Order("vod_likes.created_at DESC"). + Order("likes.created_at DESC"). Find(&dblikes).Error if err != nil { return nil, 0, nil, fmt.Errorf("error retrieving likes: %w", err) @@ -101,7 +101,7 @@ func (m *DBModel) GetLikesForSubject(ctx context.Context, subject string, limit nextCursor = &dblikes[limit-1].CreatedAt dblikes = dblikes[:limit] } - views := []*streamplace.VodGetLikes_LikeView{} + views := []*streamplace.GetLikes_LikeView{} for _, l := range dblikes { view, err := l.ToStreamplaceLikeView() if err != nil { @@ -114,6 +114,6 @@ func (m *DBModel) GetLikesForSubject(ctx context.Context, subject string, limit func (m *DBModel) GetLikeCount(ctx context.Context, subject string) (int64, error) { var count int64 - err := m.DB.Model(&VodLike{}).Where("subject = ?", subject).Count(&count).Error + err := m.DB.Model(&Like{}).Where("subject = ?", subject).Count(&count).Error return count, err } diff --git a/pkg/model/model.go b/pkg/model/model.go index 69d1d7e8..cf0db402 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -166,11 +166,11 @@ type Model interface { GetVodComment(uri string) (*VodComment, error) GetCommentsForVideo(ctx context.Context, videoURI string, limit int, cursor *time.Time) ([]*streamplace.VodDefs_CommentView, *time.Time, error) - CreateVodLike(ctx context.Context, like *VodLike) error - DeleteVodLike(ctx context.Context, uri string) error - GetVodLike(uri string) (*VodLike, error) - GetVodLikeBySubjectAndUser(ctx context.Context, subject string, repoDID string) (*VodLike, error) - GetLikesForSubject(ctx context.Context, subject string, limit int, cursor *time.Time) ([]*streamplace.VodGetLikes_LikeView, int64, *time.Time, error) + CreateLike(ctx context.Context, like *Like) error + DeleteLike(ctx context.Context, uri string) error + GetLike(uri string) (*Like, error) + GetLikeBySubjectAndUser(ctx context.Context, subject string, repoDID string) (*Like, error) + GetLikesForSubject(ctx context.Context, subject string, limit int, cursor *time.Time) ([]*streamplace.GetLikes_LikeView, int64, *time.Time, error) GetLikeCount(ctx context.Context, subject string) (int64, error) CreateVodGate(ctx context.Context, gate *VodGate) error @@ -259,7 +259,7 @@ func MakeDB(dbURL string) (Model, error) { BetaInvite{}, BetaRequest{}, VodComment{}, - VodLike{}, + Like{}, VodGate{}, } { err = db.AutoMigrate(model) diff --git a/pkg/spxrpc/place_stream_vod.go b/pkg/spxrpc/place_stream_vod.go index 9dd074f4..75a9f655 100644 --- a/pkg/spxrpc/place_stream_vod.go +++ b/pkg/spxrpc/place_stream_vod.go @@ -44,7 +44,7 @@ func (s *Server) handlePlaceStreamVodGetComments(ctx context.Context, cursor str return out, nil } -func (s *Server) handlePlaceStreamVodGetLikes(ctx context.Context, cursor string, limit int, subject string) (*placestream.VodGetLikes_Output, error) { +func (s *Server) handlePlaceStreamGetLikes(ctx context.Context, cursor string, limit int, subject string) (*placestream.GetLikes_Output, error) { if subject == "" { return nil, echo.NewHTTPError(http.StatusBadRequest, "subject is required") } @@ -67,7 +67,7 @@ func (s *Server) handlePlaceStreamVodGetLikes(ctx context.Context, cursor string if err != nil { return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - out := &placestream.VodGetLikes_Output{ + out := &placestream.GetLikes_Output{ Subject: subject, Count: count, Likes: likes, diff --git a/pkg/spxrpc/stubs.go b/pkg/spxrpc/stubs.go index 0d1ce776..abbddb30 100644 --- a/pkg/spxrpc/stubs.go +++ b/pkg/spxrpc/stubs.go @@ -293,6 +293,7 @@ func (s *Server) RegisterHandlersPlaceStream(e *echo.Echo) error { e.GET("/xrpc/place.stream.config.getEnv", s.HandlePlaceStreamConfigGetEnv) e.GET("/xrpc/place.stream.game.getGame", s.HandlePlaceStreamGameGetGame) e.GET("/xrpc/place.stream.game.search", s.HandlePlaceStreamGameSearch) + e.GET("/xrpc/place.stream.getLikes", s.HandlePlaceStreamGetLikes) e.GET("/xrpc/place.stream.graph.getFollowingUser", s.HandlePlaceStreamGraphGetFollowingUser) e.GET("/xrpc/place.stream.ingest.getIngestUrls", s.HandlePlaceStreamIngestGetIngestUrls) e.POST("/xrpc/place.stream.live.denyTeleport", s.HandlePlaceStreamLiveDenyTeleport) @@ -337,7 +338,6 @@ func (s *Server) RegisterHandlersPlaceStream(e *echo.Echo) error { e.POST("/xrpc/place.stream.server.updateWebhook", s.HandlePlaceStreamServerUpdateWebhook) e.POST("/xrpc/place.stream.server.upsertStorage", s.HandlePlaceStreamServerUpsertStorage) e.GET("/xrpc/place.stream.vod.getComments", s.HandlePlaceStreamVodGetComments) - e.GET("/xrpc/place.stream.vod.getLikes", s.HandlePlaceStreamVodGetLikes) return nil } @@ -515,6 +515,32 @@ func (s *Server) HandlePlaceStreamGameSearch(c echo.Context) error { return c.JSON(200, out) } +func (s *Server) HandlePlaceStreamGetLikes(c echo.Context) error { + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamGetLikes") + defer span.End() + cursor := c.QueryParam("cursor") + + var limit int + if p := c.QueryParam("limit"); p != "" { + var err error + limit, err = strconv.Atoi(p) + if err != nil { + return err + } + } else { + limit = 50 + } + subject := c.QueryParam("subject") + var out *placestream.GetLikes_Output + var handleErr error + // func (s *Server) handlePlaceStreamGetLikes(ctx context.Context,cursor string,limit int,subject string) (*placestream.GetLikes_Output, error) + out, handleErr = s.handlePlaceStreamGetLikes(ctx, cursor, limit, subject) + if handleErr != nil { + return handleErr + } + return c.JSON(200, out) +} + func (s *Server) HandlePlaceStreamGraphGetFollowingUser(c echo.Context) error { ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamGraphGetFollowingUser") defer span.End() @@ -1332,32 +1358,6 @@ func (s *Server) HandlePlaceStreamVodGetComments(c echo.Context) error { return c.JSON(200, out) } -func (s *Server) HandlePlaceStreamVodGetLikes(c echo.Context) error { - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamVodGetLikes") - defer span.End() - cursor := c.QueryParam("cursor") - - var limit int - if p := c.QueryParam("limit"); p != "" { - var err error - limit, err = strconv.Atoi(p) - if err != nil { - return err - } - } else { - limit = 50 - } - subject := c.QueryParam("subject") - var out *placestream.VodGetLikes_Output - var handleErr error - // func (s *Server) handlePlaceStreamVodGetLikes(ctx context.Context,cursor string,limit int,subject string) (*placestream.VodGetLikes_Output, error) - out, handleErr = s.handlePlaceStreamVodGetLikes(ctx, cursor, limit, subject) - if handleErr != nil { - return handleErr - } - return c.JSON(200, out) -} - func (s *Server) RegisterHandlersToolsOzone(e *echo.Echo) error { return nil } diff --git a/pkg/streamplace/vodgetLikes.go b/pkg/streamplace/streamgetLikes.go similarity index 53% rename from pkg/streamplace/vodgetLikes.go rename to pkg/streamplace/streamgetLikes.go index 679d7b12..8afd877a 100644 --- a/pkg/streamplace/vodgetLikes.go +++ b/pkg/streamplace/streamgetLikes.go @@ -1,6 +1,6 @@ // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. -// Lexicon schema: place.stream.vod.getLikes +// Lexicon schema: place.stream.getLikes package streamplace @@ -11,8 +11,8 @@ import ( lexutil "github.com/bluesky-social/indigo/lex/util" ) -// VodGetLikes_LikeView is a "likeView" in the place.stream.vod.getLikes schema. -type VodGetLikes_LikeView struct { +// GetLikes_LikeView is a "likeView" in the place.stream.getLikes schema. +type GetLikes_LikeView struct { Author *appbsky.ActorDefs_ProfileViewBasic `json:"author" cborgen:"author"` Cid string `json:"cid" cborgen:"cid"` IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` @@ -20,22 +20,22 @@ type VodGetLikes_LikeView struct { Uri string `json:"uri" cborgen:"uri"` } -// VodGetLikes_Output is the output of a place.stream.vod.getLikes call. -type VodGetLikes_Output struct { +// GetLikes_Output is the output of a place.stream.getLikes call. +type GetLikes_Output struct { // count: Total number of likes for this subject. - Count int64 `json:"count" cborgen:"count"` - Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` - Likes []*VodGetLikes_LikeView `json:"likes,omitempty" cborgen:"likes,omitempty"` - Subject string `json:"subject" cborgen:"subject"` + Count int64 `json:"count" cborgen:"count"` + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + Likes []*GetLikes_LikeView `json:"likes,omitempty" cborgen:"likes,omitempty"` + Subject string `json:"subject" cborgen:"subject"` } -// VodGetLikes calls the XRPC method "place.stream.vod.getLikes". +// GetLikes calls the XRPC method "place.stream.getLikes". // // cursor: Optional pagination cursor. // limit: Maximum number of likes to return. // subject: AT-URI of the subject (video or comment). -func VodGetLikes(ctx context.Context, c lexutil.LexClient, cursor string, limit int64, subject string) (*VodGetLikes_Output, error) { - var out VodGetLikes_Output +func GetLikes(ctx context.Context, c lexutil.LexClient, cursor string, limit int64, subject string) (*GetLikes_Output, error) { + var out GetLikes_Output params := map[string]interface{}{} if cursor != "" { @@ -45,7 +45,7 @@ func VodGetLikes(ctx context.Context, c lexutil.LexClient, cursor string, limit params["limit"] = limit } params["subject"] = subject - if err := c.LexDo(ctx, lexutil.Query, "", "place.stream.vod.getLikes", params, nil, &out); err != nil { + if err := c.LexDo(ctx, lexutil.Query, "", "place.stream.getLikes", params, nil, &out); err != nil { return nil, err } -- 2.51.2