Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com

debug: add logging to AcceptInvite to trace 404

+7
+7
internal/handler/handler.go
··· 580 580 func (h *Handler) AcceptInvite(w http.ResponseWriter, r *http.Request) { 581 581 user := h.currentUser(r) 582 582 if user == nil { 583 + log.Printf("AcceptInvite: unauthenticated, redirecting to login") 583 584 // Preserve invite token through the login redirect. 584 585 http.Redirect(w, r, "/auth/login?next="+url.QueryEscape(r.URL.String()), http.StatusSeeOther) 585 586 return ··· 587 588 588 589 rKey := r.PathValue("rkey") 589 590 inviteToken := r.URL.Query().Get("invite") 591 + log.Printf("AcceptInvite: user=%s rkey=%s token=%s", user.ID, rKey, inviteToken[:8]+"...") 590 592 if inviteToken == "" { 591 593 http.Error(w, "Invalid invite", http.StatusBadRequest) 592 594 return ··· 594 596 595 597 invite, err := collaboration.ValidateInvite(h.DB, inviteToken, rKey) 596 598 if err != nil { 599 + log.Printf("AcceptInvite: validate invite: %v", err) 597 600 http.Error(w, err.Error(), http.StatusBadRequest) 598 601 return 599 602 } 603 + log.Printf("AcceptInvite: invite valid, createdBy=%s", invite.CreatedBy) 600 604 601 605 // The collaborator's session — needed to get their DID. 602 606 collabSession, err := h.DB.GetATProtoSession(user.ID) 603 607 if err != nil || collabSession == nil { 608 + log.Printf("AcceptInvite: no ATProto session for collaborator user=%s err=%v", user.ID, err) 604 609 http.Redirect(w, r, "/auth/atproto?next="+url.QueryEscape(r.URL.String()), http.StatusSeeOther) 605 610 return 606 611 } 612 + log.Printf("AcceptInvite: collab DID=%s", collabSession.DID) 607 613 608 614 // Fetch and update the document from the OWNER's PDS, not the collaborator's. 609 615 // The invite records the owner's DID in CreatedBy. ··· 613 619 http.Error(w, "Document owner not found", http.StatusInternalServerError) 614 620 return 615 621 } 622 + log.Printf("AcceptInvite: owner user=%s", ownerUser.ID) 616 623 617 624 ownerClient, err := h.xrpcClient(ownerUser.ID) 618 625 if err != nil {