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 1cbac20e 75145d93

verified
+230 -244
+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
··· 89 89 func (rp *Repo) EditSpindle(w http.ResponseWriter, r *http.Request) { 90 90 user := rp.oauth.GetMultiAccountUser(r) 91 91 l := rp.logger.With("handler", "EditSpindle") 92 - l = l.With("did", user.Active.Did) 92 + l = l.With("did", user.Did) 93 93 94 94 errorId := "operation-error" 95 95 fail := func(msg string, err error) { ··· 113 113 114 114 if !removingSpindle { 115 115 // ensure that this is a valid spindle for this user 116 - validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Active.Did) 116 + validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Did) 117 117 if err != nil { 118 118 fail("Failed to find spindles. Try again later.", err) 119 119 return ··· 176 176 func (rp *Repo) AddLabelDef(w http.ResponseWriter, r *http.Request) { 177 177 user := rp.oauth.GetMultiAccountUser(r) 178 178 l := rp.logger.With("handler", "AddLabel") 179 - l = l.With("did", user.Active.Did) 179 + l = l.With("did", user.Did) 180 180 181 181 f, err := rp.repoResolver.Resolve(r) 182 182 if err != nil { ··· 222 222 } 223 223 224 224 label := models.LabelDefinition{ 225 - Did: user.Active.Did, 225 + Did: user.Did, 226 226 Rkey: tid.TID(), 227 227 Name: name, 228 228 ValueType: valueType, ··· 335 335 func (rp *Repo) DeleteLabelDef(w http.ResponseWriter, r *http.Request) { 336 336 user := rp.oauth.GetMultiAccountUser(r) 337 337 l := rp.logger.With("handler", "DeleteLabel") 338 - l = l.With("did", user.Active.Did) 338 + l = l.With("did", user.Did) 339 339 340 340 f, err := rp.repoResolver.Resolve(r) 341 341 if err != nil { ··· 443 443 func (rp *Repo) SubscribeLabel(w http.ResponseWriter, r *http.Request) { 444 444 user := rp.oauth.GetMultiAccountUser(r) 445 445 l := rp.logger.With("handler", "SubscribeLabel") 446 - l = l.With("did", user.Active.Did) 446 + l = l.With("did", user.Did) 447 447 448 448 f, err := rp.repoResolver.Resolve(r) 449 449 if err != nil { ··· 529 529 func (rp *Repo) UnsubscribeLabel(w http.ResponseWriter, r *http.Request) { 530 530 user := rp.oauth.GetMultiAccountUser(r) 531 531 l := rp.logger.With("handler", "UnsubscribeLabel") 532 - l = l.With("did", user.Active.Did) 532 + l = l.With("did", user.Did) 533 533 534 534 f, err := rp.repoResolver.Resolve(r) 535 535 if err != nil { ··· 700 700 func (rp *Repo) AddCollaborator(w http.ResponseWriter, r *http.Request) { 701 701 user := rp.oauth.GetMultiAccountUser(r) 702 702 l := rp.logger.With("handler", "AddCollaborator") 703 - l = l.With("did", user.Active.Did) 703 + l = l.With("did", user.Did) 704 704 705 705 f, err := rp.repoResolver.Resolve(r) 706 706 if err != nil { ··· 729 729 return 730 730 } 731 731 732 - if collaboratorIdent.DID.String() == user.Active.Did { 732 + if collaboratorIdent.DID.String() == user.Did { 733 733 fail("You seem to be adding yourself as a collaborator.", nil) 734 734 return 735 735 } ··· 749 749 createdAt := time.Now() 750 750 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 751 751 Collection: tangled.RepoCollaboratorNSID, 752 - Repo: currentUser.Active.Did, 752 + Repo: currentUser.Did, 753 753 Rkey: rkey, 754 754 Record: &lexutil.LexiconTypeDecoder{ 755 755 Val: &tangled.RepoCollaborator{ ··· 798 798 } 799 799 800 800 err = db.AddCollaborator(tx, models.Collaborator{ 801 - Did: syntax.DID(currentUser.Active.Did), 801 + Did: syntax.DID(currentUser.Did), 802 802 Rkey: rkey, 803 803 SubjectDid: collaboratorIdent.DID, 804 804 RepoAt: f.RepoAt(), ··· 846 846 } 847 847 _, err = comatproto.RepoDeleteRecord(r.Context(), atpClient, &comatproto.RepoDeleteRecord_Input{ 848 848 Collection: tangled.RepoNSID, 849 - Repo: user.Active.Did, 849 + Repo: user.Did, 850 850 Rkey: f.Rkey, 851 851 }) 852 852 if err != nil { ··· 975 975 r.Context(), 976 976 client, 977 977 &tangled.RepoForkSync_Input{ 978 - Did: user.Active.Did, 978 + Did: user.Did, 979 979 Name: f.Name, 980 980 Source: f.Source, 981 981 Branch: ref, ··· 1004 1004 switch r.Method { 1005 1005 case http.MethodGet: 1006 1006 user := rp.oauth.GetMultiAccountUser(r) 1007 - knots, err := rp.enforcer.GetKnotsForUser(user.Active.Did) 1007 + knots, err := rp.enforcer.GetKnotsForUser(user.Did) 1008 1008 if err != nil { 1009 1009 rp.pages.Notice(w, "repo", "Invalid user account.") 1010 1010 return ··· 1026 1026 } 1027 1027 l = l.With("targetKnot", targetKnot) 1028 1028 1029 - ok, err := rp.enforcer.E.Enforce(user.Active.Did, targetKnot, targetKnot, "repo:create") 1029 + ok, err := rp.enforcer.E.Enforce(user.Did, targetKnot, targetKnot, "repo:create") 1030 1030 if err != nil || !ok { 1031 1031 rp.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") 1032 1032 return ··· 1043 1043 // in the user's account. 1044 1044 existingRepo, err := db.GetRepo( 1045 1045 rp.db, 1046 - orm.FilterEq("did", user.Active.Did), 1046 + orm.FilterEq("did", user.Did), 1047 1047 orm.FilterEq("name", forkName), 1048 1048 ) 1049 1049 if err != nil { ··· 1072 1072 // create an atproto record for this fork 1073 1073 rkey := tid.TID() 1074 1074 repo := &models.Repo{ 1075 - Did: user.Active.Did, 1075 + Did: user.Did, 1076 1076 Name: forkName, 1077 1077 Knot: targetKnot, 1078 1078 Rkey: rkey, ··· 1092 1092 1093 1093 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 1094 1094 Collection: tangled.RepoNSID, 1095 - Repo: user.Active.Did, 1095 + Repo: user.Did, 1096 1096 Rkey: rkey, 1097 1097 Record: &lexutil.LexiconTypeDecoder{ 1098 1098 Val: &record, ··· 1171 1171 } 1172 1172 1173 1173 // acls 1174 - p, _ := securejoin.SecureJoin(user.Active.Did, forkName) 1175 - err = rp.enforcer.AddRepo(user.Active.Did, targetKnot, p) 1174 + p, _ := securejoin.SecureJoin(user.Did, forkName) 1175 + err = rp.enforcer.AddRepo(user.Did, targetKnot, p) 1176 1176 if err != nil { 1177 1177 l.Error("failed to add ACLs", "err", err) 1178 1178 rp.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 1197 1197 aturi = "" 1198 1198 1199 1199 rp.notifier.NewRepo(r.Context(), repo) 1200 - rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, forkName)) 1200 + rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, forkName)) 1201 1201 } 1202 1202 } 1203 1203
+1 -1
appview/repo/settings.go
··· 74 74 func (rp *Repo) Secrets(w http.ResponseWriter, r *http.Request) { 75 75 user := rp.oauth.GetMultiAccountUser(r) 76 76 l := rp.logger.With("handler", "Secrets") 77 - l = l.With("did", user.Active.Did) 77 + l = l.With("did", user.Did) 78 78 79 79 f, err := rp.repoResolver.Resolve(r) 80 80 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
+11 -11
appview/settings/settings.go
··· 84 84 func (s *Settings) sitesSettings(w http.ResponseWriter, r *http.Request) { 85 85 user := s.OAuth.GetMultiAccountUser(r) 86 86 87 - claim, err := db.GetActiveDomainClaimForDid(s.Db, user.Active.Did) 87 + claim, err := db.GetActiveDomainClaimForDid(s.Db, user.Did) 88 88 if err != nil { 89 89 s.Logger.Error("failed to get domain claim", "err", err) 90 90 claim = nil ··· 93 93 // determine whether the active account has a tngl.sh handle, in which 94 94 // case their sites domain is automatically their handle domain. 95 95 isTnglHandle := func() bool { 96 - ident, err := s.IdResolver.ResolveIdent(r.Context(), user.Active.Did) 96 + ident, err := s.IdResolver.ResolveIdent(r.Context(), user.Did) 97 97 if err != nil { 98 98 return false 99 99 } ··· 164 164 } 165 165 166 166 isTnglHandle := func() bool { 167 - ident, err := s.IdResolver.ResolveIdent(r.Context(), user.Active.Did) 167 + ident, err := s.IdResolver.ResolveIdent(r.Context(), user.Did) 168 168 if err != nil { 169 169 return false 170 170 } ··· 175 175 return 176 176 } 177 177 178 - if err := db.ReleaseDomain(s.Db, user.Active.Did, domain); err != nil { 178 + if err := db.ReleaseDomain(s.Db, user.Did, domain); err != nil { 179 179 s.Logger.Error("releasing domain", "err", err) 180 180 s.Pages.Notice(w, "settings-sites-error", "Unable to release domain. Make sure it belongs to your account.") 181 181 return ··· 183 183 184 184 // Clean up all site data for this DID asynchronously. 185 185 if s.CfClient.Enabled() { 186 - siteConfigs, err := db.GetRepoSiteConfigsForDid(s.Db, user.Active.Did) 186 + siteConfigs, err := db.GetRepoSiteConfigsForDid(s.Db, user.Did) 187 187 if err != nil { 188 188 s.Logger.Error("releaseSitesDomain: fetching site configs for cleanup", "err", err) 189 189 } 190 190 191 - if err := db.DeleteRepoSiteConfigsForDid(s.Db, user.Active.Did); err != nil { 191 + if err := db.DeleteRepoSiteConfigsForDid(s.Db, user.Did); err != nil { 192 192 s.Logger.Error("releaseSitesDomain: deleting site configs from db", "err", err) 193 193 } 194 194 ··· 197 197 198 198 // Delete each repo's R2 objects. 199 199 for _, sc := range siteConfigs { 200 - if err := sites.Delete(ctx, s.CfClient, user.Active.Did, sc.RepoName); err != nil { 201 - s.Logger.Error("releaseSitesDomain: R2 delete failed", "did", user.Active.Did, "repo", sc.RepoName, "err", err) 200 + if err := sites.Delete(ctx, s.CfClient, user.Did, sc.RepoName); err != nil { 201 + s.Logger.Error("releaseSitesDomain: R2 delete failed", "did", user.Did, "repo", sc.RepoName, "err", err) 202 202 } 203 203 } 204 204 ··· 232 232 func (s *Settings) profileSettings(w http.ResponseWriter, r *http.Request) { 233 233 user := s.OAuth.GetMultiAccountUser(r) 234 234 235 - punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did()) 235 + punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did) 236 236 if err != nil { 237 237 log.Printf("failed to get users punchcard preferences: %s", err) 238 238 } ··· 289 289 290 290 func (s *Settings) keysSettings(w http.ResponseWriter, r *http.Request) { 291 291 user := s.OAuth.GetMultiAccountUser(r) 292 - pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Active.Did) 292 + pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Did) 293 293 if err != nil { 294 294 s.Logger.Error("keys settings", "err", err) 295 295 } ··· 302 302 303 303 func (s *Settings) emailsSettings(w http.ResponseWriter, r *http.Request) { 304 304 user := s.OAuth.GetMultiAccountUser(r) 305 - emails, err := db.GetAllEmails(s.Db, user.Active.Did) 305 + emails, err := db.GetAllEmails(s.Db, user.Did) 306 306 if err != nil { 307 307 s.Logger.Error("emails settings", "err", err) 308 308 }
+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
··· 271 271 } 272 272 273 273 l := s.logger.With("handler", "UpgradeBanner") 274 - l = l.With("did", user.Active.Did) 274 + l = l.With("did", user.Did) 275 275 276 276 regs, err := db.GetRegistrations( 277 277 s.db, 278 - orm.FilterEq("did", user.Active.Did), 278 + orm.FilterEq("did", user.Did), 279 279 orm.FilterEq("needs_upgrade", 1), 280 280 ) 281 281 if err != nil { ··· 284 284 285 285 spindles, err := db.GetSpindles( 286 286 s.db, 287 - orm.FilterEq("owner", user.Active.Did), 287 + orm.FilterEq("owner", user.Did), 288 288 orm.FilterEq("needs_upgrade", 1), 289 289 ) 290 290 if err != nil { ··· 374 374 switch r.Method { 375 375 case http.MethodGet: 376 376 user := s.oauth.GetMultiAccountUser(r) 377 - knots, err := s.enforcer.GetKnotsForUser(user.Active.Did) 377 + knots, err := s.enforcer.GetKnotsForUser(user.Did) 378 378 if err != nil { 379 379 s.pages.Notice(w, "repo", "Invalid user account.") 380 380 return ··· 389 389 l := s.logger.With("handler", "NewRepo") 390 390 391 391 user := s.oauth.GetMultiAccountUser(r) 392 - l = l.With("did", user.Active.Did) 392 + l = l.With("did", user.Did) 393 393 394 394 // form validation 395 395 domain := r.FormValue("domain") ··· 425 425 } 426 426 427 427 // ACL validation 428 - ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create") 428 + ok, err := s.enforcer.E.Enforce(user.Did, domain, domain, "repo:create") 429 429 if err != nil || !ok { 430 430 l.Info("unauthorized") 431 431 s.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") ··· 435 435 // Check for existing repos 436 436 existingRepo, err := db.GetRepo( 437 437 s.db, 438 - orm.FilterEq("did", user.Active.Did), 438 + orm.FilterEq("did", user.Did), 439 439 orm.FilterEq("name", repoName), 440 440 ) 441 441 if err == nil && existingRepo != nil { ··· 447 447 // create atproto record for this repo 448 448 rkey := tid.TID() 449 449 repo := &models.Repo{ 450 - Did: user.Active.Did, 450 + Did: user.Did, 451 451 Name: repoName, 452 452 Knot: domain, 453 453 Rkey: rkey, ··· 466 466 467 467 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 468 468 Collection: tangled.RepoNSID, 469 - Repo: user.Active.Did, 469 + Repo: user.Did, 470 470 Rkey: rkey, 471 471 Record: &lexutil.LexiconTypeDecoder{ 472 472 Val: &record, ··· 543 543 } 544 544 545 545 // acls 546 - p, _ := securejoin.SecureJoin(user.Active.Did, repoName) 547 - err = s.enforcer.AddRepo(user.Active.Did, domain, p) 546 + p, _ := securejoin.SecureJoin(user.Did, repoName) 547 + err = s.enforcer.AddRepo(user.Did, domain, p) 548 548 if err != nil { 549 549 l.Error("acl setup failed", "err", err) 550 550 s.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 569 569 aturi = "" 570 570 571 571 s.notifier.NewRepo(r.Context(), repo) 572 - s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, repoName)) 572 + s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, repoName)) 573 573 } 574 574 } 575 575
+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 {
+13 -13
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 ··· 415 415 416 416 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 417 417 Collection: tangled.StringNSID, 418 - Repo: user.Active.Did, 418 + Repo: user.Did, 419 419 Rkey: rkey, 420 420 }) 421 421 if err != nil { ··· 425 425 426 426 if err := db.DeleteString( 427 427 s.Db, 428 - orm.FilterEq("did", user.Active.Did), 428 + orm.FilterEq("did", user.Did), 429 429 orm.FilterEq("rkey", rkey), 430 430 ); err != nil { 431 431 fail("Failed to delete string.", err) 432 432 return 433 433 } 434 434 435 - s.Notifier.DeleteString(r.Context(), user.Active.Did, rkey) 435 + s.Notifier.DeleteString(r.Context(), user.Did, rkey) 436 436 437 - s.Pages.HxRedirect(w, "/strings/"+user.Active.Did) 437 + s.Pages.HxRedirect(w, "/strings/"+user.Did) 438 438 } 439 439 440 440 func (s *Strings) comment(w http.ResponseWriter, r *http.Request) {