tangled
alpha
login
or
join now
diffdown.com
/
diffdown-app
0
fork
atom
Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol
diffdown.com
0
fork
atom
overview
issues
10
pulls
pipelines
debug: add logging to AcceptInvite to trace 404
John Luther
3 weeks ago
27d8ce24
3ce910d9
+7
1 changed file
expand all
collapse all
unified
split
internal
handler
handler.go
+7
internal/handler/handler.go
reviewed
···
580
580
func (h *Handler) AcceptInvite(w http.ResponseWriter, r *http.Request) {
581
581
user := h.currentUser(r)
582
582
if user == nil {
583
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
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
599
+
log.Printf("AcceptInvite: validate invite: %v", err)
597
600
http.Error(w, err.Error(), http.StatusBadRequest)
598
601
return
599
602
}
603
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
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
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
622
+
log.Printf("AcceptInvite: owner user=%s", ownerUser.ID)
616
623
617
624
ownerClient, err := h.xrpcClient(ownerUser.ID)
618
625
if err != nil {