tiny 88x31 lexicon for atproto
0
fork

Configure Feed

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

bee bee bee bee beeop

+24 -5
+22 -3
db/lexicon.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "errors" 5 6 "fmt" 6 7 "github.com/jackc/pgx/v5" 7 8 "tangled.org/moth11.net/88x31/types" ··· 205 206 return err 206 207 } 207 208 208 - func (s *Store) DeleteLike(uri string, ctx context.Context) error { 209 - _, err := s.pool.Exec(ctx, ` 209 + func (s *Store) GetLike(uri string, ctx context.Context) (string, error) { 210 + row := s.pool.QueryRow(ctx, ` 211 + SELECT subject_uri FROM likes WHERE uri = $1 212 + `, uri) 213 + var resuri string 214 + err := row.Scan(&resuri) 215 + if err != nil { 216 + err = errors.New("error scanning like subject: " + err.Error()) 217 + return "", err 218 + } 219 + return resuri, nil 220 + } 221 + 222 + func (s *Store) DeleteLike(uri string, ctx context.Context) (string, error) { 223 + l, err := s.GetLike(uri, ctx) 224 + if err != nil { 225 + err = errors.New("error getting like: " + err.Error()) 226 + return "", err 227 + } 228 + _, err = s.pool.Exec(ctx, ` 210 229 DELETE FROM likes WHERE uri = $1 211 230 `, uri) 212 - return err 231 + return l, err 213 232 }
+2 -2
handler/upload.go
··· 101 101 return 102 102 } 103 103 log.Println("deleted like") 104 - err = h.db.DeleteLike(uri, r.Context()) 104 + l, err := h.db.DeleteLike(uri, r.Context()) 105 105 if err != nil { 106 106 log.Println(err) 107 107 http.Error(w, "error storing like", http.StatusInternalServerError) 108 108 return 109 109 } 110 110 log.Println("cached deleted like") 111 - http.Redirect(w, r, fmt.Sprintf("/button?uri=%s", uri), http.StatusCreated) 111 + http.Redirect(w, r, fmt.Sprintf("/button?uri=%s", l), http.StatusCreated) 112 112 } 113 113 114 114 func (h *Handler) upload(cs *oauth.ClientSession, w http.ResponseWriter, r *http.Request) {