backend for xcvr appview
2
fork

Configure Feed

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

expanded lexicon because i don't have uri on frontend

+42 -1
+33
server/internal/db/db.go
··· 319 319 c.Creator = p 320 320 return &c, nil 321 321 } 322 + func (s *Store) GetChannelViewHR(handle string, rkey string, ctx context.Context) (*types.ChannelView, error) { 323 + did, err := s.ResolveHandle(handle, ctx) 324 + if err != nil { 325 + return nil, err 326 + } 327 + uri := fmt.Sprintf("at://%s/org.xcvr.feed.channel/%s", did, rkey) 328 + row := s.pool.QueryRow(ctx, ` 329 + SELECT 330 + channels.uri, 331 + channels.host, 332 + channels.title, 333 + channels.topic, 334 + channels.created_at, 335 + did_handles.did, 336 + did_handles.handle, 337 + profiles.display_name, 338 + profiles.status, 339 + profiles.color, 340 + profiles.avatar_cid 341 + FROM channels 342 + LEFT JOIN profiles ON channels.did = profiles.did 343 + LEFT JOIN did_handles ON profiles.did = did_handles.did 344 + WHERE channels.uri = $1 345 + `, uri) 346 + var c types.ChannelView 347 + var p types.ProfileView 348 + 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) 349 + if err != nil { 350 + return nil, err 351 + } 352 + c.Creator = p 353 + return &c, nil 354 + } 322 355 323 356 func (s *Store) DeleteChannel(uri string, ctx context.Context) error { 324 357 _, err := s.pool.Exec(ctx, `DELETE FROM channels WHERE uri = $1`, uri)
+9 -1
server/internal/handler/lexiconHandlers.go
··· 33 33 } 34 34 func (h *Handler) getChannel(w http.ResponseWriter, r *http.Request) { 35 35 uri := r.URL.Query().Get("uri") 36 - cv, err := h.db.GetChannelView(uri, r.Context()) 36 + handle := r.URL.Query().Get("handle") 37 + rkey := r.URL.Query().Get("rkey") 38 + var cv *types.ChannelView 39 + var err error 40 + if uri != "" { 41 + cv, err = h.db.GetChannelView(uri, r.Context()) 42 + } else { 43 + h.db.getChannelViewHR(handle, rkey, r.Context()) 44 + } 37 45 if err != nil { 38 46 h.notFound(w, err) 39 47 return