Live video on the AT Protocol

updating chat.hide to chat.gate

+113 -113
+3 -3
js/components/src/livestream-store/websocket-consumer.tsx
··· 3 3 ChatMessageViewHydrated, 4 4 LivestreamViewHydrated, 5 5 PlaceStreamChatDefs, 6 - PlaceStreamChatHide, 6 + PlaceStreamChatGate, 7 7 PlaceStreamChatMessage, 8 8 PlaceStreamDefs, 9 9 PlaceStreamLivestream, ··· 57 57 ...state, 58 58 profile: message, 59 59 }; 60 - } else if (PlaceStreamChatHide.isRecord(message)) { 61 - const hideRecord = message as PlaceStreamChatHide.Record; 60 + } else if (PlaceStreamChatGate.isRecord(message)) { 61 + const hideRecord = message as PlaceStreamChatGate.Record; 62 62 const hiddenMessageUri = hideRecord.hiddenMessage; 63 63 const newPendingHides = [...state.pendingHides]; 64 64 if (!newPendingHides.includes(hiddenMessageUri)) {
+2 -2
js/components/src/streamplace-store/block.tsx
··· 41 41 } 42 42 43 43 const record = { 44 - $type: "place.stream.chat.hide", 44 + $type: "place.stream.chat.gate", 45 45 hiddenMessage: chatMessageUri, 46 46 }; 47 47 48 48 return await agent.com.atproto.repo.createRecord({ 49 49 repo: agent.did, 50 - collection: "place.stream.chat.hide", 50 + collection: "place.stream.chat.gate", 51 51 record, 52 52 }); 53 53 };
+5 -5
js/docs/src/content/docs/lex-reference/chat/place-stream-chat-hide.md js/docs/src/content/docs/lex-reference/chat/place-stream-chat-gate.md
··· 1 1 --- 2 - title: place.stream.chat.hide 3 - description: Reference for the place.stream.chat.hide lexicon 2 + title: place.stream.chat.gate 3 + description: Reference for the place.stream.chat.gate lexicon 4 4 --- 5 5 6 6 **Lexicon Version:** 1 ··· 13 13 14 14 **Type:** `record` 15 15 16 - Record defining a single hidden chat message. 16 + Record defining a single gated chat message. 17 17 18 18 **Record Key:** `tid` 19 19 ··· 30 30 ```json 31 31 { 32 32 "lexicon": 1, 33 - "id": "place.stream.chat.hide", 33 + "id": "place.stream.chat.gate", 34 34 "defs": { 35 35 "main": { 36 36 "type": "record", 37 37 "key": "tid", 38 - "description": "Record defining a single hidden chat message.", 38 + "description": "Record defining a single gated chat message.", 39 39 "record": { 40 40 "type": "object", 41 41 "required": ["hiddenMessage"],
+2 -2
lexicons/place/stream/chat/hide.json lexicons/place/stream/chat/gate.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "place.stream.chat.hide", 3 + "id": "place.stream.chat.gate", 4 4 "defs": { 5 5 "main": { 6 6 "type": "record", 7 7 "key": "tid", 8 - "description": "Record defining a single hidden chat message.", 8 + "description": "Record defining a single gated chat message.", 9 9 "record": { 10 10 "type": "object", 11 11 "required": ["hiddenMessage"],
+1 -1
pkg/atproto/firehose.go
··· 151 151 constants.APP_BSKY_FEED_POST, 152 152 constants.APP_BSKY_GRAPH_BLOCK, 153 153 constants.PLACE_STREAM_SERVER_SETTINGS, 154 - constants.PLACE_STREAM_CHAT_HIDE, 154 + constants.PLACE_STREAM_CHAT_GATE, 155 155 } 156 156 157 157 func (atsync *ATProtoSynchronizer) handleCommitEventOps(ctx context.Context, evt *comatproto.SyncSubscribeRepos_Commit) {
+10 -10
pkg/atproto/sync.go
··· 148 148 } 149 149 } 150 150 151 - case *streamplace.ChatHide: 151 + case *streamplace.ChatGate: 152 152 repo, err := atsync.SyncBlueskyRepoCached(ctx, userDID, atsync.Model) 153 153 if err != nil { 154 154 return fmt.Errorf("failed to sync bluesky repo: %w", err) ··· 157 157 // someone we don't know about 158 158 return nil 159 159 } 160 - log.Debug(ctx, "creating hide", "userDID", userDID, "hiddenMessage", rec.HiddenMessage) 161 - hide := &model.Hide{ 160 + log.Debug(ctx, "creating gate", "userDID", userDID, "hiddenMessage", rec.HiddenMessage) 161 + gate := &model.Gate{ 162 162 RKey: rkey.String(), 163 163 RepoDID: userDID, 164 164 HiddenMessage: rec.HiddenMessage, ··· 166 166 CreatedAt: now, 167 167 Repo: repo, 168 168 } 169 - err = atsync.Model.CreateHide(ctx, hide) 169 + err = atsync.Model.CreateGate(ctx, gate) 170 170 if err != nil { 171 - return fmt.Errorf("failed to create hide: %w", err) 171 + return fmt.Errorf("failed to create gate: %w", err) 172 172 } 173 - hide, err = atsync.Model.GetHide(ctx, rkey.String()) 173 + gate, err = atsync.Model.GetGate(ctx, rkey.String()) 174 174 if err != nil { 175 - return fmt.Errorf("failed to get hide after we just saved it?!: %w", err) 175 + return fmt.Errorf("failed to get gate after we just saved it?!: %w", err) 176 176 } 177 - streamplaceHide, err := hide.ToStreamplaceHide() 177 + streamplaceGate, err := gate.ToStreamplaceGate() 178 178 if err != nil { 179 - return fmt.Errorf("failed to convert hide to streamplace hide: %w", err) 179 + return fmt.Errorf("failed to convert gate to streamplace gate: %w", err) 180 180 } 181 - go atsync.Bus.Publish(userDID, streamplaceHide) 181 + go atsync.Bus.Publish(userDID, streamplaceGate) 182 182 183 183 case *streamplace.ChatProfile: 184 184 repo, err := atsync.SyncBlueskyRepoCached(ctx, userDID, atsync.Model)
+1 -1
pkg/constants/constants.go
··· 9 9 var APP_BSKY_GRAPH_FOLLOW = "app.bsky.graph.follow" //nolint:all 10 10 var APP_BSKY_FEED_POST = "app.bsky.feed.post" //nolint:all 11 11 var APP_BSKY_GRAPH_BLOCK = "app.bsky.graph.block" //nolint:all 12 - var PLACE_STREAM_CHAT_HIDE = "place.stream.chat.hide" //nolint:all 12 + var PLACE_STREAM_CHAT_GATE = "place.stream.chat.gate" //nolint:all 13 13 14 14 const DID_KEY_PREFIX = "did:key" //nolint:all 15 15 const ADDRESS_KEY_PREFIX = "0x" //nolint:all
+1 -1
pkg/gen/gen.go
··· 24 24 streamplace.ChatProfile_Color{}, 25 25 streamplace.ChatMessage_ReplyRef{}, 26 26 streamplace.ServerSettings{}, 27 - streamplace.ChatHide{}, 27 + streamplace.ChatGate{}, 28 28 ); err != nil { 29 29 panic(err) 30 30 }
+3 -3
pkg/model/chat_message.go
··· 115 115 // Exclude messages from users blocked by the streamer 116 116 Joins("LEFT JOIN blocks ON blocks.repo_did = chat_messages.streamer_repo_did AND blocks.subject_did = chat_messages.repo_did"). 117 117 Where("blocks.rkey IS NULL"). // Only include messages where no block exists 118 - // Exclude hidden messages 119 - Joins("LEFT JOIN hides ON hides.repo_did = chat_messages.streamer_repo_did AND hides.hidden_message = chat_messages.uri"). 120 - Where("hides.hidden_message IS NULL"). // Only include messages where no hide exists 118 + // Exclude gated messages 119 + Joins("LEFT JOIN gates ON gates.repo_did = chat_messages.streamer_repo_did AND gates.hidden_message = chat_messages.uri"). 120 + Where("gates.hidden_message IS NULL"). // Only include messages where no gate exists 121 121 Limit(100). 122 122 Order("chat_messages.created_at DESC"). 123 123 Find(&dbmessages).Error
+55
pkg/model/gate.go
··· 1 + package model 2 + 3 + import ( 4 + "context" 5 + "errors" 6 + "time" 7 + 8 + "gorm.io/gorm" 9 + "stream.place/streamplace/pkg/streamplace" 10 + ) 11 + 12 + type Gate struct { 13 + RKey string `gorm:"primaryKey;column:rkey"` 14 + CID string `gorm:"column:cid"` 15 + RepoDID string `json:"repoDID" gorm:"column:repo_did"` 16 + Repo *Repo `json:"repo,omitempty" gorm:"foreignKey:DID;references:RepoDID"` 17 + HiddenMessage string `gorm:"column:hidden_message" json:"hiddenMessage"` 18 + CreatedAt time.Time `gorm:"column:created_at"` 19 + } 20 + 21 + func (g *Gate) ToStreamplaceGate() (*streamplace.ChatGate, error) { 22 + return &streamplace.ChatGate{ 23 + LexiconTypeID: "place.stream.chat.gate", 24 + HiddenMessage: g.HiddenMessage, 25 + }, nil 26 + } 27 + 28 + func (m *DBModel) CreateGate(ctx context.Context, gate *Gate) error { 29 + return m.DB.Create(gate).Error 30 + } 31 + 32 + func (m *DBModel) GetGate(ctx context.Context, rkey string) (*Gate, error) { 33 + var gate Gate 34 + err := m.DB.Preload("Repo").Where("rkey = ?", rkey).First(&gate).Error 35 + if errors.Is(err, gorm.ErrRecordNotFound) { 36 + return nil, nil 37 + } 38 + if err != nil { 39 + return nil, err 40 + } 41 + return &gate, nil 42 + } 43 + 44 + func (m *DBModel) DeleteGate(ctx context.Context, rkey string) error { 45 + return m.DB.Where("rkey = ?", rkey).Delete(&Gate{}).Error 46 + } 47 + 48 + func (m *DBModel) GetUserGates(ctx context.Context, userDID string) ([]*Gate, error) { 49 + var gates []*Gate 50 + err := m.DB.Where("repo_did = ?", userDID).Find(&gates).Error 51 + if err != nil { 52 + return nil, err 53 + } 54 + return gates, nil 55 + }
-55
pkg/model/hide.go
··· 1 - package model 2 - 3 - import ( 4 - "context" 5 - "errors" 6 - "time" 7 - 8 - "gorm.io/gorm" 9 - "stream.place/streamplace/pkg/streamplace" 10 - ) 11 - 12 - type Hide struct { 13 - RKey string `gorm:"primaryKey;column:rkey"` 14 - CID string `gorm:"column:cid"` 15 - RepoDID string `json:"repoDID" gorm:"column:repo_did"` 16 - Repo *Repo `json:"repo,omitempty" gorm:"foreignKey:DID;references:RepoDID"` 17 - HiddenMessage string `gorm:"column:hidden_message" json:"hiddenMessage"` 18 - CreatedAt time.Time `gorm:"column:created_at"` 19 - } 20 - 21 - func (h *Hide) ToStreamplaceHide() (*streamplace.ChatHide, error) { 22 - return &streamplace.ChatHide{ 23 - LexiconTypeID: "place.stream.chat.hide", 24 - HiddenMessage: h.HiddenMessage, 25 - }, nil 26 - } 27 - 28 - func (m *DBModel) CreateHide(ctx context.Context, hide *Hide) error { 29 - return m.DB.Create(hide).Error 30 - } 31 - 32 - func (m *DBModel) GetHide(ctx context.Context, rkey string) (*Hide, error) { 33 - var hide Hide 34 - err := m.DB.Preload("Repo").Where("rkey = ?", rkey).First(&hide).Error 35 - if errors.Is(err, gorm.ErrRecordNotFound) { 36 - return nil, nil 37 - } 38 - if err != nil { 39 - return nil, err 40 - } 41 - return &hide, nil 42 - } 43 - 44 - func (m *DBModel) DeleteHide(ctx context.Context, rkey string) error { 45 - return m.DB.Where("rkey = ?", rkey).Delete(&Hide{}).Error 46 - } 47 - 48 - func (m *DBModel) GetUserHides(ctx context.Context, userDID string) ([]*Hide, error) { 49 - var hides []*Hide 50 - err := m.DB.Where("repo_did = ?", userDID).Find(&hides).Error 51 - if err != nil { 52 - return nil, err 53 - } 54 - return hides, nil 55 - }
+5 -5
pkg/model/model.go
··· 84 84 MostRecentChatMessages(repoDID string) ([]*streamplace.ChatDefs_MessageView, error) 85 85 GetChatMessage(cid string) (*ChatMessage, error) 86 86 87 - CreateHide(ctx context.Context, hide *Hide) error 88 - DeleteHide(ctx context.Context, rkey string) error 89 - GetHide(ctx context.Context, rkey string) (*Hide, error) 90 - GetUserHides(ctx context.Context, userDID string) ([]*Hide, error) 87 + CreateGate(ctx context.Context, gate *Gate) error 88 + DeleteGate(ctx context.Context, rkey string) error 89 + GetGate(ctx context.Context, rkey string) (*Gate, error) 90 + GetUserGates(ctx context.Context, userDID string) ([]*Gate, error) 91 91 92 92 CreateChatProfile(ctx context.Context, profile *ChatProfile) error 93 93 GetChatProfile(ctx context.Context, repoDID string) (*ChatProfile, error) ··· 159 159 Block{}, 160 160 ChatMessage{}, 161 161 ChatProfile{}, 162 - Hide{}, 162 + Gate{}, 163 163 oatproxy.OAuthSession{}, 164 164 ServerSettings{}, 165 165 } {
+6 -6
pkg/streamplace/cbor_gen.go
··· 2769 2769 2770 2770 return nil 2771 2771 } 2772 - func (t *ChatHide) MarshalCBOR(w io.Writer) error { 2772 + func (t *ChatGate) MarshalCBOR(w io.Writer) error { 2773 2773 if t == nil { 2774 2774 _, err := w.Write(cbg.CborNull) 2775 2775 return err ··· 2793 2793 return err 2794 2794 } 2795 2795 2796 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("place.stream.chat.hide"))); err != nil { 2796 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("place.stream.chat.gate"))); err != nil { 2797 2797 return err 2798 2798 } 2799 - if _, err := cw.WriteString(string("place.stream.chat.hide")); err != nil { 2799 + if _, err := cw.WriteString(string("place.stream.chat.gate")); err != nil { 2800 2800 return err 2801 2801 } 2802 2802 ··· 2825 2825 return nil 2826 2826 } 2827 2827 2828 - func (t *ChatHide) UnmarshalCBOR(r io.Reader) (err error) { 2829 - *t = ChatHide{} 2828 + func (t *ChatGate) UnmarshalCBOR(r io.Reader) (err error) { 2829 + *t = ChatGate{} 2830 2830 2831 2831 cr := cbg.NewCborReader(r) 2832 2832 ··· 2845 2845 } 2846 2846 2847 2847 if extra > cbg.MaxLength { 2848 - return fmt.Errorf("ChatHide: map struct too large (%d)", extra) 2848 + return fmt.Errorf("ChatGate: map struct too large (%d)", extra) 2849 2849 } 2850 2850 2851 2851 n := extra
+19
pkg/streamplace/chatgate.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package streamplace 4 + 5 + // schema: place.stream.chat.gate 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + func init() { 12 + util.RegisterType("place.stream.chat.gate", &ChatGate{}) 13 + } // 14 + // RECORDTYPE: ChatGate 15 + type ChatGate struct { 16 + LexiconTypeID string `json:"$type,const=place.stream.chat.gate" cborgen:"$type,const=place.stream.chat.gate"` 17 + // hiddenMessage: URI of the hidden chat message. 18 + HiddenMessage string `json:"hiddenMessage" cborgen:"hiddenMessage"` 19 + }
-19
pkg/streamplace/chathide.go
··· 1 - // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 - 3 - package streamplace 4 - 5 - // schema: place.stream.chat.hide 6 - 7 - import ( 8 - "github.com/bluesky-social/indigo/lex/util" 9 - ) 10 - 11 - func init() { 12 - util.RegisterType("place.stream.chat.hide", &ChatHide{}) 13 - } // 14 - // RECORDTYPE: ChatHide 15 - type ChatHide struct { 16 - LexiconTypeID string `json:"$type,const=place.stream.chat.hide" cborgen:"$type,const=place.stream.chat.hide"` 17 - // hiddenMessage: URI of the hidden chat message. 18 - HiddenMessage string `json:"hiddenMessage" cborgen:"hiddenMessage"` 19 - }