backend for xcvr appview
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

beeeeeeeebbbbbbebeeeep

rachel-mp4 75b5cdf3 7c5343ce

+63 -5
+2 -3
lexicons/org/xcvr/lrc/defs.json
··· 38 38 }, 39 39 "signetView": { 40 40 "type": "object", 41 - "required": ["uri", "issuer", "channelURI", "lrcID", "author", "startedAt"], 41 + "required": ["uri", "issuer", "channelURI", "lrcID", "authorHandle", "startedAt"], 42 42 "properties": { 43 43 "uri": { 44 44 "type": "string", ··· 57 57 "minimum": 0, 58 58 "maximum": 4294967295 59 59 }, 60 - "author": { 60 + "authorHandle": { 61 61 "type": "string", 62 - "format": "handle" 63 62 }, 64 63 "startedAt": { 65 64 "type": "string",
+43
lexicons/org/xcvr/lrc/subscribeLexStream.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "org.xcvr.lrc.subscribeLexStream", 4 + "defs": { 5 + "main": { 6 + "type": "subscription", 7 + "description": "", 8 + "parameters": { 9 + "type": "params", 10 + "properties": { 11 + "limit": { 12 + "type": "integer", 13 + "minimum": 1, 14 + "maximum": 100, 15 + "default": 50 16 + }, 17 + "cursor": { 18 + "type": "string" 19 + } 20 + } 21 + }, 22 + "output": { 23 + "encoding": "application/json", 24 + "schema": { 25 + "type": "object", 26 + "required": ["messages"], 27 + "properties": { 28 + "messages": { 29 + "type": "array", 30 + "items": { 31 + "type": "ref", 32 + "ref": "org.xcvr.lrc.defs#messageView" 33 + } 34 + }, 35 + "cursor": { 36 + "type": "string" 37 + } 38 + } 39 + } 40 + } 41 + } 42 + } 43 + }
+1 -1
server/internal/db/db.go
··· 78 78 _, err := s.pool.Exec(ctx, `INSERT INTO did_handles ( 79 79 handle, 80 80 did 81 - ) VALUES ($1, $2)`, handle, did) 81 + ) VALUES ($1, $2) ON CONFLICT (handle) DO NOTHING`, handle, did) 82 82 if err != nil { 83 83 return errors.New("error storing did/handle: " + err.Error()) 84 84 }
+10
server/internal/db/lexicon.go
··· 204 204 return signetUri, nil 205 205 } 206 206 207 + func (s *Store) GetMsgChannelURI(signetURI string, ctx context.Context) (string, error) { 208 + row := s.pool.QueryRow(ctx, `SELECT s.channel_uri FROM signets s WHERE s.uri = $1`, signetURI) 209 + var channelURI string 210 + err := row.Scan(&channelURI) 211 + if err != nil { 212 + return "", errors.New("error scanning: " + err.Error()) 213 + } 214 + return channelURI, nil 215 + } 216 + 207 217 func (s *Store) StoreSignet(signet *types.Signet, ctx context.Context) error { 208 218 _, err := s.pool.Exec(ctx, ` 209 219 INSERT INTO signets (
+1 -1
server/internal/handler/handler.go
··· 40 40 mux.HandleFunc("GET /xrpc/org.xcvr.lrc.getMessages", h.getMessages) 41 41 mux.HandleFunc("GET /xrpc/org.xcvr.actor.resolveChannel", h.resolveChannel) 42 42 mux.HandleFunc("GET /xrpc/org.xcvr.actor.getProfileView", h.getProfileView) 43 - mux.HandleFunc("GET /xrpc/org.xcvr.lrc.getLexStream", h.subscribeLexStream) 43 + mux.HandleFunc("GET /xrpc/org.xcvr.lrc.subscribeLexStream", h.subscribeLexStream) 44 44 // backend metadata handlers 45 45 mux.HandleFunc(clientMetadataPath(), h.serveClientMetadata) 46 46 mux.HandleFunc(clientTOSPath(), h.serveTOS)
+5
server/internal/handler/lrcHandlers.go
··· 217 217 h.serverError(w, errors.New("sooo... the record posted but i couldn't store it: "+err.Error())) 218 218 return 219 219 } 220 + curi, err := h.db.GetMsgChannelURI(lmr.SignetURI, r.Context()) 221 + if err != nil { 222 + h.serverError(w, errors.New("aaaaaaaaaaaa "+err.Error())) 223 + } 224 + h.model.BroadcastMessage(curi, message) 220 225 h.getMessages(w, r) 221 226 } 222 227
+1
server/internal/model/channel.go
··· 237 237 if err != nil { 238 238 m.logger.Println("failed to store signet!" + err.Error()) 239 239 } 240 + m.BroadcastSignet(uri, sr) 240 241 } 241 242 } 242 243 }