Monorepo for Tangled tangled.org

appview: remove `oauth.User` type

This is not required anymore. `MultiAccountUser` can just hold active
user DID.

Signed-off-by: Seongmin Lee <git@boltless.me>

boltless.me e1adce39 c5db1ce1

verified
+221 -235
+19 -19
appview/issues/issues.go
··· 103 103 104 104 userReactions := map[models.ReactionKind]bool{} 105 105 if user != nil { 106 - userReactions = db.GetReactionStatusMap(rp.db, user.Active.Did, issue.AtUri()) 106 + userReactions = db.GetReactionStatusMap(rp.db, user.Did, issue.AtUri()) 107 107 } 108 108 109 109 backlinks, err := db.GetBacklinks(rp.db, issue.AtUri()) ··· 182 182 return 183 183 } 184 184 185 - ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueNSID, user.Active.Did, newIssue.Rkey) 185 + ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueNSID, user.Did, newIssue.Rkey) 186 186 if err != nil { 187 187 l.Error("failed to get record", "err", err) 188 188 rp.pages.Notice(w, noticeId, "Failed to edit issue, no record found on PDS.") ··· 191 191 192 192 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 193 193 Collection: tangled.RepoIssueNSID, 194 - Repo: user.Active.Did, 194 + Repo: user.Did, 195 195 Rkey: newIssue.Rkey, 196 196 SwapRecord: ex.Cid, 197 197 Record: &lexutil.LexiconTypeDecoder{ ··· 306 306 return 307 307 } 308 308 309 - roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 309 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 310 310 isRepoOwner := roles.IsOwner() 311 311 isCollaborator := roles.IsCollaborator() 312 - isIssueOwner := user.Active.Did == issue.Did 312 + isIssueOwner := user.Did == issue.Did 313 313 314 314 // TODO: make this more granular 315 315 if isIssueOwner || isRepoOwner || isCollaborator { ··· 326 326 issue.Open = false 327 327 328 328 // notify about the issue closure 329 - rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Active.Did), issue) 329 + rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 330 330 331 331 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) 332 332 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) ··· 354 354 return 355 355 } 356 356 357 - roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 357 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 358 358 isRepoOwner := roles.IsOwner() 359 359 isCollaborator := roles.IsCollaborator() 360 - isIssueOwner := user.Active.Did == issue.Did 360 + isIssueOwner := user.Did == issue.Did 361 361 362 362 if isCollaborator || isRepoOwner || isIssueOwner { 363 363 err := db.ReopenIssues( ··· 373 373 issue.Open = true 374 374 375 375 // notify about the issue reopen 376 - rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Active.Did), issue) 376 + rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 377 377 378 378 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) 379 379 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) ··· 416 416 mentions, references := rp.mentionsResolver.Resolve(r.Context(), body) 417 417 418 418 comment := models.IssueComment{ 419 - Did: user.Active.Did, 419 + Did: user.Did, 420 420 Rkey: tid.TID(), 421 421 IssueAt: issue.AtUri().String(), 422 422 ReplyTo: replyTo, ··· 557 557 } 558 558 comment := comments[0] 559 559 560 - if comment.Did != user.Active.Did { 561 - l.Error("unauthorized comment edit", "expectedDid", comment.Did, "gotDid", user.Active.Did) 560 + if comment.Did != user.Did { 561 + l.Error("unauthorized comment edit", "expectedDid", comment.Did, "gotDid", user.Did) 562 562 http.Error(w, "you are not the author of this comment", http.StatusUnauthorized) 563 563 return 564 564 } ··· 608 608 // rkey is optional, it was introduced later 609 609 if newComment.Rkey != "" { 610 610 // update the record on pds 611 - ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueCommentNSID, user.Active.Did, comment.Rkey) 611 + ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueCommentNSID, user.Did, comment.Rkey) 612 612 if err != nil { 613 613 l.Error("failed to get record", "err", err, "did", newComment.Did, "rkey", newComment.Rkey) 614 614 rp.pages.Notice(w, fmt.Sprintf("comment-%s-status", commentId), "Failed to update description, no record found on PDS.") ··· 617 617 618 618 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 619 619 Collection: tangled.RepoIssueCommentNSID, 620 - Repo: user.Active.Did, 620 + Repo: user.Did, 621 621 Rkey: newComment.Rkey, 622 622 SwapRecord: ex.Cid, 623 623 Record: &lexutil.LexiconTypeDecoder{ ··· 739 739 } 740 740 comment := comments[0] 741 741 742 - if comment.Did != user.Active.Did { 743 - l.Error("unauthorized action", "expectedDid", comment.Did, "gotDid", user.Active.Did) 742 + if comment.Did != user.Did { 743 + l.Error("unauthorized action", "expectedDid", comment.Did, "gotDid", user.Did) 744 744 http.Error(w, "you are not the author of this comment", http.StatusUnauthorized) 745 745 return 746 746 } ··· 769 769 } 770 770 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 771 771 Collection: tangled.RepoIssueCommentNSID, 772 - Repo: user.Active.Did, 772 + Repo: user.Did, 773 773 Rkey: comment.Rkey, 774 774 }) 775 775 if err != nil { ··· 1015 1015 Title: r.FormValue("title"), 1016 1016 Body: body, 1017 1017 Open: true, 1018 - Did: user.Active.Did, 1018 + Did: user.Did, 1019 1019 Created: time.Now(), 1020 1020 Mentions: mentions, 1021 1021 References: references, ··· 1039 1039 } 1040 1040 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 1041 1041 Collection: tangled.RepoIssueNSID, 1042 - Repo: user.Active.Did, 1042 + Repo: user.Did, 1043 1043 Rkey: issue.Rkey, 1044 1044 Record: &lexutil.LexiconTypeDecoder{ 1045 1045 Val: &record,
+24 -24
appview/knots/knots.go
··· 60 60 user := k.OAuth.GetMultiAccountUser(r) 61 61 registrations, err := db.GetRegistrations( 62 62 k.Db, 63 - orm.FilterEq("did", user.Active.Did), 63 + orm.FilterEq("did", user.Did), 64 64 ) 65 65 if err != nil { 66 66 k.Logger.Error("failed to fetch knot registrations", "err", err) ··· 78 78 l := k.Logger.With("handler", "dashboard") 79 79 80 80 user := k.OAuth.GetMultiAccountUser(r) 81 - l = l.With("user", user.Active.Did) 81 + l = l.With("user", user.Did) 82 82 83 83 domain := chi.URLParam(r, "domain") 84 84 if domain == "" { ··· 88 88 89 89 registrations, err := db.GetRegistrations( 90 90 k.Db, 91 - orm.FilterEq("did", user.Active.Did), 91 + orm.FilterEq("did", user.Did), 92 92 orm.FilterEq("domain", domain), 93 93 ) 94 94 if err != nil { ··· 158 158 return 159 159 } 160 160 l = l.With("domain", domain) 161 - l = l.With("user", user.Active.Did) 161 + l = l.With("user", user.Did) 162 162 163 163 tx, err := k.Db.Begin() 164 164 if err != nil { ··· 171 171 k.Enforcer.E.LoadPolicy() 172 172 }() 173 173 174 - err = db.AddKnot(tx, domain, user.Active.Did) 174 + err = db.AddKnot(tx, domain, user.Did) 175 175 if err != nil { 176 176 l.Error("failed to insert", "err", err) 177 177 fail() ··· 193 193 return 194 194 } 195 195 196 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Active.Did, domain) 196 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Did, domain) 197 197 var exCid *string 198 198 if ex != nil { 199 199 exCid = ex.Cid ··· 202 202 // re-announce by registering under same rkey 203 203 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 204 204 Collection: tangled.KnotNSID, 205 - Repo: user.Active.Did, 205 + Repo: user.Did, 206 206 Rkey: domain, 207 207 Record: &lexutil.LexiconTypeDecoder{ 208 208 Val: &tangled.Knot{ ··· 233 233 } 234 234 235 235 // begin verification 236 - err = serververify.RunVerification(r.Context(), domain, user.Active.Did, k.Config.Core.Dev) 236 + err = serververify.RunVerification(r.Context(), domain, user.Did, k.Config.Core.Dev) 237 237 if err != nil { 238 238 l.Error("verification failed", "err", err) 239 239 k.Pages.HxRefresh(w) 240 240 return 241 241 } 242 242 243 - err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Active.Did) 243 + err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Did) 244 244 if err != nil { 245 245 l.Error("failed to mark verified", "err", err) 246 246 k.Pages.HxRefresh(w) ··· 277 277 // get record from db first 278 278 registrations, err := db.GetRegistrations( 279 279 k.Db, 280 - orm.FilterEq("did", user.Active.Did), 280 + orm.FilterEq("did", user.Did), 281 281 orm.FilterEq("domain", domain), 282 282 ) 283 283 if err != nil { ··· 305 305 306 306 err = db.DeleteKnot( 307 307 tx, 308 - orm.FilterEq("did", user.Active.Did), 308 + orm.FilterEq("did", user.Did), 309 309 orm.FilterEq("domain", domain), 310 310 ) 311 311 if err != nil { ··· 333 333 334 334 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 335 335 Collection: tangled.KnotNSID, 336 - Repo: user.Active.Did, 336 + Repo: user.Did, 337 337 Rkey: domain, 338 338 }) 339 339 if err != nil { ··· 381 381 return 382 382 } 383 383 l = l.With("domain", domain) 384 - l = l.With("user", user.Active.Did) 384 + l = l.With("user", user.Did) 385 385 386 386 // get record from db first 387 387 registrations, err := db.GetRegistrations( 388 388 k.Db, 389 - orm.FilterEq("did", user.Active.Did), 389 + orm.FilterEq("did", user.Did), 390 390 orm.FilterEq("domain", domain), 391 391 ) 392 392 if err != nil { ··· 402 402 registration := registrations[0] 403 403 404 404 // begin verification 405 - err = serververify.RunVerification(r.Context(), domain, user.Active.Did, k.Config.Core.Dev) 405 + err = serververify.RunVerification(r.Context(), domain, user.Did, k.Config.Core.Dev) 406 406 if err != nil { 407 407 l.Error("verification failed", "err", err) 408 408 ··· 420 420 return 421 421 } 422 422 423 - err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Active.Did) 423 + err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Did) 424 424 if err != nil { 425 425 l.Error("failed to mark verified", "err", err) 426 426 k.Pages.Notice(w, noticeId, err.Error()) ··· 439 439 return 440 440 } 441 441 442 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Active.Did, domain) 442 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Did, domain) 443 443 var exCid *string 444 444 if ex != nil { 445 445 exCid = ex.Cid ··· 448 448 // ignore the error here 449 449 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 450 450 Collection: tangled.KnotNSID, 451 - Repo: user.Active.Did, 451 + Repo: user.Did, 452 452 Rkey: domain, 453 453 Record: &lexutil.LexiconTypeDecoder{ 454 454 Val: &tangled.Knot{ ··· 477 477 // Get updated registration to show 478 478 registrations, err = db.GetRegistrations( 479 479 k.Db, 480 - orm.FilterEq("did", user.Active.Did), 480 + orm.FilterEq("did", user.Did), 481 481 orm.FilterEq("domain", domain), 482 482 ) 483 483 if err != nil { ··· 509 509 return 510 510 } 511 511 l = l.With("domain", domain) 512 - l = l.With("user", user.Active.Did) 512 + l = l.With("user", user.Did) 513 513 514 514 registrations, err := db.GetRegistrations( 515 515 k.Db, 516 - orm.FilterEq("did", user.Active.Did), 516 + orm.FilterEq("did", user.Did), 517 517 orm.FilterEq("domain", domain), 518 518 orm.FilterIsNot("registered", "null"), 519 519 ) ··· 566 566 567 567 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 568 568 Collection: tangled.KnotMemberNSID, 569 - Repo: user.Active.Did, 569 + Repo: user.Did, 570 570 Rkey: rkey, 571 571 Record: &lexutil.LexiconTypeDecoder{ 572 572 Val: &tangled.KnotMember{ ··· 617 617 return 618 618 } 619 619 l = l.With("domain", domain) 620 - l = l.With("user", user.Active.Did) 620 + l = l.With("user", user.Did) 621 621 622 622 registrations, err := db.GetRegistrations( 623 623 k.Db, 624 - orm.FilterEq("did", user.Active.Did), 624 + orm.FilterEq("did", user.Did), 625 625 orm.FilterEq("domain", domain), 626 626 orm.FilterIsNot("registered", "null"), 627 627 )
+1 -1
appview/labels/labels.go
··· 86 86 return 87 87 } 88 88 89 - did := user.Active.Did 89 + did := user.Did 90 90 rkey := tid.TID() 91 91 performedAt := time.Now() 92 92 indexedAt := time.Now()
+4 -4
appview/middleware/middleware.go
··· 128 128 return 129 129 } 130 130 131 - ok, err := mw.enforcer.E.HasGroupingPolicy(actor.Active.Did, group, domain) 131 + ok, err := mw.enforcer.E.HasGroupingPolicy(actor.Did, group, domain) 132 132 if err != nil || !ok { 133 - log.Printf("%s does not have perms of a %s in domain %s", actor.Active.Did, group, domain) 133 + log.Printf("%s does not have perms of a %s in domain %s", actor.Did, group, domain) 134 134 http.Error(w, "Forbiden", http.StatusUnauthorized) 135 135 return 136 136 } ··· 161 161 return 162 162 } 163 163 164 - ok, err := mw.enforcer.E.Enforce(actor.Active.Did, f.Knot, f.DidSlashRepo(), requiredPerm) 164 + ok, err := mw.enforcer.E.Enforce(actor.Did, f.Knot, f.DidSlashRepo(), requiredPerm) 165 165 if err != nil || !ok { 166 - log.Printf("%s does not have perms of a %s in repo %s", actor.Active.Did, requiredPerm, f.DidSlashRepo()) 166 + log.Printf("%s does not have perms of a %s in repo %s", actor.Did, requiredPerm, f.DidSlashRepo()) 167 167 http.Error(w, "Forbiden", http.StatusUnauthorized) 168 168 return 169 169 }
+4 -4
appview/notifications/notifications.go
··· 54 54 55 55 total, err := db.CountNotifications( 56 56 n.db, 57 - orm.FilterEq("recipient_did", user.Active.Did), 57 + orm.FilterEq("recipient_did", user.Did), 58 58 ) 59 59 if err != nil { 60 60 l.Error("failed to get total notifications", "err", err) ··· 65 65 notifications, err := db.GetNotificationsWithEntities( 66 66 n.db, 67 67 page, 68 - orm.FilterEq("recipient_did", user.Active.Did), 68 + orm.FilterEq("recipient_did", user.Did), 69 69 ) 70 70 if err != nil { 71 71 l.Error("failed to get notifications", "err", err) ··· 73 73 return 74 74 } 75 75 76 - err = db.MarkAllNotificationsRead(n.db, user.Active.Did) 76 + err = db.MarkAllNotificationsRead(n.db, user.Did) 77 77 if err != nil { 78 78 l.Error("failed to mark notifications as read", "err", err) 79 79 } ··· 98 98 99 99 count, err := db.CountNotifications( 100 100 n.db, 101 - orm.FilterEq("recipient_did", user.Active.Did), 101 + orm.FilterEq("recipient_did", user.Did), 102 102 orm.FilterEq("read", 0), 103 103 ) 104 104 if err != nil {
+2 -8
appview/oauth/accounts.go
··· 22 22 } 23 23 24 24 type MultiAccountUser struct { 25 - Active User 25 + Did string 26 26 Accounts []AccountInfo 27 - } 28 - 29 - func (m *MultiAccountUser) Did() string { 30 - return m.Active.Did 31 27 } 32 28 33 29 func (o *OAuth) GetAccounts(r *http.Request) *AccountRegistry { ··· 116 112 117 113 registry := o.GetAccounts(r) 118 114 return &MultiAccountUser{ 119 - Active: User{ 120 - Did: sess.Data.AccountDID.String(), 121 - }, 115 + Did: sess.Data.AccountDID.String(), 122 116 Accounts: registry.Accounts, 123 117 } 124 118 }
+1 -5
appview/oauth/oauth.go
··· 235 235 return o.saveAccounts(w, r, registry) 236 236 } 237 237 238 - type User struct { 239 - Did string 240 - } 241 - 242 238 func (o *OAuth) GetDid(r *http.Request) string { 243 239 if u := o.GetMultiAccountUser(r); u != nil { 244 - return u.Did() 240 + return u.Did 245 241 } 246 242 247 243 return ""
+22 -22
appview/pulls/pulls.go
··· 132 132 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 133 133 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 134 134 resubmitResult := pages.Unknown 135 - if user.Active.Did == pull.OwnerDid { 135 + if user.Did == pull.OwnerDid { 136 136 resubmitResult = s.resubmitCheck(r, f, pull, stack) 137 137 } 138 138 ··· 195 195 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 196 196 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 197 197 resubmitResult := pages.Unknown 198 - if user != nil && user.Active.Did == pull.OwnerDid { 198 + if user != nil && user.Did == pull.OwnerDid { 199 199 resubmitResult = s.resubmitCheck(r, f, pull, stack) 200 200 } 201 201 ··· 236 236 237 237 userReactions := map[models.ReactionKind]bool{} 238 238 if user != nil { 239 - userReactions = db.GetReactionStatusMap(s.db, user.Active.Did, pull.AtUri()) 239 + userReactions = db.GetReactionStatusMap(s.db, user.Did, pull.AtUri()) 240 240 } 241 241 242 242 labelDefs, err := db.GetLabelDefinitions( ··· 406 406 } 407 407 408 408 // user can only delete branch if they are a collaborator in the repo that the branch belongs to 409 - perms := s.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.DidSlashRepo()) 409 + perms := s.enforcer.GetPermissionsInRepo(user.Did, repo.Knot, repo.DidSlashRepo()) 410 410 if !slices.Contains(perms, "repo:push") { 411 411 return nil 412 412 } ··· 844 844 } 845 845 atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 846 846 Collection: tangled.RepoPullCommentNSID, 847 - Repo: user.Active.Did, 847 + Repo: user.Did, 848 848 Rkey: tid.TID(), 849 849 Record: &lexutil.LexiconTypeDecoder{ 850 850 Val: &tangled.RepoPullComment{ ··· 861 861 } 862 862 863 863 comment := &models.PullComment{ 864 - OwnerDid: user.Active.Did, 864 + OwnerDid: user.Did, 865 865 RepoAt: f.RepoAt().String(), 866 866 PullId: pull.PullId, 867 867 Body: body, ··· 956 956 fromFork := r.FormValue("fork") 957 957 sourceBranch := r.FormValue("sourceBranch") 958 958 patch := r.FormValue("patch") 959 - userDid := syntax.DID(user.Active.Did) 959 + userDid := syntax.DID(user.Did) 960 960 961 961 if targetBranch == "" { 962 962 s.pages.Notice(w, "pull", "Target branch is required.") ··· 1586 1586 func (s *Pulls) CompareForksFragment(w http.ResponseWriter, r *http.Request) { 1587 1587 user := s.oauth.GetMultiAccountUser(r) 1588 1588 1589 - forks, err := db.GetForksByDid(s.db, user.Active.Did) 1589 + forks, err := db.GetForksByDid(s.db, user.Did) 1590 1590 if err != nil { 1591 1591 log.Println("failed to get forks", err) 1592 1592 return ··· 1733 1733 return 1734 1734 } 1735 1735 1736 - if user == nil || user.Active.Did != pull.OwnerDid { 1736 + if user == nil || user.Did != pull.OwnerDid { 1737 1737 log.Println("unauthorized user") 1738 1738 w.WriteHeader(http.StatusUnauthorized) 1739 1739 return ··· 1747 1747 1748 1748 patch := r.FormValue("patch") 1749 1749 1750 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, "", "") 1750 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, "", "") 1751 1751 } 1752 1752 1753 1753 func (s *Pulls) resubmitBranch(w http.ResponseWriter, r *http.Request) { ··· 1760 1760 return 1761 1761 } 1762 1762 1763 - if user == nil || user.Active.Did != pull.OwnerDid { 1763 + if user == nil || user.Did != pull.OwnerDid { 1764 1764 log.Println("unauthorized user") 1765 1765 w.WriteHeader(http.StatusUnauthorized) 1766 1766 return ··· 1772 1772 return 1773 1773 } 1774 1774 1775 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 1775 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 1776 1776 if !roles.IsPushAllowed() { 1777 1777 log.Println("unauthorized user") 1778 1778 w.WriteHeader(http.StatusUnauthorized) ··· 1812 1812 patch := comparison.FormatPatchRaw 1813 1813 combined := comparison.CombinedPatchRaw 1814 1814 1815 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1815 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1816 1816 } 1817 1817 1818 1818 func (s *Pulls) resubmitFork(w http.ResponseWriter, r *http.Request) { ··· 1825 1825 return 1826 1826 } 1827 1827 1828 - if user == nil || user.Active.Did != pull.OwnerDid { 1828 + if user == nil || user.Did != pull.OwnerDid { 1829 1829 log.Println("unauthorized user") 1830 1830 w.WriteHeader(http.StatusUnauthorized) 1831 1831 return ··· 1909 1909 patch := comparison.FormatPatchRaw 1910 1910 combined := comparison.CombinedPatchRaw 1911 1911 1912 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1912 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1913 1913 } 1914 1914 1915 1915 func (s *Pulls) resubmitPullHelper( ··· 2337 2337 2338 2338 // notify about the pull merge 2339 2339 for _, p := range pullsToMerge { 2340 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2340 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2341 2341 } 2342 2342 2343 2343 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2361 2361 } 2362 2362 2363 2363 // auth filter: only owner or collaborators can close 2364 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 2364 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 2365 2365 isOwner := roles.IsOwner() 2366 2366 isCollaborator := roles.IsCollaborator() 2367 - isPullAuthor := user.Active.Did == pull.OwnerDid 2367 + isPullAuthor := user.Did == pull.OwnerDid 2368 2368 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2369 2369 if !isCloseAllowed { 2370 2370 log.Println("failed to close pull") ··· 2410 2410 } 2411 2411 2412 2412 for _, p := range pullsToClose { 2413 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2413 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2414 2414 } 2415 2415 2416 2416 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2435 2435 } 2436 2436 2437 2437 // auth filter: only owner or collaborators can close 2438 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 2438 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 2439 2439 isOwner := roles.IsOwner() 2440 2440 isCollaborator := roles.IsCollaborator() 2441 - isPullAuthor := user.Active.Did == pull.OwnerDid 2441 + isPullAuthor := user.Did == pull.OwnerDid 2442 2442 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2443 2443 if !isCloseAllowed { 2444 2444 log.Println("failed to close pull") ··· 2484 2484 } 2485 2485 2486 2486 for _, p := range pullsToReopen { 2487 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2487 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2488 2488 } 2489 2489 2490 2490 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f)
+4 -4
appview/repo/artifact.go
··· 77 77 78 78 putRecordResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 79 79 Collection: tangled.RepoArtifactNSID, 80 - Repo: user.Active.Did, 80 + Repo: user.Did, 81 81 Rkey: rkey, 82 82 Record: &lexutil.LexiconTypeDecoder{ 83 83 Val: &tangled.RepoArtifact{ ··· 106 106 defer tx.Rollback() 107 107 108 108 artifact := models.Artifact{ 109 - Did: user.Active.Did, 109 + Did: user.Did, 110 110 Rkey: rkey, 111 111 RepoAt: f.RepoAt(), 112 112 Tag: tag.Tag.Hash, ··· 257 257 258 258 artifact := artifacts[0] 259 259 260 - if user.Active.Did != artifact.Did { 260 + if user.Did != artifact.Did { 261 261 l.Error("user not authorized to delete artifact", "err", err) 262 262 rp.pages.Notice(w, "remove", "Unauthorized deletion of artifact.") 263 263 return ··· 265 265 266 266 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 267 267 Collection: tangled.RepoArtifactNSID, 268 - Repo: user.Active.Did, 268 + Repo: user.Did, 269 269 Rkey: artifact.Rkey, 270 270 }) 271 271 if err != nil {
+21 -21
appview/repo/repo.go
··· 83 83 func (rp *Repo) EditSpindle(w http.ResponseWriter, r *http.Request) { 84 84 user := rp.oauth.GetMultiAccountUser(r) 85 85 l := rp.logger.With("handler", "EditSpindle") 86 - l = l.With("did", user.Active.Did) 86 + l = l.With("did", user.Did) 87 87 88 88 errorId := "operation-error" 89 89 fail := func(msg string, err error) { ··· 107 107 108 108 if !removingSpindle { 109 109 // ensure that this is a valid spindle for this user 110 - validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Active.Did) 110 + validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Did) 111 111 if err != nil { 112 112 fail("Failed to find spindles. Try again later.", err) 113 113 return ··· 170 170 func (rp *Repo) AddLabelDef(w http.ResponseWriter, r *http.Request) { 171 171 user := rp.oauth.GetMultiAccountUser(r) 172 172 l := rp.logger.With("handler", "AddLabel") 173 - l = l.With("did", user.Active.Did) 173 + l = l.With("did", user.Did) 174 174 175 175 f, err := rp.repoResolver.Resolve(r) 176 176 if err != nil { ··· 216 216 } 217 217 218 218 label := models.LabelDefinition{ 219 - Did: user.Active.Did, 219 + Did: user.Did, 220 220 Rkey: tid.TID(), 221 221 Name: name, 222 222 ValueType: valueType, ··· 329 329 func (rp *Repo) DeleteLabelDef(w http.ResponseWriter, r *http.Request) { 330 330 user := rp.oauth.GetMultiAccountUser(r) 331 331 l := rp.logger.With("handler", "DeleteLabel") 332 - l = l.With("did", user.Active.Did) 332 + l = l.With("did", user.Did) 333 333 334 334 f, err := rp.repoResolver.Resolve(r) 335 335 if err != nil { ··· 437 437 func (rp *Repo) SubscribeLabel(w http.ResponseWriter, r *http.Request) { 438 438 user := rp.oauth.GetMultiAccountUser(r) 439 439 l := rp.logger.With("handler", "SubscribeLabel") 440 - l = l.With("did", user.Active.Did) 440 + l = l.With("did", user.Did) 441 441 442 442 f, err := rp.repoResolver.Resolve(r) 443 443 if err != nil { ··· 523 523 func (rp *Repo) UnsubscribeLabel(w http.ResponseWriter, r *http.Request) { 524 524 user := rp.oauth.GetMultiAccountUser(r) 525 525 l := rp.logger.With("handler", "UnsubscribeLabel") 526 - l = l.With("did", user.Active.Did) 526 + l = l.With("did", user.Did) 527 527 528 528 f, err := rp.repoResolver.Resolve(r) 529 529 if err != nil { ··· 694 694 func (rp *Repo) AddCollaborator(w http.ResponseWriter, r *http.Request) { 695 695 user := rp.oauth.GetMultiAccountUser(r) 696 696 l := rp.logger.With("handler", "AddCollaborator") 697 - l = l.With("did", user.Active.Did) 697 + l = l.With("did", user.Did) 698 698 699 699 f, err := rp.repoResolver.Resolve(r) 700 700 if err != nil { ··· 723 723 return 724 724 } 725 725 726 - if collaboratorIdent.DID.String() == user.Active.Did { 726 + if collaboratorIdent.DID.String() == user.Did { 727 727 fail("You seem to be adding yourself as a collaborator.", nil) 728 728 return 729 729 } ··· 743 743 createdAt := time.Now() 744 744 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 745 745 Collection: tangled.RepoCollaboratorNSID, 746 - Repo: currentUser.Active.Did, 746 + Repo: currentUser.Did, 747 747 Rkey: rkey, 748 748 Record: &lexutil.LexiconTypeDecoder{ 749 749 Val: &tangled.RepoCollaborator{ ··· 792 792 } 793 793 794 794 err = db.AddCollaborator(tx, models.Collaborator{ 795 - Did: syntax.DID(currentUser.Active.Did), 795 + Did: syntax.DID(currentUser.Did), 796 796 Rkey: rkey, 797 797 SubjectDid: collaboratorIdent.DID, 798 798 RepoAt: f.RepoAt(), ··· 840 840 } 841 841 _, err = comatproto.RepoDeleteRecord(r.Context(), atpClient, &comatproto.RepoDeleteRecord_Input{ 842 842 Collection: tangled.RepoNSID, 843 - Repo: user.Active.Did, 843 + Repo: user.Did, 844 844 Rkey: f.Rkey, 845 845 }) 846 846 if err != nil { ··· 969 969 r.Context(), 970 970 client, 971 971 &tangled.RepoForkSync_Input{ 972 - Did: user.Active.Did, 972 + Did: user.Did, 973 973 Name: f.Name, 974 974 Source: f.Source, 975 975 Branch: ref, ··· 998 998 switch r.Method { 999 999 case http.MethodGet: 1000 1000 user := rp.oauth.GetMultiAccountUser(r) 1001 - knots, err := rp.enforcer.GetKnotsForUser(user.Active.Did) 1001 + knots, err := rp.enforcer.GetKnotsForUser(user.Did) 1002 1002 if err != nil { 1003 1003 rp.pages.Notice(w, "repo", "Invalid user account.") 1004 1004 return ··· 1020 1020 } 1021 1021 l = l.With("targetKnot", targetKnot) 1022 1022 1023 - ok, err := rp.enforcer.E.Enforce(user.Active.Did, targetKnot, targetKnot, "repo:create") 1023 + ok, err := rp.enforcer.E.Enforce(user.Did, targetKnot, targetKnot, "repo:create") 1024 1024 if err != nil || !ok { 1025 1025 rp.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") 1026 1026 return ··· 1037 1037 // in the user's account. 1038 1038 existingRepo, err := db.GetRepo( 1039 1039 rp.db, 1040 - orm.FilterEq("did", user.Active.Did), 1040 + orm.FilterEq("did", user.Did), 1041 1041 orm.FilterEq("name", forkName), 1042 1042 ) 1043 1043 if err != nil { ··· 1066 1066 // create an atproto record for this fork 1067 1067 rkey := tid.TID() 1068 1068 repo := &models.Repo{ 1069 - Did: user.Active.Did, 1069 + Did: user.Did, 1070 1070 Name: forkName, 1071 1071 Knot: targetKnot, 1072 1072 Rkey: rkey, ··· 1086 1086 1087 1087 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 1088 1088 Collection: tangled.RepoNSID, 1089 - Repo: user.Active.Did, 1089 + Repo: user.Did, 1090 1090 Rkey: rkey, 1091 1091 Record: &lexutil.LexiconTypeDecoder{ 1092 1092 Val: &record, ··· 1165 1165 } 1166 1166 1167 1167 // acls 1168 - p, _ := securejoin.SecureJoin(user.Active.Did, forkName) 1169 - err = rp.enforcer.AddRepo(user.Active.Did, targetKnot, p) 1168 + p, _ := securejoin.SecureJoin(user.Did, forkName) 1169 + err = rp.enforcer.AddRepo(user.Did, targetKnot, p) 1170 1170 if err != nil { 1171 1171 l.Error("failed to add ACLs", "err", err) 1172 1172 rp.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 1191 1191 aturi = "" 1192 1192 1193 1193 rp.notifier.NewRepo(r.Context(), repo) 1194 - rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, forkName)) 1194 + rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, forkName)) 1195 1195 } 1196 1196 } 1197 1197
+1 -1
appview/repo/settings.go
··· 70 70 func (rp *Repo) Secrets(w http.ResponseWriter, r *http.Request) { 71 71 user := rp.oauth.GetMultiAccountUser(r) 72 72 l := rp.logger.With("handler", "Secrets") 73 - l = l.With("did", user.Active.Did) 73 + l = l.With("did", user.Did) 74 74 75 75 f, err := rp.repoResolver.Resolve(r) 76 76 if err != nil {
+2 -2
appview/reporesolver/resolver.go
··· 76 76 isStarred := false 77 77 roles := repoinfo.RolesInRepo{} 78 78 if user != nil { 79 - isStarred = db.GetStarStatus(rr.execer, user.Active.Did, repoAt) 80 - roles.Roles = rr.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.DidSlashRepo()) 79 + isStarred = db.GetStarStatus(rr.execer, user.Did, repoAt) 80 + roles.Roles = rr.enforcer.GetPermissionsInRepo(user.Did, repo.Knot, repo.DidSlashRepo()) 81 81 } 82 82 83 83 stats := repo.RepoStats
+3 -3
appview/settings/settings.go
··· 70 70 func (s *Settings) profileSettings(w http.ResponseWriter, r *http.Request) { 71 71 user := s.OAuth.GetMultiAccountUser(r) 72 72 73 - punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did()) 73 + punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did) 74 74 if err != nil { 75 75 log.Printf("failed to get users punchcard preferences: %s", err) 76 76 } ··· 127 127 128 128 func (s *Settings) keysSettings(w http.ResponseWriter, r *http.Request) { 129 129 user := s.OAuth.GetMultiAccountUser(r) 130 - pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Active.Did) 130 + pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Did) 131 131 if err != nil { 132 132 log.Println(err) 133 133 } ··· 140 140 141 141 func (s *Settings) emailsSettings(w http.ResponseWriter, r *http.Request) { 142 142 user := s.OAuth.GetMultiAccountUser(r) 143 - emails, err := db.GetAllEmails(s.Db, user.Active.Did) 143 + emails, err := db.GetAllEmails(s.Db, user.Did) 144 144 if err != nil { 145 145 log.Println(err) 146 146 }
+34 -34
appview/spindles/spindles.go
··· 59 59 user := s.OAuth.GetMultiAccountUser(r) 60 60 all, err := db.GetSpindles( 61 61 s.Db, 62 - orm.FilterEq("owner", user.Active.Did), 62 + orm.FilterEq("owner", user.Did), 63 63 ) 64 64 if err != nil { 65 65 s.Logger.Error("failed to fetch spindles", "err", err) ··· 78 78 l := s.Logger.With("handler", "dashboard") 79 79 80 80 user := s.OAuth.GetMultiAccountUser(r) 81 - l = l.With("user", user.Active.Did) 81 + l = l.With("user", user.Did) 82 82 83 83 instance := chi.URLParam(r, "instance") 84 84 if instance == "" { ··· 89 89 spindles, err := db.GetSpindles( 90 90 s.Db, 91 91 orm.FilterEq("instance", instance), 92 - orm.FilterEq("owner", user.Active.Did), 92 + orm.FilterEq("owner", user.Did), 93 93 orm.FilterIsNot("verified", "null"), 94 94 ) 95 95 if err != nil || len(spindles) != 1 { ··· 161 161 return 162 162 } 163 163 l = l.With("instance", instance) 164 - l = l.With("user", user.Active.Did) 164 + l = l.With("user", user.Did) 165 165 166 166 tx, err := s.Db.Begin() 167 167 if err != nil { ··· 175 175 }() 176 176 177 177 err = db.AddSpindle(tx, models.Spindle{ 178 - Owner: syntax.DID(user.Active.Did), 178 + Owner: syntax.DID(user.Did), 179 179 Instance: instance, 180 180 }) 181 181 if err != nil { ··· 199 199 return 200 200 } 201 201 202 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Active.Did, instance) 202 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Did, instance) 203 203 var exCid *string 204 204 if ex != nil { 205 205 exCid = ex.Cid ··· 208 208 // re-announce by registering under same rkey 209 209 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 210 210 Collection: tangled.SpindleNSID, 211 - Repo: user.Active.Did, 211 + Repo: user.Did, 212 212 Rkey: instance, 213 213 Record: &lexutil.LexiconTypeDecoder{ 214 214 Val: &tangled.Spindle{ ··· 239 239 } 240 240 241 241 // begin verification 242 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 242 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 243 243 if err != nil { 244 244 l.Error("verification failed", "err", err) 245 245 s.Pages.HxRefresh(w) 246 246 return 247 247 } 248 248 249 - _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 249 + _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 250 250 if err != nil { 251 251 l.Error("failed to mark verified", "err", err) 252 252 s.Pages.HxRefresh(w) ··· 276 276 277 277 spindles, err := db.GetSpindles( 278 278 s.Db, 279 - orm.FilterEq("owner", user.Active.Did), 279 + orm.FilterEq("owner", user.Did), 280 280 orm.FilterEq("instance", instance), 281 281 ) 282 282 if err != nil || len(spindles) != 1 { ··· 285 285 return 286 286 } 287 287 288 - if string(spindles[0].Owner) != user.Active.Did { 289 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 288 + if string(spindles[0].Owner) != user.Did { 289 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 290 290 s.Pages.Notice(w, noticeId, "Failed to delete spindle, unauthorized deletion attempt.") 291 291 return 292 292 } ··· 305 305 // remove spindle members first 306 306 err = db.RemoveSpindleMember( 307 307 tx, 308 - orm.FilterEq("did", user.Active.Did), 308 + orm.FilterEq("did", user.Did), 309 309 orm.FilterEq("instance", instance), 310 310 ) 311 311 if err != nil { ··· 316 316 317 317 err = db.DeleteSpindle( 318 318 tx, 319 - orm.FilterEq("owner", user.Active.Did), 319 + orm.FilterEq("owner", user.Did), 320 320 orm.FilterEq("instance", instance), 321 321 ) 322 322 if err != nil { ··· 344 344 345 345 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 346 346 Collection: tangled.SpindleNSID, 347 - Repo: user.Active.Did, 347 + Repo: user.Did, 348 348 Rkey: instance, 349 349 }) 350 350 if err != nil { ··· 392 392 return 393 393 } 394 394 l = l.With("instance", instance) 395 - l = l.With("user", user.Active.Did) 395 + l = l.With("user", user.Did) 396 396 397 397 spindles, err := db.GetSpindles( 398 398 s.Db, 399 - orm.FilterEq("owner", user.Active.Did), 399 + orm.FilterEq("owner", user.Did), 400 400 orm.FilterEq("instance", instance), 401 401 ) 402 402 if err != nil || len(spindles) != 1 { ··· 405 405 return 406 406 } 407 407 408 - if string(spindles[0].Owner) != user.Active.Did { 409 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 408 + if string(spindles[0].Owner) != user.Did { 409 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 410 410 s.Pages.Notice(w, noticeId, "Failed to verify spindle, unauthorized verification attempt.") 411 411 return 412 412 } 413 413 414 414 // begin verification 415 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 415 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 416 416 if err != nil { 417 417 l.Error("verification failed", "err", err) 418 418 ··· 430 430 return 431 431 } 432 432 433 - rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 433 + rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 434 434 if err != nil { 435 435 l.Error("failed to mark verified", "err", err) 436 436 s.Pages.Notice(w, noticeId, err.Error()) ··· 468 468 return 469 469 } 470 470 l = l.With("instance", instance) 471 - l = l.With("user", user.Active.Did) 471 + l = l.With("user", user.Did) 472 472 473 473 spindles, err := db.GetSpindles( 474 474 s.Db, 475 - orm.FilterEq("owner", user.Active.Did), 475 + orm.FilterEq("owner", user.Did), 476 476 orm.FilterEq("instance", instance), 477 477 ) 478 478 if err != nil || len(spindles) != 1 { ··· 487 487 s.Pages.Notice(w, noticeId, defaultErr) 488 488 } 489 489 490 - if string(spindles[0].Owner) != user.Active.Did { 491 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 490 + if string(spindles[0].Owner) != user.Did { 491 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 492 492 s.Pages.Notice(w, noticeId, "Failed to add member, unauthorized attempt.") 493 493 return 494 494 } ··· 537 537 538 538 // add member to db 539 539 if err = db.AddSpindleMember(tx, models.SpindleMember{ 540 - Did: syntax.DID(user.Active.Did), 540 + Did: syntax.DID(user.Did), 541 541 Rkey: rkey, 542 542 Instance: instance, 543 543 Subject: memberId.DID, ··· 555 555 556 556 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 557 557 Collection: tangled.SpindleMemberNSID, 558 - Repo: user.Active.Did, 558 + Repo: user.Did, 559 559 Rkey: rkey, 560 560 Record: &lexutil.LexiconTypeDecoder{ 561 561 Val: &tangled.SpindleMember{ ··· 604 604 return 605 605 } 606 606 l = l.With("instance", instance) 607 - l = l.With("user", user.Active.Did) 607 + l = l.With("user", user.Did) 608 608 609 609 spindles, err := db.GetSpindles( 610 610 s.Db, 611 - orm.FilterEq("owner", user.Active.Did), 611 + orm.FilterEq("owner", user.Did), 612 612 orm.FilterEq("instance", instance), 613 613 ) 614 614 if err != nil || len(spindles) != 1 { ··· 617 617 return 618 618 } 619 619 620 - if string(spindles[0].Owner) != user.Active.Did { 621 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 620 + if string(spindles[0].Owner) != user.Did { 621 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 622 622 s.Pages.Notice(w, noticeId, "Failed to remove member, unauthorized attempt.") 623 623 return 624 624 } ··· 653 653 // get the record from the DB first: 654 654 members, err := db.GetSpindleMembers( 655 655 s.Db, 656 - orm.FilterEq("did", user.Active.Did), 656 + orm.FilterEq("did", user.Did), 657 657 orm.FilterEq("instance", instance), 658 658 orm.FilterEq("subject", memberId.DID), 659 659 ) ··· 666 666 // remove from db 667 667 if err = db.RemoveSpindleMember( 668 668 tx, 669 - orm.FilterEq("did", user.Active.Did), 669 + orm.FilterEq("did", user.Did), 670 670 orm.FilterEq("instance", instance), 671 671 orm.FilterEq("subject", memberId.DID), 672 672 ); err != nil { ··· 692 692 // remove from pds 693 693 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 694 694 Collection: tangled.SpindleMemberNSID, 695 - Repo: user.Active.Did, 695 + Repo: user.Did, 696 696 Rkey: members[0].Rkey, 697 697 }) 698 698 if err != nil {
+1 -1
appview/state/accounts.go
··· 41 41 } 42 42 43 43 currentUser := s.oauth.GetMultiAccountUser(r) 44 - isCurrentAccount := currentUser != nil && currentUser.Active.Did == did 44 + isCurrentAccount := currentUser != nil && currentUser.Did == did 45 45 46 46 var remainingAccounts []string 47 47 if currentUser != nil {
+6 -6
appview/state/follow.go
··· 29 29 return 30 30 } 31 31 32 - if currentUser.Active.Did == subjectIdent.DID.String() { 32 + if currentUser.Did == subjectIdent.DID.String() { 33 33 log.Println("cant follow or unfollow yourself") 34 34 return 35 35 } ··· 46 46 rkey := tid.TID() 47 47 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 48 48 Collection: tangled.GraphFollowNSID, 49 - Repo: currentUser.Active.Did, 49 + Repo: currentUser.Did, 50 50 Rkey: rkey, 51 51 Record: &lexutil.LexiconTypeDecoder{ 52 52 Val: &tangled.GraphFollow{ ··· 62 62 log.Println("created atproto record: ", resp.Uri) 63 63 64 64 follow := &models.Follow{ 65 - UserDid: currentUser.Active.Did, 65 + UserDid: currentUser.Did, 66 66 SubjectDid: subjectIdent.DID.String(), 67 67 Rkey: rkey, 68 68 } ··· 89 89 return 90 90 case http.MethodDelete: 91 91 // find the record in the db 92 - follow, err := db.GetFollow(s.db, currentUser.Active.Did, subjectIdent.DID.String()) 92 + follow, err := db.GetFollow(s.db, currentUser.Did, subjectIdent.DID.String()) 93 93 if err != nil { 94 94 log.Println("failed to get follow relationship") 95 95 return ··· 97 97 98 98 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 99 99 Collection: tangled.GraphFollowNSID, 100 - Repo: currentUser.Active.Did, 100 + Repo: currentUser.Did, 101 101 Rkey: follow.Rkey, 102 102 }) 103 103 ··· 106 106 return 107 107 } 108 108 109 - err = db.DeleteFollowByRkey(s.db, currentUser.Active.Did, follow.Rkey) 109 + err = db.DeleteFollowByRkey(s.db, currentUser.Did, follow.Rkey) 110 110 if err != nil { 111 111 log.Println("failed to delete follow from DB") 112 112 // this is not an issue, the firehose event might have already done this
+1 -1
appview/state/login.go
··· 81 81 return 82 82 } 83 83 84 - currentDid := currentUser.Active.Did 84 + currentDid := currentUser.Did 85 85 86 86 var remainingAccounts []string 87 87 for _, acc := range currentUser.Accounts {
+35 -39
appview/state/profile.go
··· 86 86 loggedInUser := s.oauth.GetMultiAccountUser(r) 87 87 followStatus := models.IsNotFollowing 88 88 if loggedInUser != nil { 89 - followStatus = db.GetFollowStatus(s.db, loggedInUser.Active.Did, did) 89 + followStatus = db.GetFollowStatus(s.db, loggedInUser.Did, did) 90 90 } 91 91 92 - var loggedInDid string 93 - if loggedInUser != nil { 94 - loggedInDid = loggedInUser.Did() 95 - } 96 - showPunchcard := s.shouldShowPunchcard(did, loggedInDid) 92 + showPunchcard := s.shouldShowPunchcard(did, loggedInUser.Did) 97 93 98 94 var punchcard *models.Punchcard 99 95 if showPunchcard { ··· 352 348 353 349 loggedInUserFollowing := make(map[string]struct{}) 354 350 if loggedInUser != nil { 355 - following, err := db.GetFollowing(s.db, loggedInUser.Active.Did) 351 + following, err := db.GetFollowing(s.db, loggedInUser.Did) 356 352 if err != nil { 357 - l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Active.Did) 353 + l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Did) 358 354 return &params, err 359 355 } 360 356 loggedInUserFollowing = make(map[string]struct{}, len(following)) ··· 369 365 followStatus := models.IsNotFollowing 370 366 if _, exists := loggedInUserFollowing[did]; exists { 371 367 followStatus = models.IsFollowing 372 - } else if loggedInUser != nil && loggedInUser.Active.Did == did { 368 + } else if loggedInUser != nil && loggedInUser.Did == did { 373 369 followStatus = models.IsSelf 374 370 } 375 371 ··· 575 571 return 576 572 } 577 573 578 - profile, err := db.GetProfile(s.db, user.Active.Did) 574 + profile, err := db.GetProfile(s.db, user.Did) 579 575 if err != nil { 580 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 576 + log.Printf("getting profile data for %s: %s", user.Did, err) 581 577 } 582 578 if profile == nil { 583 - profile = &models.Profile{Did: user.Active.Did} 579 + profile = &models.Profile{Did: user.Did} 584 580 } 585 581 586 582 profile.Description = r.FormValue("description") ··· 621 617 return 622 618 } 623 619 624 - profile, err := db.GetProfile(s.db, user.Active.Did) 620 + profile, err := db.GetProfile(s.db, user.Did) 625 621 if err != nil { 626 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 622 + log.Printf("getting profile data for %s: %s", user.Did, err) 627 623 } 628 624 if profile == nil { 629 - profile = &models.Profile{Did: user.Active.Did} 625 + profile = &models.Profile{Did: user.Did} 630 626 } 631 627 632 628 i := 0 ··· 681 677 vanityStats = append(vanityStats, string(v.Kind)) 682 678 } 683 679 684 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 680 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 685 681 var cid *string 686 682 if ex != nil { 687 683 cid = ex.Cid ··· 689 685 690 686 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 691 687 Collection: tangled.ActorProfileNSID, 692 - Repo: user.Active.Did, 688 + Repo: user.Did, 693 689 Rkey: "self", 694 690 Record: &lexutil.LexiconTypeDecoder{ 695 691 Val: &tangled.ActorProfile{ ··· 718 714 719 715 s.notifier.UpdateProfile(r.Context(), profile) 720 716 721 - s.pages.HxRedirect(w, "/"+user.Active.Did) 717 + s.pages.HxRedirect(w, "/"+user.Did) 722 718 } 723 719 724 720 func (s *State) EditBioFragment(w http.ResponseWriter, r *http.Request) { 725 721 user := s.oauth.GetMultiAccountUser(r) 726 722 727 - profile, err := db.GetProfile(s.db, user.Active.Did) 723 + profile, err := db.GetProfile(s.db, user.Did) 728 724 if err != nil { 729 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 725 + log.Printf("getting profile data for %s: %s", user.Did, err) 730 726 } 731 727 if profile == nil { 732 - profile = &models.Profile{Did: user.Active.Did} 728 + profile = &models.Profile{Did: user.Did} 733 729 } 734 730 735 731 s.pages.EditBioFragment(w, pages.EditBioParams{ ··· 741 737 func (s *State) EditPinsFragment(w http.ResponseWriter, r *http.Request) { 742 738 user := s.oauth.GetMultiAccountUser(r) 743 739 744 - profile, err := db.GetProfile(s.db, user.Active.Did) 740 + profile, err := db.GetProfile(s.db, user.Did) 745 741 if err != nil { 746 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 742 + log.Printf("getting profile data for %s: %s", user.Did, err) 747 743 } 748 744 if profile == nil { 749 - profile = &models.Profile{Did: user.Active.Did} 745 + profile = &models.Profile{Did: user.Did} 750 746 } 751 747 752 - repos, err := db.GetRepos(s.db, 0, orm.FilterEq("did", user.Active.Did)) 748 + repos, err := db.GetRepos(s.db, 0, orm.FilterEq("did", user.Did)) 753 749 if err != nil { 754 - log.Printf("getting repos for %s: %s", user.Active.Did, err) 750 + log.Printf("getting repos for %s: %s", user.Did, err) 755 751 } 756 752 757 - collaboratingRepos, err := db.CollaboratingIn(s.db, user.Active.Did) 753 + collaboratingRepos, err := db.CollaboratingIn(s.db, user.Did) 758 754 if err != nil { 759 - log.Printf("getting collaborating repos for %s: %s", user.Active.Did, err) 755 + log.Printf("getting collaborating repos for %s: %s", user.Did, err) 760 756 } 761 757 762 758 allRepos := []pages.PinnedRepo{} ··· 786 782 func (s *State) UploadProfileAvatar(w http.ResponseWriter, r *http.Request) { 787 783 l := s.logger.With("handler", "UploadProfileAvatar") 788 784 user := s.oauth.GetMultiAccountUser(r) 789 - l = l.With("did", user.Active.Did) 785 + l = l.With("did", user.Did) 790 786 791 787 // Parse multipart form (10MB max) 792 788 if err := r.ParseMultipartForm(10 << 20); err != nil { ··· 833 829 l.Info("uploaded avatar blob", "cid", uploadBlobResp.Blob.Ref.String()) 834 830 835 831 // get current profile record from PDS to get its CID for swap 836 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 832 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 837 833 if err != nil { 838 834 l.Error("failed to get current profile record", "err", err) 839 835 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 857 853 858 854 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 859 855 Collection: tangled.ActorProfileNSID, 860 - Repo: user.Active.Did, 856 + Repo: user.Did, 861 857 Rkey: "self", 862 858 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 863 859 SwapRecord: getRecordResp.Cid, ··· 871 867 872 868 l.Info("successfully updated profile with avatar") 873 869 874 - profile, err := db.GetProfile(s.db, user.Active.Did) 870 + profile, err := db.GetProfile(s.db, user.Did) 875 871 if err != nil { 876 872 l.Warn("getting profile data from DB", "err", err) 877 873 } 878 874 if profile == nil { 879 - profile = &models.Profile{Did: user.Active.Did} 875 + profile = &models.Profile{Did: user.Did} 880 876 } 881 877 profile.Avatar = uploadBlobResp.Blob.Ref.String() 882 878 ··· 902 898 func (s *State) RemoveProfileAvatar(w http.ResponseWriter, r *http.Request) { 903 899 l := s.logger.With("handler", "RemoveProfileAvatar") 904 900 user := s.oauth.GetMultiAccountUser(r) 905 - l = l.With("did", user.Active.Did) 901 + l = l.With("did", user.Did) 906 902 907 903 client, err := s.oauth.AuthorizedClient(r) 908 904 if err != nil { ··· 911 907 return 912 908 } 913 909 914 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 910 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 915 911 if err != nil { 916 912 l.Error("failed to get current profile record", "err", err) 917 913 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 935 931 936 932 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 937 933 Collection: tangled.ActorProfileNSID, 938 - Repo: user.Active.Did, 934 + Repo: user.Did, 939 935 Rkey: "self", 940 936 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 941 937 SwapRecord: getRecordResp.Cid, ··· 949 945 950 946 l.Info("successfully removed avatar from PDS") 951 947 952 - profile, err := db.GetProfile(s.db, user.Active.Did) 948 + profile, err := db.GetProfile(s.db, user.Did) 953 949 if err != nil { 954 950 l.Warn("getting profile data from DB", "err", err) 955 951 } 956 952 if profile == nil { 957 - profile = &models.Profile{Did: user.Active.Did} 953 + profile = &models.Profile{Did: user.Did} 958 954 } 959 955 profile.Avatar = "" 960 956 ··· 995 991 hideOthers = true 996 992 } 997 993 998 - err = db.UpsertPunchcardPreference(s.db, user.Active.Did, hideMine, hideOthers) 994 + err = db.UpsertPunchcardPreference(s.db, user.Did, hideMine, hideOthers) 999 995 if err != nil { 1000 996 log.Println("failed to update punchcard preferences", err) 1001 997 return
+6 -6
appview/state/reaction.go
··· 49 49 rkey := tid.TID() 50 50 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 51 51 Collection: tangled.FeedReactionNSID, 52 - Repo: currentUser.Active.Did, 52 + Repo: currentUser.Did, 53 53 Rkey: rkey, 54 54 Record: &lexutil.LexiconTypeDecoder{ 55 55 Val: &tangled.FeedReaction{ ··· 64 64 return 65 65 } 66 66 67 - err = db.AddReaction(s.db, currentUser.Active.Did, subjectUri, reactionKind, rkey) 67 + err = db.AddReaction(s.db, currentUser.Did, subjectUri, reactionKind, rkey) 68 68 if err != nil { 69 69 log.Println("failed to react", err) 70 70 return ··· 87 87 88 88 return 89 89 case http.MethodDelete: 90 - reaction, err := db.GetReaction(s.db, currentUser.Active.Did, subjectUri, reactionKind) 90 + reaction, err := db.GetReaction(s.db, currentUser.Did, subjectUri, reactionKind) 91 91 if err != nil { 92 - log.Println("failed to get reaction relationship for", currentUser.Active.Did, subjectUri) 92 + log.Println("failed to get reaction relationship for", currentUser.Did, subjectUri) 93 93 return 94 94 } 95 95 96 96 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 97 97 Collection: tangled.FeedReactionNSID, 98 - Repo: currentUser.Active.Did, 98 + Repo: currentUser.Did, 99 99 Rkey: reaction.Rkey, 100 100 }) 101 101 ··· 104 104 return 105 105 } 106 106 107 - err = db.DeleteReactionByRkey(s.db, currentUser.Active.Did, reaction.Rkey) 107 + err = db.DeleteReactionByRkey(s.db, currentUser.Did, reaction.Rkey) 108 108 if err != nil { 109 109 log.Println("failed to delete reaction from DB") 110 110 // this is not an issue, the firehose event might have already done this
+5 -5
appview/state/star.go
··· 42 42 rkey := tid.TID() 43 43 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 44 44 Collection: tangled.FeedStarNSID, 45 - Repo: currentUser.Active.Did, 45 + Repo: currentUser.Did, 46 46 Rkey: rkey, 47 47 Record: &lexutil.LexiconTypeDecoder{ 48 48 Val: &tangled.FeedStar{ ··· 57 57 log.Println("created atproto record: ", resp.Uri) 58 58 59 59 star := &models.Star{ 60 - Did: currentUser.Active.Did, 60 + Did: currentUser.Did, 61 61 RepoAt: subjectUri, 62 62 Rkey: rkey, 63 63 } ··· 84 84 return 85 85 case http.MethodDelete: 86 86 // find the record in the db 87 - star, err := db.GetStar(s.db, currentUser.Active.Did, subjectUri) 87 + star, err := db.GetStar(s.db, currentUser.Did, subjectUri) 88 88 if err != nil { 89 89 log.Println("failed to get star relationship") 90 90 return ··· 92 92 93 93 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 94 94 Collection: tangled.FeedStarNSID, 95 - Repo: currentUser.Active.Did, 95 + Repo: currentUser.Did, 96 96 Rkey: star.Rkey, 97 97 }) 98 98 ··· 101 101 return 102 102 } 103 103 104 - err = db.DeleteStarByRkey(s.db, currentUser.Active.Did, star.Rkey) 104 + err = db.DeleteStarByRkey(s.db, currentUser.Did, star.Rkey) 105 105 if err != nil { 106 106 log.Println("failed to delete star from DB") 107 107 // this is not an issue, the firehose event might have already done this
+12 -12
appview/state/state.go
··· 259 259 } 260 260 261 261 l := s.logger.With("handler", "UpgradeBanner") 262 - l = l.With("did", user.Active.Did) 262 + l = l.With("did", user.Did) 263 263 264 264 regs, err := db.GetRegistrations( 265 265 s.db, 266 - orm.FilterEq("did", user.Active.Did), 266 + orm.FilterEq("did", user.Did), 267 267 orm.FilterEq("needs_upgrade", 1), 268 268 ) 269 269 if err != nil { ··· 272 272 273 273 spindles, err := db.GetSpindles( 274 274 s.db, 275 - orm.FilterEq("owner", user.Active.Did), 275 + orm.FilterEq("owner", user.Did), 276 276 orm.FilterEq("needs_upgrade", 1), 277 277 ) 278 278 if err != nil { ··· 362 362 switch r.Method { 363 363 case http.MethodGet: 364 364 user := s.oauth.GetMultiAccountUser(r) 365 - knots, err := s.enforcer.GetKnotsForUser(user.Active.Did) 365 + knots, err := s.enforcer.GetKnotsForUser(user.Did) 366 366 if err != nil { 367 367 s.pages.Notice(w, "repo", "Invalid user account.") 368 368 return ··· 377 377 l := s.logger.With("handler", "NewRepo") 378 378 379 379 user := s.oauth.GetMultiAccountUser(r) 380 - l = l.With("did", user.Active.Did) 380 + l = l.With("did", user.Did) 381 381 382 382 // form validation 383 383 domain := r.FormValue("domain") ··· 413 413 } 414 414 415 415 // ACL validation 416 - ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create") 416 + ok, err := s.enforcer.E.Enforce(user.Did, domain, domain, "repo:create") 417 417 if err != nil || !ok { 418 418 l.Info("unauthorized") 419 419 s.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") ··· 423 423 // Check for existing repos 424 424 existingRepo, err := db.GetRepo( 425 425 s.db, 426 - orm.FilterEq("did", user.Active.Did), 426 + orm.FilterEq("did", user.Did), 427 427 orm.FilterEq("name", repoName), 428 428 ) 429 429 if err == nil && existingRepo != nil { ··· 435 435 // create atproto record for this repo 436 436 rkey := tid.TID() 437 437 repo := &models.Repo{ 438 - Did: user.Active.Did, 438 + Did: user.Did, 439 439 Name: repoName, 440 440 Knot: domain, 441 441 Rkey: rkey, ··· 454 454 455 455 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 456 456 Collection: tangled.RepoNSID, 457 - Repo: user.Active.Did, 457 + Repo: user.Did, 458 458 Rkey: rkey, 459 459 Record: &lexutil.LexiconTypeDecoder{ 460 460 Val: &record, ··· 531 531 } 532 532 533 533 // acls 534 - p, _ := securejoin.SecureJoin(user.Active.Did, repoName) 535 - err = s.enforcer.AddRepo(user.Active.Did, domain, p) 534 + p, _ := securejoin.SecureJoin(user.Did, repoName) 535 + err = s.enforcer.AddRepo(user.Did, domain, p) 536 536 if err != nil { 537 537 l.Error("acl setup failed", "err", err) 538 538 s.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 557 557 aturi = "" 558 558 559 559 s.notifier.NewRepo(r.Context(), repo) 560 - s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, repoName)) 560 + s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, repoName)) 561 561 } 562 562 } 563 563
+1 -1
appview/state/timeline.go
··· 48 48 49 49 var userDid string 50 50 if user != nil { 51 - userDid = user.Active.Did 51 + userDid = user.Did 52 52 } 53 53 timeline, err := db.MakeTimeline(s.db, 50, userDid, filtered) 54 54 if err != nil {
+12 -12
appview/strings/strings.go
··· 156 156 user := s.OAuth.GetMultiAccountUser(r) 157 157 isStarred := false 158 158 if user != nil { 159 - isStarred = db.GetStarStatus(s.Db, user.Active.Did, string.AtUri()) 159 + isStarred = db.GetStarStatus(s.Db, user.Did, string.AtUri()) 160 160 } 161 161 162 162 s.Pages.SingleString(w, pages.SingleStringParams{ ··· 216 216 first := all[0] 217 217 218 218 // verify that the logged in user owns this string 219 - if user.Active.Did != id.DID.String() { 220 - l.Error("unauthorized request", "expected", id.DID, "got", user.Active.Did) 219 + if user.Did != id.DID.String() { 220 + l.Error("unauthorized request", "expected", id.DID, "got", user.Did) 221 221 w.WriteHeader(http.StatusUnauthorized) 222 222 return 223 223 } ··· 299 299 s.Notifier.EditString(r.Context(), &entry) 300 300 301 301 // if that went okay, redir to the string 302 - s.Pages.HxRedirect(w, "/strings/"+user.Active.Did+"/"+entry.Rkey) 302 + s.Pages.HxRedirect(w, "/strings/"+user.Did+"/"+entry.Rkey) 303 303 } 304 304 305 305 } ··· 335 335 description := r.FormValue("description") 336 336 337 337 string := models.String{ 338 - Did: syntax.DID(user.Active.Did), 338 + Did: syntax.DID(user.Did), 339 339 Rkey: tid.TID(), 340 340 Filename: filename, 341 341 Description: description, ··· 353 353 354 354 resp, err := comatproto.RepoPutRecord(r.Context(), client, &atproto.RepoPutRecord_Input{ 355 355 Collection: tangled.StringNSID, 356 - Repo: user.Active.Did, 356 + Repo: user.Did, 357 357 Rkey: string.Rkey, 358 358 Record: &lexutil.LexiconTypeDecoder{ 359 359 Val: &record, ··· 375 375 s.Notifier.NewString(r.Context(), &string) 376 376 377 377 // successful 378 - s.Pages.HxRedirect(w, "/strings/"+user.Active.Did+"/"+string.Rkey) 378 + s.Pages.HxRedirect(w, "/strings/"+user.Did+"/"+string.Rkey) 379 379 } 380 380 } 381 381 ··· 402 402 return 403 403 } 404 404 405 - if user.Active.Did != id.DID.String() { 406 - fail("You cannot delete this string", fmt.Errorf("unauthorized deletion, %s != %s", user.Active.Did, id.DID.String())) 405 + if user.Did != id.DID.String() { 406 + fail("You cannot delete this string", fmt.Errorf("unauthorized deletion, %s != %s", user.Did, id.DID.String())) 407 407 return 408 408 } 409 409 410 410 if err := db.DeleteString( 411 411 s.Db, 412 - orm.FilterEq("did", user.Active.Did), 412 + orm.FilterEq("did", user.Did), 413 413 orm.FilterEq("rkey", rkey), 414 414 ); err != nil { 415 415 fail("Failed to delete string.", err) 416 416 return 417 417 } 418 418 419 - s.Notifier.DeleteString(r.Context(), user.Active.Did, rkey) 419 + s.Notifier.DeleteString(r.Context(), user.Did, rkey) 420 420 421 - s.Pages.HxRedirect(w, "/strings/"+user.Active.Did) 421 + s.Pages.HxRedirect(w, "/strings/"+user.Did) 422 422 } 423 423 424 424 func (s *Strings) comment(w http.ResponseWriter, r *http.Request) {