Monorepo for Tangled tangled.org

appview: remove oauth.User type #1027

open opened by boltless.me targeting master from sl/uvpzuszrulvq

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

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

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mdcq5ouzmj22
+242 -256
Diff #8
+19 -19
appview/issues/issues.go
··· 106 106 107 107 userReactions := map[models.ReactionKind]bool{} 108 108 if user != nil { 109 - userReactions = db.GetReactionStatusMap(rp.db, user.Active.Did, issue.AtUri()) 109 + userReactions = db.GetReactionStatusMap(rp.db, user.Did, issue.AtUri()) 110 110 } 111 111 112 112 backlinks, err := db.GetBacklinks(rp.db, issue.AtUri()) ··· 185 185 return 186 186 } 187 187 188 - ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueNSID, user.Active.Did, newIssue.Rkey) 188 + ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueNSID, user.Did, newIssue.Rkey) 189 189 if err != nil { 190 190 l.Error("failed to get record", "err", err) 191 191 rp.pages.Notice(w, noticeId, "Failed to edit issue, no record found on PDS.") ··· 194 194 195 195 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 196 196 Collection: tangled.RepoIssueNSID, 197 - Repo: user.Active.Did, 197 + Repo: user.Did, 198 198 Rkey: newIssue.Rkey, 199 199 SwapRecord: ex.Cid, 200 200 Record: &lexutil.LexiconTypeDecoder{ ··· 309 309 return 310 310 } 311 311 312 - roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 312 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 313 313 isRepoOwner := roles.IsOwner() 314 314 isCollaborator := roles.IsCollaborator() 315 - isIssueOwner := user.Active.Did == issue.Did 315 + isIssueOwner := user.Did == issue.Did 316 316 317 317 // TODO: make this more granular 318 318 if isIssueOwner || isRepoOwner || isCollaborator { ··· 329 329 issue.Open = false 330 330 331 331 // notify about the issue closure 332 - rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Active.Did), issue) 332 + rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 333 333 334 334 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) 335 335 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) ··· 357 357 return 358 358 } 359 359 360 - roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 360 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 361 361 isRepoOwner := roles.IsOwner() 362 362 isCollaborator := roles.IsCollaborator() 363 - isIssueOwner := user.Active.Did == issue.Did 363 + isIssueOwner := user.Did == issue.Did 364 364 365 365 if isCollaborator || isRepoOwner || isIssueOwner { 366 366 err := db.ReopenIssues( ··· 376 376 issue.Open = true 377 377 378 378 // notify about the issue reopen 379 - rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Active.Did), issue) 379 + rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue) 380 380 381 381 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) 382 382 rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", ownerSlashRepo, issue.IssueId)) ··· 419 419 mentions, references := rp.mentionsResolver.Resolve(r.Context(), body) 420 420 421 421 comment := models.IssueComment{ 422 - Did: user.Active.Did, 422 + Did: user.Did, 423 423 Rkey: tid.TID(), 424 424 IssueAt: issue.AtUri().String(), 425 425 ReplyTo: replyTo, ··· 560 560 } 561 561 comment := comments[0] 562 562 563 - if comment.Did != user.Active.Did { 564 - l.Error("unauthorized comment edit", "expectedDid", comment.Did, "gotDid", user.Active.Did) 563 + if comment.Did != user.Did { 564 + l.Error("unauthorized comment edit", "expectedDid", comment.Did, "gotDid", user.Did) 565 565 http.Error(w, "you are not the author of this comment", http.StatusUnauthorized) 566 566 return 567 567 } ··· 611 611 // rkey is optional, it was introduced later 612 612 if newComment.Rkey != "" { 613 613 // update the record on pds 614 - ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueCommentNSID, user.Active.Did, comment.Rkey) 614 + ex, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.RepoIssueCommentNSID, user.Did, comment.Rkey) 615 615 if err != nil { 616 616 l.Error("failed to get record", "err", err, "did", newComment.Did, "rkey", newComment.Rkey) 617 617 rp.pages.Notice(w, fmt.Sprintf("comment-%s-status", commentId), "Failed to update description, no record found on PDS.") ··· 620 620 621 621 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 622 622 Collection: tangled.RepoIssueCommentNSID, 623 - Repo: user.Active.Did, 623 + Repo: user.Did, 624 624 Rkey: newComment.Rkey, 625 625 SwapRecord: ex.Cid, 626 626 Record: &lexutil.LexiconTypeDecoder{ ··· 742 742 } 743 743 comment := comments[0] 744 744 745 - if comment.Did != user.Active.Did { 746 - l.Error("unauthorized action", "expectedDid", comment.Did, "gotDid", user.Active.Did) 745 + if comment.Did != user.Did { 746 + l.Error("unauthorized action", "expectedDid", comment.Did, "gotDid", user.Did) 747 747 http.Error(w, "you are not the author of this comment", http.StatusUnauthorized) 748 748 return 749 749 } ··· 772 772 } 773 773 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 774 774 Collection: tangled.RepoIssueCommentNSID, 775 - Repo: user.Active.Did, 775 + Repo: user.Did, 776 776 Rkey: comment.Rkey, 777 777 }) 778 778 if err != nil { ··· 1018 1018 Title: r.FormValue("title"), 1019 1019 Body: body, 1020 1020 Open: true, 1021 - Did: user.Active.Did, 1021 + Did: user.Did, 1022 1022 Created: time.Now(), 1023 1023 Mentions: mentions, 1024 1024 References: references, ··· 1042 1042 } 1043 1043 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 1044 1044 Collection: tangled.RepoIssueNSID, 1045 - Repo: user.Active.Did, 1045 + Repo: user.Did, 1046 1046 Rkey: issue.Rkey, 1047 1047 Record: &lexutil.LexiconTypeDecoder{ 1048 1048 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 { ··· 157 157 return 158 158 } 159 159 l = l.With("domain", domain) 160 - l = l.With("user", user.Active.Did) 160 + l = l.With("user", user.Did) 161 161 162 162 tx, err := k.Db.Begin() 163 163 if err != nil { ··· 170 170 k.Enforcer.E.LoadPolicy() 171 171 }() 172 172 173 - err = db.AddKnot(tx, domain, user.Active.Did) 173 + err = db.AddKnot(tx, domain, user.Did) 174 174 if err != nil { 175 175 l.Error("failed to insert", "err", err) 176 176 fail() ··· 192 192 return 193 193 } 194 194 195 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Active.Did, domain) 195 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Did, domain) 196 196 var exCid *string 197 197 if ex != nil { 198 198 exCid = ex.Cid ··· 201 201 // re-announce by registering under same rkey 202 202 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 203 203 Collection: tangled.KnotNSID, 204 - Repo: user.Active.Did, 204 + Repo: user.Did, 205 205 Rkey: domain, 206 206 Record: &lexutil.LexiconTypeDecoder{ 207 207 Val: &tangled.Knot{ ··· 232 232 } 233 233 234 234 // begin verification 235 - err = serververify.RunVerification(r.Context(), domain, user.Active.Did, k.Config.Core.Dev) 235 + err = serververify.RunVerification(r.Context(), domain, user.Did, k.Config.Core.Dev) 236 236 if err != nil { 237 237 l.Error("verification failed", "err", err) 238 238 k.Pages.HxRefresh(w) 239 239 return 240 240 } 241 241 242 - err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Active.Did) 242 + err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Did) 243 243 if err != nil { 244 244 l.Error("failed to mark verified", "err", err) 245 245 k.Pages.HxRefresh(w) ··· 276 276 // get record from db first 277 277 registrations, err := db.GetRegistrations( 278 278 k.Db, 279 - orm.FilterEq("did", user.Active.Did), 279 + orm.FilterEq("did", user.Did), 280 280 orm.FilterEq("domain", domain), 281 281 ) 282 282 if err != nil { ··· 304 304 305 305 err = db.DeleteKnot( 306 306 tx, 307 - orm.FilterEq("did", user.Active.Did), 307 + orm.FilterEq("did", user.Did), 308 308 orm.FilterEq("domain", domain), 309 309 ) 310 310 if err != nil { ··· 332 332 333 333 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 334 334 Collection: tangled.KnotNSID, 335 - Repo: user.Active.Did, 335 + Repo: user.Did, 336 336 Rkey: domain, 337 337 }) 338 338 if err != nil { ··· 380 380 return 381 381 } 382 382 l = l.With("domain", domain) 383 - l = l.With("user", user.Active.Did) 383 + l = l.With("user", user.Did) 384 384 385 385 // get record from db first 386 386 registrations, err := db.GetRegistrations( 387 387 k.Db, 388 - orm.FilterEq("did", user.Active.Did), 388 + orm.FilterEq("did", user.Did), 389 389 orm.FilterEq("domain", domain), 390 390 ) 391 391 if err != nil { ··· 401 401 registration := registrations[0] 402 402 403 403 // begin verification 404 - err = serververify.RunVerification(r.Context(), domain, user.Active.Did, k.Config.Core.Dev) 404 + err = serververify.RunVerification(r.Context(), domain, user.Did, k.Config.Core.Dev) 405 405 if err != nil { 406 406 l.Error("verification failed", "err", err) 407 407 ··· 419 419 return 420 420 } 421 421 422 - err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Active.Did) 422 + err = serververify.MarkKnotVerified(k.Db, k.Enforcer, domain, user.Did) 423 423 if err != nil { 424 424 l.Error("failed to mark verified", "err", err) 425 425 k.Pages.Notice(w, noticeId, err.Error()) ··· 438 438 return 439 439 } 440 440 441 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Active.Did, domain) 441 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.KnotNSID, user.Did, domain) 442 442 var exCid *string 443 443 if ex != nil { 444 444 exCid = ex.Cid ··· 447 447 // ignore the error here 448 448 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 449 449 Collection: tangled.KnotNSID, 450 - Repo: user.Active.Did, 450 + Repo: user.Did, 451 451 Rkey: domain, 452 452 Record: &lexutil.LexiconTypeDecoder{ 453 453 Val: &tangled.Knot{ ··· 476 476 // Get updated registration to show 477 477 registrations, err = db.GetRegistrations( 478 478 k.Db, 479 - orm.FilterEq("did", user.Active.Did), 479 + orm.FilterEq("did", user.Did), 480 480 orm.FilterEq("domain", domain), 481 481 ) 482 482 if err != nil { ··· 508 508 return 509 509 } 510 510 l = l.With("domain", domain) 511 - l = l.With("user", user.Active.Did) 511 + l = l.With("user", user.Did) 512 512 513 513 registrations, err := db.GetRegistrations( 514 514 k.Db, 515 - orm.FilterEq("did", user.Active.Did), 515 + orm.FilterEq("did", user.Did), 516 516 orm.FilterEq("domain", domain), 517 517 orm.FilterIsNot("registered", "null"), 518 518 ) ··· 565 565 566 566 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 567 567 Collection: tangled.KnotMemberNSID, 568 - Repo: user.Active.Did, 568 + Repo: user.Did, 569 569 Rkey: rkey, 570 570 Record: &lexutil.LexiconTypeDecoder{ 571 571 Val: &tangled.KnotMember{ ··· 616 616 return 617 617 } 618 618 l = l.With("domain", domain) 619 - l = l.With("user", user.Active.Did) 619 + l = l.With("user", user.Did) 620 620 621 621 registrations, err := db.GetRegistrations( 622 622 k.Db, 623 - orm.FilterEq("did", user.Active.Did), 623 + orm.FilterEq("did", user.Did), 624 624 orm.FilterEq("domain", domain), 625 625 orm.FilterIsNot("registered", "null"), 626 626 )
+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 27 } 28 28 29 - func (m *MultiAccountUser) Did() string { 30 - return m.Active.Did 31 - } 32 - 33 29 func (o *OAuth) GetAccounts(r *http.Request) *AccountRegistry { 34 30 session, err := o.SessStore.Get(r, AccountsName) 35 31 if err != nil || session.IsNew { ··· 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
··· 237 237 return o.saveAccounts(w, r, registry) 238 238 } 239 239 240 - type User struct { 241 - Did string 242 - } 243 - 244 240 func (o *OAuth) GetDid(r *http.Request) string { 245 241 if u := o.GetMultiAccountUser(r); u != nil { 246 - return u.Did() 242 + return u.Did 247 243 } 248 244 249 245 return ""
+22 -22
appview/pulls/pulls.go
··· 135 135 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 136 136 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 137 137 resubmitResult := pages.Unknown 138 - if user.Active.Did == pull.OwnerDid { 138 + if user.Did == pull.OwnerDid { 139 139 resubmitResult = s.resubmitCheck(r, f, pull, stack) 140 140 } 141 141 ··· 198 198 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 199 199 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 200 200 resubmitResult := pages.Unknown 201 - if user != nil && user.Active.Did == pull.OwnerDid { 201 + if user != nil && user.Did == pull.OwnerDid { 202 202 resubmitResult = s.resubmitCheck(r, f, pull, stack) 203 203 } 204 204 ··· 239 239 240 240 userReactions := map[models.ReactionKind]bool{} 241 241 if user != nil { 242 - userReactions = db.GetReactionStatusMap(s.db, user.Active.Did, pull.AtUri()) 242 + userReactions = db.GetReactionStatusMap(s.db, user.Did, pull.AtUri()) 243 243 } 244 244 245 245 labelDefs, err := db.GetLabelDefinitions( ··· 409 409 } 410 410 411 411 // user can only delete branch if they are a collaborator in the repo that the branch belongs to 412 - perms := s.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.DidSlashRepo()) 412 + perms := s.enforcer.GetPermissionsInRepo(user.Did, repo.Knot, repo.DidSlashRepo()) 413 413 if !slices.Contains(perms, "repo:push") { 414 414 return nil 415 415 } ··· 819 819 } 820 820 atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 821 821 Collection: tangled.RepoPullCommentNSID, 822 - Repo: user.Active.Did, 822 + Repo: user.Did, 823 823 Rkey: tid.TID(), 824 824 Record: &lexutil.LexiconTypeDecoder{ 825 825 Val: &tangled.RepoPullComment{ ··· 836 836 } 837 837 838 838 comment := &models.PullComment{ 839 - OwnerDid: user.Active.Did, 839 + OwnerDid: user.Did, 840 840 RepoAt: f.RepoAt().String(), 841 841 PullId: pull.PullId, 842 842 Body: body, ··· 923 923 fromFork := r.FormValue("fork") 924 924 sourceBranch := r.FormValue("sourceBranch") 925 925 patch := r.FormValue("patch") 926 - userDid := syntax.DID(user.Active.Did) 926 + userDid := syntax.DID(user.Did) 927 927 928 928 if targetBranch == "" { 929 929 s.pages.Notice(w, "pull", "Target branch is required.") ··· 1541 1541 func (s *Pulls) CompareForksFragment(w http.ResponseWriter, r *http.Request) { 1542 1542 user := s.oauth.GetMultiAccountUser(r) 1543 1543 1544 - forks, err := db.GetForksByDid(s.db, user.Active.Did) 1544 + forks, err := db.GetForksByDid(s.db, user.Did) 1545 1545 if err != nil { 1546 1546 log.Println("failed to get forks", err) 1547 1547 return ··· 1670 1670 return 1671 1671 } 1672 1672 1673 - if user == nil || user.Active.Did != pull.OwnerDid { 1673 + if user == nil || user.Did != pull.OwnerDid { 1674 1674 log.Println("unauthorized user") 1675 1675 w.WriteHeader(http.StatusUnauthorized) 1676 1676 return ··· 1684 1684 1685 1685 patch := r.FormValue("patch") 1686 1686 1687 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, "", "") 1687 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, "", "") 1688 1688 } 1689 1689 1690 1690 func (s *Pulls) resubmitBranch(w http.ResponseWriter, r *http.Request) { ··· 1697 1697 return 1698 1698 } 1699 1699 1700 - if user == nil || user.Active.Did != pull.OwnerDid { 1700 + if user == nil || user.Did != pull.OwnerDid { 1701 1701 log.Println("unauthorized user") 1702 1702 w.WriteHeader(http.StatusUnauthorized) 1703 1703 return ··· 1709 1709 return 1710 1710 } 1711 1711 1712 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 1712 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 1713 1713 if !roles.IsPushAllowed() { 1714 1714 log.Println("unauthorized user") 1715 1715 w.WriteHeader(http.StatusUnauthorized) ··· 1749 1749 patch := comparison.FormatPatchRaw 1750 1750 combined := comparison.CombinedPatchRaw 1751 1751 1752 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1752 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1753 1753 } 1754 1754 1755 1755 func (s *Pulls) resubmitFork(w http.ResponseWriter, r *http.Request) { ··· 1762 1762 return 1763 1763 } 1764 1764 1765 - if user == nil || user.Active.Did != pull.OwnerDid { 1765 + if user == nil || user.Did != pull.OwnerDid { 1766 1766 log.Println("unauthorized user") 1767 1767 w.WriteHeader(http.StatusUnauthorized) 1768 1768 return ··· 1846 1846 patch := comparison.FormatPatchRaw 1847 1847 combined := comparison.CombinedPatchRaw 1848 1848 1849 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1849 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1850 1850 } 1851 1851 1852 1852 func (s *Pulls) resubmitPullHelper( ··· 2274 2274 2275 2275 // notify about the pull merge 2276 2276 for _, p := range pullsToMerge { 2277 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2277 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2278 2278 } 2279 2279 2280 2280 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2298 2298 } 2299 2299 2300 2300 // auth filter: only owner or collaborators can close 2301 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 2301 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 2302 2302 isOwner := roles.IsOwner() 2303 2303 isCollaborator := roles.IsCollaborator() 2304 - isPullAuthor := user.Active.Did == pull.OwnerDid 2304 + isPullAuthor := user.Did == pull.OwnerDid 2305 2305 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2306 2306 if !isCloseAllowed { 2307 2307 log.Println("failed to close pull") ··· 2347 2347 } 2348 2348 2349 2349 for _, p := range pullsToClose { 2350 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2350 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2351 2351 } 2352 2352 2353 2353 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2372 2372 } 2373 2373 2374 2374 // auth filter: only owner or collaborators can close 2375 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.DidSlashRepo())} 2375 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.DidSlashRepo())} 2376 2376 isOwner := roles.IsOwner() 2377 2377 isCollaborator := roles.IsCollaborator() 2378 - isPullAuthor := user.Active.Did == pull.OwnerDid 2378 + isPullAuthor := user.Did == pull.OwnerDid 2379 2379 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2380 2380 if !isCloseAllowed { 2381 2381 log.Println("failed to close pull") ··· 2421 2421 } 2422 2422 2423 2423 for _, p := range pullsToReopen { 2424 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2424 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2425 2425 } 2426 2426 2427 2427 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
··· 92 92 func (rp *Repo) EditSpindle(w http.ResponseWriter, r *http.Request) { 93 93 user := rp.oauth.GetMultiAccountUser(r) 94 94 l := rp.logger.With("handler", "EditSpindle") 95 - l = l.With("did", user.Active.Did) 95 + l = l.With("did", user.Did) 96 96 97 97 errorId := "operation-error" 98 98 fail := func(msg string, err error) { ··· 116 116 117 117 if !removingSpindle { 118 118 // ensure that this is a valid spindle for this user 119 - validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Active.Did) 119 + validSpindles, err := rp.enforcer.GetSpindlesForUser(user.Did) 120 120 if err != nil { 121 121 fail("Failed to find spindles. Try again later.", err) 122 122 return ··· 179 179 func (rp *Repo) AddLabelDef(w http.ResponseWriter, r *http.Request) { 180 180 user := rp.oauth.GetMultiAccountUser(r) 181 181 l := rp.logger.With("handler", "AddLabel") 182 - l = l.With("did", user.Active.Did) 182 + l = l.With("did", user.Did) 183 183 184 184 f, err := rp.repoResolver.Resolve(r) 185 185 if err != nil { ··· 225 225 } 226 226 227 227 label := models.LabelDefinition{ 228 - Did: user.Active.Did, 228 + Did: user.Did, 229 229 Rkey: tid.TID(), 230 230 Name: name, 231 231 ValueType: valueType, ··· 338 338 func (rp *Repo) DeleteLabelDef(w http.ResponseWriter, r *http.Request) { 339 339 user := rp.oauth.GetMultiAccountUser(r) 340 340 l := rp.logger.With("handler", "DeleteLabel") 341 - l = l.With("did", user.Active.Did) 341 + l = l.With("did", user.Did) 342 342 343 343 f, err := rp.repoResolver.Resolve(r) 344 344 if err != nil { ··· 446 446 func (rp *Repo) SubscribeLabel(w http.ResponseWriter, r *http.Request) { 447 447 user := rp.oauth.GetMultiAccountUser(r) 448 448 l := rp.logger.With("handler", "SubscribeLabel") 449 - l = l.With("did", user.Active.Did) 449 + l = l.With("did", user.Did) 450 450 451 451 f, err := rp.repoResolver.Resolve(r) 452 452 if err != nil { ··· 532 532 func (rp *Repo) UnsubscribeLabel(w http.ResponseWriter, r *http.Request) { 533 533 user := rp.oauth.GetMultiAccountUser(r) 534 534 l := rp.logger.With("handler", "UnsubscribeLabel") 535 - l = l.With("did", user.Active.Did) 535 + l = l.With("did", user.Did) 536 536 537 537 f, err := rp.repoResolver.Resolve(r) 538 538 if err != nil { ··· 703 703 func (rp *Repo) AddCollaborator(w http.ResponseWriter, r *http.Request) { 704 704 user := rp.oauth.GetMultiAccountUser(r) 705 705 l := rp.logger.With("handler", "AddCollaborator") 706 - l = l.With("did", user.Active.Did) 706 + l = l.With("did", user.Did) 707 707 708 708 f, err := rp.repoResolver.Resolve(r) 709 709 if err != nil { ··· 732 732 return 733 733 } 734 734 735 - if collaboratorIdent.DID.String() == user.Active.Did { 735 + if collaboratorIdent.DID.String() == user.Did { 736 736 fail("You seem to be adding yourself as a collaborator.", nil) 737 737 return 738 738 } ··· 752 752 createdAt := time.Now() 753 753 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 754 754 Collection: tangled.RepoCollaboratorNSID, 755 - Repo: currentUser.Active.Did, 755 + Repo: currentUser.Did, 756 756 Rkey: rkey, 757 757 Record: &lexutil.LexiconTypeDecoder{ 758 758 Val: &tangled.RepoCollaborator{ ··· 801 801 } 802 802 803 803 err = db.AddCollaborator(tx, models.Collaborator{ 804 - Did: syntax.DID(currentUser.Active.Did), 804 + Did: syntax.DID(currentUser.Did), 805 805 Rkey: rkey, 806 806 SubjectDid: collaboratorIdent.DID, 807 807 RepoAt: f.RepoAt(), ··· 849 849 } 850 850 _, err = comatproto.RepoDeleteRecord(r.Context(), atpClient, &comatproto.RepoDeleteRecord_Input{ 851 851 Collection: tangled.RepoNSID, 852 - Repo: user.Active.Did, 852 + Repo: user.Did, 853 853 Rkey: f.Rkey, 854 854 }) 855 855 if err != nil { ··· 978 978 r.Context(), 979 979 client, 980 980 &tangled.RepoForkSync_Input{ 981 - Did: user.Active.Did, 981 + Did: user.Did, 982 982 Name: f.Name, 983 983 Source: f.Source, 984 984 Branch: ref, ··· 1007 1007 switch r.Method { 1008 1008 case http.MethodGet: 1009 1009 user := rp.oauth.GetMultiAccountUser(r) 1010 - knots, err := rp.enforcer.GetKnotsForUser(user.Active.Did) 1010 + knots, err := rp.enforcer.GetKnotsForUser(user.Did) 1011 1011 if err != nil { 1012 1012 rp.pages.Notice(w, "repo", "Invalid user account.") 1013 1013 return ··· 1029 1029 } 1030 1030 l = l.With("targetKnot", targetKnot) 1031 1031 1032 - ok, err := rp.enforcer.E.Enforce(user.Active.Did, targetKnot, targetKnot, "repo:create") 1032 + ok, err := rp.enforcer.E.Enforce(user.Did, targetKnot, targetKnot, "repo:create") 1033 1033 if err != nil || !ok { 1034 1034 rp.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") 1035 1035 return ··· 1046 1046 // in the user's account. 1047 1047 existingRepo, err := db.GetRepo( 1048 1048 rp.db, 1049 - orm.FilterEq("did", user.Active.Did), 1049 + orm.FilterEq("did", user.Did), 1050 1050 orm.FilterEq("name", forkName), 1051 1051 ) 1052 1052 if err != nil { ··· 1075 1075 // create an atproto record for this fork 1076 1076 rkey := tid.TID() 1077 1077 repo := &models.Repo{ 1078 - Did: user.Active.Did, 1078 + Did: user.Did, 1079 1079 Name: forkName, 1080 1080 Knot: targetKnot, 1081 1081 Rkey: rkey, ··· 1095 1095 1096 1096 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 1097 1097 Collection: tangled.RepoNSID, 1098 - Repo: user.Active.Did, 1098 + Repo: user.Did, 1099 1099 Rkey: rkey, 1100 1100 Record: &lexutil.LexiconTypeDecoder{ 1101 1101 Val: &record, ··· 1174 1174 } 1175 1175 1176 1176 // acls 1177 - p, _ := securejoin.SecureJoin(user.Active.Did, forkName) 1178 - err = rp.enforcer.AddRepo(user.Active.Did, targetKnot, p) 1177 + p, _ := securejoin.SecureJoin(user.Did, forkName) 1178 + err = rp.enforcer.AddRepo(user.Did, targetKnot, p) 1179 1179 if err != nil { 1180 1180 l.Error("failed to add ACLs", "err", err) 1181 1181 rp.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 1200 1200 aturi = "" 1201 1201 1202 1202 rp.notifier.NewRepo(r.Context(), repo) 1203 - rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, forkName)) 1203 + rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, forkName)) 1204 1204 } 1205 1205 } 1206 1206
+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
+6 -6
appview/settings/danger.go
··· 59 59 60 60 func (s *Settings) requestPasswordReset(w http.ResponseWriter, r *http.Request) { 61 61 user := s.OAuth.GetMultiAccountUser(r) 62 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 62 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 63 63 s.Pages.Notice(w, "password-error", "Only available for tngl.sh accounts.") 64 64 return 65 65 } ··· 100 100 101 101 func (s *Settings) resetPassword(w http.ResponseWriter, r *http.Request) { 102 102 user := s.OAuth.GetMultiAccountUser(r) 103 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 103 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 104 104 s.Pages.Notice(w, "password-error", "Only available for tngl.sh accounts.") 105 105 return 106 106 } ··· 134 134 135 135 func (s *Settings) deactivateAccount(w http.ResponseWriter, r *http.Request) { 136 136 user := s.OAuth.GetMultiAccountUser(r) 137 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 137 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 138 138 s.Pages.Notice(w, "deactivate-error", "Only available for tngl.sh accounts.") 139 139 return 140 140 } ··· 172 172 173 173 func (s *Settings) requestAccountDelete(w http.ResponseWriter, r *http.Request) { 174 174 user := s.OAuth.GetMultiAccountUser(r) 175 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 175 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 176 176 s.Pages.Notice(w, "delete-error", "Only available for tngl.sh accounts.") 177 177 return 178 178 } ··· 204 204 205 205 func (s *Settings) deleteAccount(w http.ResponseWriter, r *http.Request) { 206 206 user := s.OAuth.GetMultiAccountUser(r) 207 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 207 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 208 208 s.Pages.Notice(w, "delete-error", "Only available for tngl.sh accounts.") 209 209 return 210 210 } ··· 269 269 270 270 func (s *Settings) reactivateAccount(w http.ResponseWriter, r *http.Request) { 271 271 user := s.OAuth.GetMultiAccountUser(r) 272 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 272 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 273 273 s.Pages.Notice(w, "reactivate-error", "Only available for tngl.sh accounts.") 274 274 return 275 275 }
+17 -17
appview/settings/settings.go
··· 115 115 func (s *Settings) sitesSettings(w http.ResponseWriter, r *http.Request) { 116 116 user := s.OAuth.GetMultiAccountUser(r) 117 117 118 - claim, err := db.GetActiveDomainClaimForDid(s.Db, user.Active.Did) 118 + claim, err := db.GetActiveDomainClaimForDid(s.Db, user.Did) 119 119 if err != nil { 120 120 s.Logger.Error("failed to get domain claim", "err", err) 121 121 claim = nil ··· 123 123 124 124 // determine whether the active account has a tngl.sh handle, in which 125 125 // case their sites domain is automatically their handle domain. 126 - isTnglHandle, _ := s.isTnglHandle(r.Context(), syntax.DID(user.Active.Did)) 126 + isTnglHandle, _ := s.isTnglHandle(r.Context(), syntax.DID(user.Did)) 127 127 128 128 s.Pages.UserSiteSettings(w, pages.UserSiteSettingsParams{ 129 129 LoggedInUser: user, ··· 193 193 return 194 194 } 195 195 196 - isTnglHandle, err := s.isTnglHandle(r.Context(), syntax.DID(user.Active.Did)) 196 + isTnglHandle, err := s.isTnglHandle(r.Context(), syntax.DID(user.Did)) 197 197 if err != nil { 198 198 s.Pages.Notice(w, "settings-sites-error", "Unable to resolve user identity") 199 199 return ··· 203 203 return 204 204 } 205 205 206 - if err := db.ReleaseDomain(s.Db, user.Active.Did, domain); err != nil { 206 + if err := db.ReleaseDomain(s.Db, user.Did, domain); err != nil { 207 207 s.Logger.Error("releasing domain", "err", err) 208 208 s.Pages.Notice(w, "settings-sites-error", "Unable to release domain. Make sure it belongs to your account.") 209 209 return ··· 211 211 212 212 // Clean up all site data for this DID asynchronously. 213 213 if s.CfClient.Enabled() { 214 - siteConfigs, err := db.GetRepoSiteConfigsForDid(s.Db, user.Active.Did) 214 + siteConfigs, err := db.GetRepoSiteConfigsForDid(s.Db, user.Did) 215 215 if err != nil { 216 216 s.Logger.Error("releaseSitesDomain: fetching site configs for cleanup", "err", err) 217 217 } 218 218 219 - if err := db.DeleteRepoSiteConfigsForDid(s.Db, user.Active.Did); err != nil { 219 + if err := db.DeleteRepoSiteConfigsForDid(s.Db, user.Did); err != nil { 220 220 s.Logger.Error("releaseSitesDomain: deleting site configs from db", "err", err) 221 221 } 222 222 ··· 225 225 226 226 // Delete each repo's R2 objects. 227 227 for _, sc := range siteConfigs { 228 - if err := sites.Delete(ctx, s.CfClient, user.Active.Did, sc.RepoName); err != nil { 229 - s.Logger.Error("releaseSitesDomain: R2 delete failed", "did", user.Active.Did, "repo", sc.RepoName, "err", err) 228 + if err := sites.Delete(ctx, s.CfClient, user.Did, sc.RepoName); err != nil { 229 + s.Logger.Error("releaseSitesDomain: R2 delete failed", "did", user.Did, "repo", sc.RepoName, "err", err) 230 230 } 231 231 } 232 232 ··· 260 260 func (s *Settings) profileSettings(w http.ResponseWriter, r *http.Request) { 261 261 user := s.OAuth.GetMultiAccountUser(r) 262 262 263 - punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did()) 263 + punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did) 264 264 if err != nil { 265 265 log.Printf("failed to get users punchcard preferences: %s", err) 266 266 } 267 267 268 - isTnglSh, err := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)) 268 + isTnglSh, err := s.isTnglShUser(r.Context(), syntax.DID(user.Did)) 269 269 270 270 // TODO: bring the user state from DB instead of PDS request 271 - isDeactivated := s.isAccountDeactivated(r.Context(), syntax.DID(user.Active.Did)) 271 + isDeactivated := s.isAccountDeactivated(r.Context(), syntax.DID(user.Did)) 272 272 273 273 s.Pages.UserProfileSettings(w, pages.UserProfileSettingsParams{ 274 274 LoggedInUser: user, ··· 325 325 326 326 func (s *Settings) keysSettings(w http.ResponseWriter, r *http.Request) { 327 327 user := s.OAuth.GetMultiAccountUser(r) 328 - pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Active.Did) 328 + pubKeys, err := db.GetPublicKeysForDid(s.Db, user.Did) 329 329 if err != nil { 330 330 s.Logger.Error("keys settings", "err", err) 331 331 } ··· 338 338 339 339 func (s *Settings) emailsSettings(w http.ResponseWriter, r *http.Request) { 340 340 user := s.OAuth.GetMultiAccountUser(r) 341 - emails, err := db.GetAllEmails(s.Db, user.Active.Did) 341 + emails, err := db.GetAllEmails(s.Db, user.Did) 342 342 if err != nil { 343 343 s.Logger.Error("emails settings", "err", err) 344 344 } ··· 733 733 734 734 func (s *Settings) elevateForHandle(w http.ResponseWriter, r *http.Request) { 735 735 user := s.OAuth.GetMultiAccountUser(r) 736 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 736 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 737 737 http.Redirect(w, r, "/settings/profile", http.StatusSeeOther) 738 738 return 739 739 } ··· 746 746 747 747 redirectURL, err := s.OAuth.StartElevatedAuthFlow( 748 748 r.Context(), w, r, 749 - user.Did(), 749 + user.Did, 750 750 []string{"identity:handle"}, 751 751 "/settings/profile?handle=1", 752 752 ) ··· 761 761 762 762 func (s *Settings) updateHandle(w http.ResponseWriter, r *http.Request) { 763 763 user := s.OAuth.GetMultiAccountUser(r) 764 - if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Active.Did)); !isTngl { 764 + if isTngl, _ := s.isTnglShUser(r.Context(), syntax.DID(user.Did)); !isTngl { 765 765 s.Pages.Notice(w, "handle-error", "Handle changes are only available for tngl.sh accounts.") 766 766 return 767 767 } ··· 803 803 if strings.Contains(err.Error(), "ScopeMissing") || strings.Contains(err.Error(), "insufficient_scope") { 804 804 redirectURL, elevErr := s.OAuth.StartElevatedAuthFlow( 805 805 r.Context(), w, r, 806 - user.Did(), 806 + user.Did, 807 807 []string{"identity:handle"}, 808 808 "/settings/profile?handle=1", 809 809 )
+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 { ··· 160 160 return 161 161 } 162 162 l = l.With("instance", instance) 163 - l = l.With("user", user.Active.Did) 163 + l = l.With("user", user.Did) 164 164 165 165 tx, err := s.Db.Begin() 166 166 if err != nil { ··· 174 174 }() 175 175 176 176 err = db.AddSpindle(tx, models.Spindle{ 177 - Owner: syntax.DID(user.Active.Did), 177 + Owner: syntax.DID(user.Did), 178 178 Instance: instance, 179 179 }) 180 180 if err != nil { ··· 198 198 return 199 199 } 200 200 201 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Active.Did, instance) 201 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Did, instance) 202 202 var exCid *string 203 203 if ex != nil { 204 204 exCid = ex.Cid ··· 207 207 // re-announce by registering under same rkey 208 208 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 209 209 Collection: tangled.SpindleNSID, 210 - Repo: user.Active.Did, 210 + Repo: user.Did, 211 211 Rkey: instance, 212 212 Record: &lexutil.LexiconTypeDecoder{ 213 213 Val: &tangled.Spindle{ ··· 238 238 } 239 239 240 240 // begin verification 241 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 241 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 242 242 if err != nil { 243 243 l.Error("verification failed", "err", err) 244 244 s.Pages.HxRefresh(w) 245 245 return 246 246 } 247 247 248 - _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 248 + _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 249 249 if err != nil { 250 250 l.Error("failed to mark verified", "err", err) 251 251 s.Pages.HxRefresh(w) ··· 275 275 276 276 spindles, err := db.GetSpindles( 277 277 s.Db, 278 - orm.FilterEq("owner", user.Active.Did), 278 + orm.FilterEq("owner", user.Did), 279 279 orm.FilterEq("instance", instance), 280 280 ) 281 281 if err != nil || len(spindles) != 1 { ··· 284 284 return 285 285 } 286 286 287 - if string(spindles[0].Owner) != user.Active.Did { 288 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 287 + if string(spindles[0].Owner) != user.Did { 288 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 289 289 s.Pages.Notice(w, noticeId, "Failed to delete spindle, unauthorized deletion attempt.") 290 290 return 291 291 } ··· 304 304 // remove spindle members first 305 305 err = db.RemoveSpindleMember( 306 306 tx, 307 - orm.FilterEq("did", user.Active.Did), 307 + orm.FilterEq("did", user.Did), 308 308 orm.FilterEq("instance", instance), 309 309 ) 310 310 if err != nil { ··· 315 315 316 316 err = db.DeleteSpindle( 317 317 tx, 318 - orm.FilterEq("owner", user.Active.Did), 318 + orm.FilterEq("owner", user.Did), 319 319 orm.FilterEq("instance", instance), 320 320 ) 321 321 if err != nil { ··· 343 343 344 344 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 345 345 Collection: tangled.SpindleNSID, 346 - Repo: user.Active.Did, 346 + Repo: user.Did, 347 347 Rkey: instance, 348 348 }) 349 349 if err != nil { ··· 391 391 return 392 392 } 393 393 l = l.With("instance", instance) 394 - l = l.With("user", user.Active.Did) 394 + l = l.With("user", user.Did) 395 395 396 396 spindles, err := db.GetSpindles( 397 397 s.Db, 398 - orm.FilterEq("owner", user.Active.Did), 398 + orm.FilterEq("owner", user.Did), 399 399 orm.FilterEq("instance", instance), 400 400 ) 401 401 if err != nil || len(spindles) != 1 { ··· 404 404 return 405 405 } 406 406 407 - if string(spindles[0].Owner) != user.Active.Did { 408 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 407 + if string(spindles[0].Owner) != user.Did { 408 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 409 409 s.Pages.Notice(w, noticeId, "Failed to verify spindle, unauthorized verification attempt.") 410 410 return 411 411 } 412 412 413 413 // begin verification 414 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 414 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 415 415 if err != nil { 416 416 l.Error("verification failed", "err", err) 417 417 ··· 429 429 return 430 430 } 431 431 432 - rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 432 + rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 433 433 if err != nil { 434 434 l.Error("failed to mark verified", "err", err) 435 435 s.Pages.Notice(w, noticeId, err.Error()) ··· 467 467 return 468 468 } 469 469 l = l.With("instance", instance) 470 - l = l.With("user", user.Active.Did) 470 + l = l.With("user", user.Did) 471 471 472 472 spindles, err := db.GetSpindles( 473 473 s.Db, 474 - orm.FilterEq("owner", user.Active.Did), 474 + orm.FilterEq("owner", user.Did), 475 475 orm.FilterEq("instance", instance), 476 476 ) 477 477 if err != nil || len(spindles) != 1 { ··· 486 486 s.Pages.Notice(w, noticeId, defaultErr) 487 487 } 488 488 489 - if string(spindles[0].Owner) != user.Active.Did { 490 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 489 + if string(spindles[0].Owner) != user.Did { 490 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 491 491 s.Pages.Notice(w, noticeId, "Failed to add member, unauthorized attempt.") 492 492 return 493 493 } ··· 536 536 537 537 // add member to db 538 538 if err = db.AddSpindleMember(tx, models.SpindleMember{ 539 - Did: syntax.DID(user.Active.Did), 539 + Did: syntax.DID(user.Did), 540 540 Rkey: rkey, 541 541 Instance: instance, 542 542 Subject: memberId.DID, ··· 554 554 555 555 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 556 556 Collection: tangled.SpindleMemberNSID, 557 - Repo: user.Active.Did, 557 + Repo: user.Did, 558 558 Rkey: rkey, 559 559 Record: &lexutil.LexiconTypeDecoder{ 560 560 Val: &tangled.SpindleMember{ ··· 603 603 return 604 604 } 605 605 l = l.With("instance", instance) 606 - l = l.With("user", user.Active.Did) 606 + l = l.With("user", user.Did) 607 607 608 608 spindles, err := db.GetSpindles( 609 609 s.Db, 610 - orm.FilterEq("owner", user.Active.Did), 610 + orm.FilterEq("owner", user.Did), 611 611 orm.FilterEq("instance", instance), 612 612 ) 613 613 if err != nil || len(spindles) != 1 { ··· 616 616 return 617 617 } 618 618 619 - if string(spindles[0].Owner) != user.Active.Did { 620 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 619 + if string(spindles[0].Owner) != user.Did { 620 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 621 621 s.Pages.Notice(w, noticeId, "Failed to remove member, unauthorized attempt.") 622 622 return 623 623 } ··· 652 652 // get the record from the DB first: 653 653 members, err := db.GetSpindleMembers( 654 654 s.Db, 655 - orm.FilterEq("did", user.Active.Did), 655 + orm.FilterEq("did", user.Did), 656 656 orm.FilterEq("instance", instance), 657 657 orm.FilterEq("subject", memberId.DID), 658 658 ) ··· 665 665 // remove from db 666 666 if err = db.RemoveSpindleMember( 667 667 tx, 668 - orm.FilterEq("did", user.Active.Did), 668 + orm.FilterEq("did", user.Did), 669 669 orm.FilterEq("instance", instance), 670 670 orm.FilterEq("subject", memberId.DID), 671 671 ); err != nil { ··· 691 691 // remove from pds 692 692 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 693 693 Collection: tangled.SpindleMemberNSID, 694 - Repo: user.Active.Did, 694 + Repo: user.Did, 695 695 Rkey: members[0].Rkey, 696 696 }) 697 697 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
··· 114 114 return 115 115 } 116 116 117 - currentDid := currentUser.Active.Did 117 + currentDid := currentUser.Did 118 118 119 119 var remainingAccounts []string 120 120 for _, acc := range currentUser.Accounts {
+35 -39
appview/state/profile.go
··· 91 91 loggedInUser := s.oauth.GetMultiAccountUser(r) 92 92 followStatus := models.IsNotFollowing 93 93 if loggedInUser != nil { 94 - followStatus = db.GetFollowStatus(s.db, loggedInUser.Active.Did, did) 94 + followStatus = db.GetFollowStatus(s.db, loggedInUser.Did, did) 95 95 } 96 96 97 - var loggedInDid string 98 - if loggedInUser != nil { 99 - loggedInDid = loggedInUser.Did() 100 - } 101 - showPunchcard := s.shouldShowPunchcard(did, loggedInDid) 97 + showPunchcard := s.shouldShowPunchcard(did, loggedInUser.Did) 102 98 103 99 var punchcard *models.Punchcard 104 100 if showPunchcard { ··· 428 424 429 425 loggedInUserFollowing := make(map[string]struct{}) 430 426 if loggedInUser != nil { 431 - following, err := db.GetFollowing(s.db, loggedInUser.Active.Did) 427 + following, err := db.GetFollowing(s.db, loggedInUser.Did) 432 428 if err != nil { 433 - l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Active.Did) 429 + l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Did) 434 430 return &params, err 435 431 } 436 432 loggedInUserFollowing = make(map[string]struct{}, len(following)) ··· 445 441 followStatus := models.IsNotFollowing 446 442 if _, exists := loggedInUserFollowing[did]; exists { 447 443 followStatus = models.IsFollowing 448 - } else if loggedInUser != nil && loggedInUser.Active.Did == did { 444 + } else if loggedInUser != nil && loggedInUser.Did == did { 449 445 followStatus = models.IsSelf 450 446 } 451 447 ··· 651 647 return 652 648 } 653 649 654 - profile, err := db.GetProfile(s.db, user.Active.Did) 650 + profile, err := db.GetProfile(s.db, user.Did) 655 651 if err != nil { 656 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 652 + log.Printf("getting profile data for %s: %s", user.Did, err) 657 653 } 658 654 if profile == nil { 659 - profile = &models.Profile{Did: user.Active.Did} 655 + profile = &models.Profile{Did: user.Did} 660 656 } 661 657 662 658 profile.Description = r.FormValue("description") ··· 697 693 return 698 694 } 699 695 700 - profile, err := db.GetProfile(s.db, user.Active.Did) 696 + profile, err := db.GetProfile(s.db, user.Did) 701 697 if err != nil { 702 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 698 + log.Printf("getting profile data for %s: %s", user.Did, err) 703 699 } 704 700 if profile == nil { 705 - profile = &models.Profile{Did: user.Active.Did} 701 + profile = &models.Profile{Did: user.Did} 706 702 } 707 703 708 704 i := 0 ··· 757 753 vanityStats = append(vanityStats, string(v.Kind)) 758 754 } 759 755 760 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 756 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 761 757 var cid *string 762 758 if ex != nil { 763 759 cid = ex.Cid ··· 765 761 766 762 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 767 763 Collection: tangled.ActorProfileNSID, 768 - Repo: user.Active.Did, 764 + Repo: user.Did, 769 765 Rkey: "self", 770 766 Record: &lexutil.LexiconTypeDecoder{ 771 767 Val: &tangled.ActorProfile{ ··· 794 790 795 791 s.notifier.UpdateProfile(r.Context(), profile) 796 792 797 - s.pages.HxRedirect(w, "/"+user.Active.Did) 793 + s.pages.HxRedirect(w, "/"+user.Did) 798 794 } 799 795 800 796 func (s *State) EditBioFragment(w http.ResponseWriter, r *http.Request) { 801 797 user := s.oauth.GetMultiAccountUser(r) 802 798 803 - profile, err := db.GetProfile(s.db, user.Active.Did) 799 + profile, err := db.GetProfile(s.db, user.Did) 804 800 if err != nil { 805 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 801 + log.Printf("getting profile data for %s: %s", user.Did, err) 806 802 } 807 803 if profile == nil { 808 - profile = &models.Profile{Did: user.Active.Did} 804 + profile = &models.Profile{Did: user.Did} 809 805 } 810 806 811 807 s.pages.EditBioFragment(w, pages.EditBioParams{ ··· 817 813 func (s *State) EditPinsFragment(w http.ResponseWriter, r *http.Request) { 818 814 user := s.oauth.GetMultiAccountUser(r) 819 815 820 - profile, err := db.GetProfile(s.db, user.Active.Did) 816 + profile, err := db.GetProfile(s.db, user.Did) 821 817 if err != nil { 822 - log.Printf("getting profile data for %s: %s", user.Active.Did, err) 818 + log.Printf("getting profile data for %s: %s", user.Did, err) 823 819 } 824 820 if profile == nil { 825 - profile = &models.Profile{Did: user.Active.Did} 821 + profile = &models.Profile{Did: user.Did} 826 822 } 827 823 828 - repos, err := db.GetRepos(s.db, orm.FilterEq("did", user.Active.Did)) 824 + repos, err := db.GetRepos(s.db, orm.FilterEq("did", user.Did)) 829 825 if err != nil { 830 - log.Printf("getting repos for %s: %s", user.Active.Did, err) 826 + log.Printf("getting repos for %s: %s", user.Did, err) 831 827 } 832 828 833 - collaboratingRepos, err := db.CollaboratingIn(s.db, user.Active.Did) 829 + collaboratingRepos, err := db.CollaboratingIn(s.db, user.Did) 834 830 if err != nil { 835 - log.Printf("getting collaborating repos for %s: %s", user.Active.Did, err) 831 + log.Printf("getting collaborating repos for %s: %s", user.Did, err) 836 832 } 837 833 838 834 allRepos := []pages.PinnedRepo{} ··· 862 858 func (s *State) UploadProfileAvatar(w http.ResponseWriter, r *http.Request) { 863 859 l := s.logger.With("handler", "UploadProfileAvatar") 864 860 user := s.oauth.GetMultiAccountUser(r) 865 - l = l.With("did", user.Active.Did) 861 + l = l.With("did", user.Did) 866 862 867 863 // Parse multipart form (10MB max) 868 864 if err := r.ParseMultipartForm(10 << 20); err != nil { ··· 909 905 l.Info("uploaded avatar blob", "cid", uploadBlobResp.Blob.Ref.String()) 910 906 911 907 // get current profile record from PDS to get its CID for swap 912 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 908 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 913 909 if err != nil { 914 910 l.Error("failed to get current profile record", "err", err) 915 911 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 933 929 934 930 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 935 931 Collection: tangled.ActorProfileNSID, 936 - Repo: user.Active.Did, 932 + Repo: user.Did, 937 933 Rkey: "self", 938 934 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 939 935 SwapRecord: getRecordResp.Cid, ··· 947 943 948 944 l.Info("successfully updated profile with avatar") 949 945 950 - profile, err := db.GetProfile(s.db, user.Active.Did) 946 + profile, err := db.GetProfile(s.db, user.Did) 951 947 if err != nil { 952 948 l.Warn("getting profile data from DB", "err", err) 953 949 } 954 950 if profile == nil { 955 - profile = &models.Profile{Did: user.Active.Did} 951 + profile = &models.Profile{Did: user.Did} 956 952 } 957 953 profile.Avatar = uploadBlobResp.Blob.Ref.String() 958 954 ··· 978 974 func (s *State) RemoveProfileAvatar(w http.ResponseWriter, r *http.Request) { 979 975 l := s.logger.With("handler", "RemoveProfileAvatar") 980 976 user := s.oauth.GetMultiAccountUser(r) 981 - l = l.With("did", user.Active.Did) 977 + l = l.With("did", user.Did) 982 978 983 979 client, err := s.oauth.AuthorizedClient(r) 984 980 if err != nil { ··· 987 983 return 988 984 } 989 985 990 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 986 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 991 987 if err != nil { 992 988 l.Error("failed to get current profile record", "err", err) 993 989 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 1011 1007 1012 1008 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 1013 1009 Collection: tangled.ActorProfileNSID, 1014 - Repo: user.Active.Did, 1010 + Repo: user.Did, 1015 1011 Rkey: "self", 1016 1012 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 1017 1013 SwapRecord: getRecordResp.Cid, ··· 1025 1021 1026 1022 l.Info("successfully removed avatar from PDS") 1027 1023 1028 - profile, err := db.GetProfile(s.db, user.Active.Did) 1024 + profile, err := db.GetProfile(s.db, user.Did) 1029 1025 if err != nil { 1030 1026 l.Warn("getting profile data from DB", "err", err) 1031 1027 } 1032 1028 if profile == nil { 1033 - profile = &models.Profile{Did: user.Active.Did} 1029 + profile = &models.Profile{Did: user.Did} 1034 1030 } 1035 1031 profile.Avatar = "" 1036 1032 ··· 1071 1067 hideOthers = true 1072 1068 } 1073 1069 1074 - err = db.UpsertPunchcardPreference(s.db, user.Active.Did, hideMine, hideOthers) 1070 + err = db.UpsertPunchcardPreference(s.db, user.Did, hideMine, hideOthers) 1075 1071 if err != nil { 1076 1072 log.Println("failed to update punchcard preferences", err) 1077 1073 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
··· 283 283 } 284 284 285 285 l := s.logger.With("handler", "UpgradeBanner") 286 - l = l.With("did", user.Active.Did) 286 + l = l.With("did", user.Did) 287 287 288 288 regs, err := db.GetRegistrations( 289 289 s.db, 290 - orm.FilterEq("did", user.Active.Did), 290 + orm.FilterEq("did", user.Did), 291 291 orm.FilterEq("needs_upgrade", 1), 292 292 ) 293 293 if err != nil { ··· 296 296 297 297 spindles, err := db.GetSpindles( 298 298 s.db, 299 - orm.FilterEq("owner", user.Active.Did), 299 + orm.FilterEq("owner", user.Did), 300 300 orm.FilterEq("needs_upgrade", 1), 301 301 ) 302 302 if err != nil { ··· 386 386 switch r.Method { 387 387 case http.MethodGet: 388 388 user := s.oauth.GetMultiAccountUser(r) 389 - knots, err := s.enforcer.GetKnotsForUser(user.Active.Did) 389 + knots, err := s.enforcer.GetKnotsForUser(user.Did) 390 390 if err != nil { 391 391 s.pages.Notice(w, "repo", "Invalid user account.") 392 392 return ··· 401 401 l := s.logger.With("handler", "NewRepo") 402 402 403 403 user := s.oauth.GetMultiAccountUser(r) 404 - l = l.With("did", user.Active.Did) 404 + l = l.With("did", user.Did) 405 405 406 406 // form validation 407 407 domain := r.FormValue("domain") ··· 437 437 } 438 438 439 439 // ACL validation 440 - ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create") 440 + ok, err := s.enforcer.E.Enforce(user.Did, domain, domain, "repo:create") 441 441 if err != nil || !ok { 442 442 l.Info("unauthorized") 443 443 s.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") ··· 447 447 // Check for existing repos 448 448 existingRepo, err := db.GetRepo( 449 449 s.db, 450 - orm.FilterEq("did", user.Active.Did), 450 + orm.FilterEq("did", user.Did), 451 451 orm.FilterEq("name", repoName), 452 452 ) 453 453 if err == nil && existingRepo != nil { ··· 459 459 // create atproto record for this repo 460 460 rkey := tid.TID() 461 461 repo := &models.Repo{ 462 - Did: user.Active.Did, 462 + Did: user.Did, 463 463 Name: repoName, 464 464 Knot: domain, 465 465 Rkey: rkey, ··· 478 478 479 479 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 480 480 Collection: tangled.RepoNSID, 481 - Repo: user.Active.Did, 481 + Repo: user.Did, 482 482 Rkey: rkey, 483 483 Record: &lexutil.LexiconTypeDecoder{ 484 484 Val: &record, ··· 555 555 } 556 556 557 557 // acls 558 - p, _ := securejoin.SecureJoin(user.Active.Did, repoName) 559 - err = s.enforcer.AddRepo(user.Active.Did, domain, p) 558 + p, _ := securejoin.SecureJoin(user.Did, repoName) 559 + err = s.enforcer.AddRepo(user.Did, domain, p) 560 560 if err != nil { 561 561 l.Error("acl setup failed", "err", err) 562 562 s.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 581 581 aturi = "" 582 582 583 583 s.notifier.NewRepo(r.Context(), repo) 584 - s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, repoName)) 584 + s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, repoName)) 585 585 } 586 586 } 587 587
+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) {

History

9 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
3/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview: remove oauth.User type
2/3 failed, 1/3 success
expand
expand 0 comments