backend for xcvr appview
2
fork

Configure Feed

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

make session id int and not uint

rachel-mp4 131ec74c c564fb71

+16 -25
+4 -13
server/internal/db/oauth.go
··· 89 89 return &req, nil 90 90 } 91 91 92 - func (s *Store) GetOauthSession(id uint, ctx context.Context) (*types.Session, error) { 93 - rows, err := s.pool.Query(ctx, ` 92 + func (s *Store) GetOauthSession(id int, ctx context.Context) (*types.Session, error) { 93 + row := s.pool.QueryRow(ctx, ` 94 94 SELECT 95 95 r.authserver_iss, 96 96 r.did, ··· 104 104 r.expiration 105 105 FROM oauthsessions r 106 106 WHERE r.id = $1 107 - LIMIT 1 108 107 `, id) 109 - if err != nil { 110 - return nil, errors.New("error querying oauthsessions:" + err.Error()) 111 - } 112 - defer rows.Close() 113 108 var session types.Session 114 - ok := rows.Next() 115 - if !ok { 116 - return nil, errors.New("no rows") 117 - } 118 - err = rows.Scan( 109 + err := row.Scan( 119 110 &session.AuthserverIss, 120 111 &session.Did, 121 112 &session.PdsUrl, ··· 142 133 return nil 143 134 } 144 135 145 - func (s *Store) SetDpopPdsNonce(id uint, dpopnonce string) error { 136 + func (s *Store) SetDpopPdsNonce(id int, dpopnonce string) error { 146 137 _, err := s.pool.Exec(context.Background(), ` 147 138 UPDATE oauthsessions SET dpop_pds_nonce = $1 WHERE id = $2 148 139 `, dpopnonce, id)
+2 -2
server/internal/handler/lrcHandlers.go
··· 31 31 32 32 func (h *Handler) postChannel(w http.ResponseWriter, r *http.Request) { 33 33 session, _ := h.sessionStore.Get(r, "oauthsession") 34 - _, ok := session.Values["id"].(uint) 34 + _, ok := session.Values["id"].(int) 35 35 if !ok { 36 36 h.postMyChannel(w, r) 37 37 return ··· 253 253 254 254 func (h *Handler) postMessage(w http.ResponseWriter, r *http.Request) { 255 255 session, _ := h.sessionStore.Get(r, "oauthsession") 256 - _, ok := session.Values["id"].(uint) 256 + _, ok := session.Values["id"].(int) 257 257 if !ok { 258 258 h.postMyMessage(w, r) 259 259 return
+2 -2
server/internal/handler/oauthHandlers.go
··· 222 222 223 223 func (h *Handler) getClient(r *http.Request) (*oauth.OauthXRPCClient, error) { 224 224 s, _ := h.sessionStore.Get(r, "oauthsession") 225 - id, ok := s.Values["id"].(uint) 225 + id, ok := s.Values["id"].(int) 226 226 if !ok { 227 227 return nil, errors.New("not authorized") 228 228 } ··· 237 237 return client, nil 238 238 } 239 239 240 - func (h *Handler) resetClient(id uint, ctx context.Context) (*oauth.OauthXRPCClient, error) { 240 + func (h *Handler) resetClient(id int, ctx context.Context) (*oauth.OauthXRPCClient, error) { 241 241 session, err := h.db.GetOauthSession(id, ctx) 242 242 if err != nil { 243 243 return nil, errors.New("errpr setting up session: " + err.Error())
+1 -1
server/internal/handler/xcvrHandlers.go
··· 60 60 pu.UpdateColor = true 61 61 } 62 62 session, _ := h.sessionStore.Get(r, "oauthsession") 63 - _, ok := session.Values["id"].(uint) 63 + _, ok := session.Values["id"].(int) 64 64 if !ok { 65 65 h.badRequest(w, errors.New("cannot update profile, not authenticated")) 66 66 return
+6 -6
server/internal/oauth/clientmapper.go
··· 6 6 ) 7 7 8 8 type ClientMap struct { 9 - clients map[uint]*OauthXRPCClient 10 - expiry map[uint]time.Time 9 + clients map[int]*OauthXRPCClient 10 + expiry map[int]time.Time 11 11 mu sync.Mutex 12 12 } 13 13 14 14 func NewClientMap() *ClientMap { 15 15 return &ClientMap{ 16 - clients: make(map[uint]*OauthXRPCClient, 10), 17 - expiry: make(map[uint]time.Time, 10), 16 + clients: make(map[int]*OauthXRPCClient, 10), 17 + expiry: make(map[int]time.Time, 10), 18 18 } 19 19 } 20 20 21 - func (c *ClientMap) Map(id uint) *OauthXRPCClient { 21 + func (c *ClientMap) Map(id int) *OauthXRPCClient { 22 22 c.mu.Lock() 23 23 defer c.mu.Unlock() 24 24 return c.clients[id] 25 25 } 26 26 27 - func (c *ClientMap) Append(id uint, client *OauthXRPCClient, expiration time.Time) { 27 + func (c *ClientMap) Append(id int, client *OauthXRPCClient, expiration time.Time) { 28 28 c.mu.Lock() 29 29 defer c.mu.Unlock() 30 30 c.clients[id] = client
+1 -1
server/internal/types/oauth.go
··· 12 12 } 13 13 14 14 type OAuthRequest struct { 15 - ID uint 15 + ID int 16 16 AuthserverIss string 17 17 State string 18 18 Did string