backend for xcvr appview
3
fork

Configure Feed

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

add getChannel lexicon

+40
+29
server/internal/db/db.go
··· 291 291 return chans, nil 292 292 } 293 293 294 + func (s *Store) GetChannelView(uri string, ctx context.Context) (*types.ChannelView, error) { 295 + row := s.pool.QueryRow(ctx, ` 296 + SELECT 297 + channels.uri, 298 + channels.host, 299 + channels.title, 300 + channels.topic, 301 + channels.created_at, 302 + did_handles.did, 303 + did_handles.handle, 304 + profiles.display_name, 305 + profiles.status, 306 + profiles.color, 307 + profiles.avatar_cid 308 + FROM channels 309 + LEFT JOIN profiles ON channels.did = profiles.did 310 + LEFT JOIN did_handles ON profiles.did = did_handles.did 311 + WHERE channels.uri = $1 312 + `, uri) 313 + var c types.ChannelView 314 + var p types.ProfileView 315 + err := row.Scan(&c.URI, &c.Host, &c.Title, &c.Topic, &c.CreatedAt, &p.DID, &p.Handle, &p.DisplayName, &p.Status, &p.Color, &p.Avatar) 316 + if err != nil { 317 + return nil, err 318 + } 319 + c.Creator = p 320 + return &c, nil 321 + } 322 + 294 323 func (s *Store) DeleteChannel(uri string, ctx context.Context) error { 295 324 _, err := s.pool.Exec(ctx, `DELETE FROM channels WHERE uri = $1`, uri) 296 325 return err
+11
server/internal/handler/lexiconHandlers.go
··· 31 31 encoder := json.NewEncoder(w) 32 32 encoder.Encode(cvs) 33 33 } 34 + func (h *Handler) getChannel(w http.ResponseWriter, r *http.Request) { 35 + uri := r.URL.Query().Get("uri") 36 + cv, err := h.db.GetChannelView(uri, r.Context()) 37 + if err != nil { 38 + h.notFound(w, err) 39 + return 40 + } 41 + w.Header().Set("Content-Type", "application/json") 42 + encoder := json.NewEncoder(w) 43 + encoder.Encode(cv) 44 + } 34 45 35 46 func (h *Handler) getMessages(w http.ResponseWriter, r *http.Request) { 36 47 limitstr := r.URL.Query().Get("limit")