Monorepo for Tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Seongmin Lee and committed by
Tangled
d8144484 531deaec

+263 -277
+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.RepoIdentifier())} 312 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.RepoIdentifier())} 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.RepoIdentifier())} 360 + roles := repoinfo.RolesInRepo{Roles: rp.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.RepoIdentifier())} 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
··· 133 133 return 134 134 } 135 135 136 - ok, err := mw.enforcer.E.HasGroupingPolicy(actor.Active.Did, group, domain) 136 + ok, err := mw.enforcer.E.HasGroupingPolicy(actor.Did, group, domain) 137 137 if err != nil || !ok { 138 - l.Warn("permission denied", "did", actor.Active.Did, "group", group, "domain", domain) 138 + l.Warn("permission denied", "did", actor.Did, "group", group, "domain", domain) 139 139 http.Error(w, "Forbidden", http.StatusUnauthorized) 140 140 return 141 141 } ··· 167 167 return 168 168 } 169 169 170 - ok, err := mw.enforcer.E.Enforce(actor.Active.Did, f.Knot, f.RepoIdentifier(), requiredPerm) 170 + ok, err := mw.enforcer.E.Enforce(actor.Did, f.Knot, f.RepoIdentifier(), requiredPerm) 171 171 if err != nil || !ok { 172 - l.Warn("permission denied", "did", actor.Active.Did, "perm", requiredPerm, "repo", f.RepoIdentifier()) 172 + l.Warn("permission denied", "did", actor.Did, "perm", requiredPerm, "repo", f.RepoIdentifier()) 173 173 http.Error(w, "Forbidden", http.StatusUnauthorized) 174 174 return 175 175 }
+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
··· 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 ""
+39 -39
appview/pulls/pulls.go
··· 106 106 case http.MethodGet: 107 107 user := s.oauth.GetMultiAccountUser(r) 108 108 if user != nil { 109 - l = l.With("user", user.Active.Did) 109 + l = l.With("user", user.Did) 110 110 } 111 111 112 112 f, err := s.repoResolver.Resolve(r) ··· 140 140 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 141 141 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 142 142 resubmitResult := pages.Unknown 143 - if user.Active.Did == pull.OwnerDid { 143 + if user.Did == pull.OwnerDid { 144 144 resubmitResult = s.resubmitCheck(r, f, pull, stack) 145 145 } 146 146 ··· 163 163 164 164 user := s.oauth.GetMultiAccountUser(r) 165 165 if user != nil { 166 - l = l.With("user", user.Active.Did) 166 + l = l.With("user", user.Did) 167 167 } 168 168 169 169 f, err := s.repoResolver.Resolve(r) ··· 209 209 mergeCheckResponse := s.mergeCheck(r, f, pull, stack) 210 210 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 211 211 resubmitResult := pages.Unknown 212 - if user != nil && user.Active.Did == pull.OwnerDid { 212 + if user != nil && user.Did == pull.OwnerDid { 213 213 resubmitResult = s.resubmitCheck(r, f, pull, stack) 214 214 } 215 215 ··· 247 247 248 248 userReactions := map[models.ReactionKind]bool{} 249 249 if user != nil { 250 - userReactions = db.GetReactionStatusMap(s.db, user.Active.Did, pull.AtUri()) 250 + userReactions = db.GetReactionStatusMap(s.db, user.Did, pull.AtUri()) 251 251 } 252 252 253 253 labelDefs, err := db.GetLabelDefinitions( ··· 415 415 } 416 416 417 417 // user can only delete branch if they are a collaborator in the repo that the branch belongs to 418 - perms := s.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.RepoIdentifier()) 418 + perms := s.enforcer.GetPermissionsInRepo(user.Did, repo.Knot, repo.RepoIdentifier()) 419 419 if !slices.Contains(perms, "repo:push") { 420 420 return nil 421 421 } ··· 504 504 505 505 user := s.oauth.GetMultiAccountUser(r) 506 506 if user != nil { 507 - l = l.With("user", user.Active.Did) 507 + l = l.With("user", user.Did) 508 508 } 509 509 510 510 params := r.URL.Query() ··· 801 801 802 802 user := s.oauth.GetMultiAccountUser(r) 803 803 if user != nil { 804 - l = l.With("user", user.Active.Did) 804 + l = l.With("user", user.Did) 805 805 } 806 806 807 807 f, err := s.repoResolver.Resolve(r) ··· 863 863 } 864 864 atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 865 865 Collection: tangled.RepoPullCommentNSID, 866 - Repo: user.Active.Did, 866 + Repo: user.Did, 867 867 Rkey: tid.TID(), 868 868 Record: &lexutil.LexiconTypeDecoder{ 869 869 Val: &tangled.RepoPullComment{ ··· 880 880 } 881 881 882 882 comment := &models.PullComment{ 883 - OwnerDid: user.Active.Did, 883 + OwnerDid: user.Did, 884 884 RepoAt: f.RepoAt().String(), 885 885 PullId: pull.PullId, 886 886 Body: body, ··· 918 918 919 919 user := s.oauth.GetMultiAccountUser(r) 920 920 if user != nil { 921 - l = l.With("user", user.Active.Did) 921 + l = l.With("user", user.Did) 922 922 } 923 923 924 924 f, err := s.repoResolver.Resolve(r) ··· 974 974 fromFork := r.FormValue("fork") 975 975 sourceBranch := r.FormValue("sourceBranch") 976 976 patch := r.FormValue("patch") 977 - userDid := syntax.DID(user.Active.Did) 977 + userDid := syntax.DID(user.Did) 978 978 979 979 if targetBranch == "" { 980 980 s.pages.Notice(w, "pull", "Target branch is required.") ··· 1603 1603 1604 1604 user := s.oauth.GetMultiAccountUser(r) 1605 1605 if user != nil { 1606 - l = l.With("user", user.Active.Did) 1606 + l = l.With("user", user.Did) 1607 1607 } 1608 1608 1609 - forks, err := db.GetForksByDid(s.db, user.Active.Did) 1609 + forks, err := db.GetForksByDid(s.db, user.Did) 1610 1610 if err != nil { 1611 1611 l.Error("failed to get forks", "err", err) 1612 1612 return ··· 1624 1624 1625 1625 user := s.oauth.GetMultiAccountUser(r) 1626 1626 if user != nil { 1627 - l = l.With("user", user.Active.Did) 1627 + l = l.With("user", user.Did) 1628 1628 } 1629 1629 1630 1630 f, err := s.repoResolver.Resolve(r) ··· 1704 1704 1705 1705 user := s.oauth.GetMultiAccountUser(r) 1706 1706 if user != nil { 1707 - l = l.With("user", user.Active.Did) 1707 + l = l.With("user", user.Did) 1708 1708 } 1709 1709 1710 1710 pull, ok := r.Context().Value("pull").(*models.Pull) ··· 1741 1741 1742 1742 user := s.oauth.GetMultiAccountUser(r) 1743 1743 if user != nil { 1744 - l = l.With("user", user.Active.Did) 1744 + l = l.With("user", user.Did) 1745 1745 } 1746 1746 1747 1747 pull, ok := r.Context().Value("pull").(*models.Pull) ··· 1752 1752 } 1753 1753 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid) 1754 1754 1755 - if user == nil || user.Active.Did != pull.OwnerDid { 1756 - l.Warn("unauthorized user", "actual_user", user.Active.Did, "expected_owner", pull.OwnerDid) 1755 + if user == nil || user.Did != pull.OwnerDid { 1756 + l.Warn("unauthorized user", "actual_user", user.Did, "expected_owner", pull.OwnerDid) 1757 1757 w.WriteHeader(http.StatusUnauthorized) 1758 1758 return 1759 1759 } ··· 1766 1766 1767 1767 patch := r.FormValue("patch") 1768 1768 1769 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, "", "") 1769 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, "", "") 1770 1770 } 1771 1771 1772 1772 func (s *Pulls) resubmitBranch(w http.ResponseWriter, r *http.Request) { ··· 1774 1774 1775 1775 user := s.oauth.GetMultiAccountUser(r) 1776 1776 if user != nil { 1777 - l = l.With("user", user.Active.Did) 1777 + l = l.With("user", user.Did) 1778 1778 } 1779 1779 1780 1780 pull, ok := r.Context().Value("pull").(*models.Pull) ··· 1785 1785 } 1786 1786 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid, "target_branch", pull.TargetBranch) 1787 1787 1788 - if user == nil || user.Active.Did != pull.OwnerDid { 1789 - l.Warn("unauthorized user", "actual_user", user.Active.Did, "expected_owner", pull.OwnerDid) 1788 + if user == nil || user.Did != pull.OwnerDid { 1789 + l.Warn("unauthorized user", "actual_user", user.Did, "expected_owner", pull.OwnerDid) 1790 1790 w.WriteHeader(http.StatusUnauthorized) 1791 1791 return 1792 1792 } ··· 1797 1797 return 1798 1798 } 1799 1799 1800 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.RepoIdentifier())} 1800 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.RepoIdentifier())} 1801 1801 if !roles.IsPushAllowed() { 1802 1802 l.Warn("unauthorized user - no push permission") 1803 1803 w.WriteHeader(http.StatusUnauthorized) ··· 1836 1836 patch := comparison.FormatPatchRaw 1837 1837 combined := comparison.CombinedPatchRaw 1838 1838 1839 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1839 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1840 1840 } 1841 1841 1842 1842 func (s *Pulls) resubmitFork(w http.ResponseWriter, r *http.Request) { ··· 1844 1844 1845 1845 user := s.oauth.GetMultiAccountUser(r) 1846 1846 if user != nil { 1847 - l = l.With("user", user.Active.Did) 1847 + l = l.With("user", user.Did) 1848 1848 } 1849 1849 1850 1850 pull, ok := r.Context().Value("pull").(*models.Pull) ··· 1855 1855 } 1856 1856 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid, "target_branch", pull.TargetBranch) 1857 1857 1858 - if user == nil || user.Active.Did != pull.OwnerDid { 1859 - l.Warn("unauthorized user", "actual_user", user.Active.Did, "expected_owner", pull.OwnerDid) 1858 + if user == nil || user.Did != pull.OwnerDid { 1859 + l.Warn("unauthorized user", "actual_user", user.Did, "expected_owner", pull.OwnerDid) 1860 1860 w.WriteHeader(http.StatusUnauthorized) 1861 1861 return 1862 1862 } ··· 1939 1939 patch := comparison.FormatPatchRaw 1940 1940 combined := comparison.CombinedPatchRaw 1941 1941 1942 - s.resubmitPullHelper(w, r, f, syntax.DID(user.Active.Did), pull, patch, combined, sourceRev) 1942 + s.resubmitPullHelper(w, r, f, syntax.DID(user.Did), pull, patch, combined, sourceRev) 1943 1943 } 1944 1944 1945 1945 func (s *Pulls) resubmitPullHelper( ··· 2301 2301 2302 2302 user := s.oauth.GetMultiAccountUser(r) 2303 2303 if user != nil { 2304 - l = l.With("user", user.Active.Did) 2304 + l = l.With("user", user.Did) 2305 2305 } 2306 2306 2307 2307 f, err := s.repoResolver.Resolve(r) ··· 2414 2414 2415 2415 // notify about the pull merge 2416 2416 for _, p := range pullsToMerge { 2417 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2417 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2418 2418 } 2419 2419 2420 2420 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2426 2426 2427 2427 user := s.oauth.GetMultiAccountUser(r) 2428 2428 if user != nil { 2429 - l = l.With("user", user.Active.Did) 2429 + l = l.With("user", user.Did) 2430 2430 } 2431 2431 2432 2432 f, err := s.repoResolver.Resolve(r) ··· 2444 2444 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid) 2445 2445 2446 2446 // auth filter: only owner or collaborators can close 2447 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.RepoIdentifier())} 2447 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.RepoIdentifier())} 2448 2448 isOwner := roles.IsOwner() 2449 2449 isCollaborator := roles.IsCollaborator() 2450 - isPullAuthor := user.Active.Did == pull.OwnerDid 2450 + isPullAuthor := user.Did == pull.OwnerDid 2451 2451 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2452 2452 if !isCloseAllowed { 2453 2453 l.Error("unauthorized to close pull", "is_owner", isOwner, "is_collaborator", isCollaborator, "is_pull_author", isPullAuthor) ··· 2490 2490 } 2491 2491 2492 2492 for _, p := range pullsToClose { 2493 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2493 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2494 2494 } 2495 2495 2496 2496 ownerSlashRepo := reporesolver.GetBaseRepoPath(r, f) ··· 2502 2502 2503 2503 user := s.oauth.GetMultiAccountUser(r) 2504 2504 if user != nil { 2505 - l = l.With("user", user.Active.Did) 2505 + l = l.With("user", user.Did) 2506 2506 } 2507 2507 2508 2508 f, err := s.repoResolver.Resolve(r) ··· 2521 2521 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid, "state", pull.State) 2522 2522 2523 2523 // auth filter: only owner or collaborators can close 2524 - roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Active.Did, f.Knot, f.RepoIdentifier())} 2524 + roles := repoinfo.RolesInRepo{Roles: s.enforcer.GetPermissionsInRepo(user.Did, f.Knot, f.RepoIdentifier())} 2525 2525 isOwner := roles.IsOwner() 2526 2526 isCollaborator := roles.IsCollaborator() 2527 - isPullAuthor := user.Active.Did == pull.OwnerDid 2527 + isPullAuthor := user.Did == pull.OwnerDid 2528 2528 isCloseAllowed := isOwner || isCollaborator || isPullAuthor 2529 2529 if !isCloseAllowed { 2530 2530 l.Error("unauthorized to reopen pull", "is_owner", isOwner, "is_collaborator", isCollaborator, "is_pull_author", isPullAuthor) ··· 2567 2567 } 2568 2568 2569 2569 for _, p := range pullsToReopen { 2570 - s.notifier.NewPullState(r.Context(), syntax.DID(user.Active.Did), p) 2570 + s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p) 2571 2571 } 2572 2572 2573 2573 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: repoArtifactRecord(f, uploadBlobResp.Blob, createdAt, header.Filename, tag.Tag.Hash[:]), ··· 100 100 defer tx.Rollback() 101 101 102 102 artifact := models.Artifact{ 103 - Did: user.Active.Did, 103 + Did: user.Did, 104 104 Rkey: rkey, 105 105 RepoAt: f.RepoAt(), 106 106 Tag: tag.Tag.Hash, ··· 251 251 252 252 artifact := artifacts[0] 253 253 254 - if user.Active.Did != artifact.Did { 254 + if user.Did != artifact.Did { 255 255 l.Error("user not authorized to delete artifact", "err", err) 256 256 rp.pages.Notice(w, "remove", "Unauthorized deletion of artifact.") 257 257 return ··· 259 259 260 260 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 261 261 Collection: tangled.RepoArtifactNSID, 262 - Repo: user.Active.Did, 262 + Repo: user.Did, 263 263 Rkey: artifact.Rkey, 264 264 }) 265 265 if err != nil {
+22 -22
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, ··· 341 341 func (rp *Repo) DeleteLabelDef(w http.ResponseWriter, r *http.Request) { 342 342 user := rp.oauth.GetMultiAccountUser(r) 343 343 l := rp.logger.With("handler", "DeleteLabel") 344 - l = l.With("did", user.Active.Did) 344 + l = l.With("did", user.Did) 345 345 346 346 f, err := rp.repoResolver.Resolve(r) 347 347 if err != nil { ··· 449 449 func (rp *Repo) SubscribeLabel(w http.ResponseWriter, r *http.Request) { 450 450 user := rp.oauth.GetMultiAccountUser(r) 451 451 l := rp.logger.With("handler", "SubscribeLabel") 452 - l = l.With("did", user.Active.Did) 452 + l = l.With("did", user.Did) 453 453 454 454 f, err := rp.repoResolver.Resolve(r) 455 455 if err != nil { ··· 535 535 func (rp *Repo) UnsubscribeLabel(w http.ResponseWriter, r *http.Request) { 536 536 user := rp.oauth.GetMultiAccountUser(r) 537 537 l := rp.logger.With("handler", "UnsubscribeLabel") 538 - l = l.With("did", user.Active.Did) 538 + l = l.With("did", user.Did) 539 539 540 540 f, err := rp.repoResolver.Resolve(r) 541 541 if err != nil { ··· 706 706 func (rp *Repo) AddCollaborator(w http.ResponseWriter, r *http.Request) { 707 707 user := rp.oauth.GetMultiAccountUser(r) 708 708 l := rp.logger.With("handler", "AddCollaborator") 709 - l = l.With("did", user.Active.Did) 709 + l = l.With("did", user.Did) 710 710 711 711 f, err := rp.repoResolver.Resolve(r) 712 712 if err != nil { ··· 735 735 return 736 736 } 737 737 738 - if collaboratorIdent.DID.String() == user.Active.Did { 738 + if collaboratorIdent.DID.String() == user.Did { 739 739 fail("You seem to be adding yourself as a collaborator.", nil) 740 740 return 741 741 } ··· 755 755 createdAt := time.Now() 756 756 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 757 757 Collection: tangled.RepoCollaboratorNSID, 758 - Repo: currentUser.Active.Did, 758 + Repo: currentUser.Did, 759 759 Rkey: rkey, 760 760 Record: &lexutil.LexiconTypeDecoder{ 761 761 Val: repoCollaboratorRecord(f, collaboratorIdent.DID.String(), createdAt), ··· 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 { ··· 980 980 r.Context(), 981 981 client, 982 982 &tangled.RepoForkSync_Input{ 983 - Did: user.Active.Did, 983 + Did: user.Did, 984 984 Name: f.Name, 985 985 Source: f.Source, 986 986 Branch: ref, ··· 1010 1010 switch r.Method { 1011 1011 case http.MethodGet: 1012 1012 user := rp.oauth.GetMultiAccountUser(r) 1013 - knots, err := rp.enforcer.GetKnotsForUser(user.Active.Did) 1013 + knots, err := rp.enforcer.GetKnotsForUser(user.Did) 1014 1014 if err != nil { 1015 1015 rp.pages.Notice(w, "repo", "Invalid user account.") 1016 1016 return ··· 1032 1032 } 1033 1033 l = l.With("targetKnot", targetKnot) 1034 1034 1035 - ok, err := rp.enforcer.E.Enforce(user.Active.Did, targetKnot, targetKnot, "repo:create") 1035 + ok, err := rp.enforcer.E.Enforce(user.Did, targetKnot, targetKnot, "repo:create") 1036 1036 if err != nil || !ok { 1037 1037 rp.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") 1038 1038 return ··· 1049 1049 // in the user's account. 1050 1050 existingRepo, err := db.GetRepo( 1051 1051 rp.db, 1052 - orm.FilterEq("did", user.Active.Did), 1052 + orm.FilterEq("did", user.Did), 1053 1053 orm.FilterEq("name", forkName), 1054 1054 ) 1055 1055 if err != nil { ··· 1121 1121 } 1122 1122 1123 1123 repo := &models.Repo{ 1124 - Did: user.Active.Did, 1124 + Did: user.Did, 1125 1125 Name: forkName, 1126 1126 Knot: targetKnot, 1127 1127 Rkey: rkey, ··· 1150 1150 } 1151 1151 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) 1152 1152 if dErr := tangled.RepoDelete(ctx, deleteClient, &tangled.RepoDelete_Input{ 1153 - Did: user.Active.Did, 1153 + Did: user.Did, 1154 1154 Name: forkName, 1155 1155 Rkey: rkey, 1156 1156 }); dErr != nil { ··· 1163 1163 return 1164 1164 } 1165 1165 l.Error("exhausted retries for knot cleanup, fork may be orphaned", 1166 - "did", user.Active.Did, "fork", forkName, "knot", targetKnot) 1166 + "did", user.Did, "fork", forkName, "knot", targetKnot) 1167 1167 }() 1168 1168 } 1169 1169 ··· 1177 1177 1178 1178 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 1179 1179 Collection: tangled.RepoNSID, 1180 - Repo: user.Active.Did, 1180 + Repo: user.Did, 1181 1181 Rkey: rkey, 1182 1182 Record: &lexutil.LexiconTypeDecoder{ 1183 1183 Val: &record, ··· 1228 1228 } 1229 1229 1230 1230 rbacPath := repo.RepoIdentifier() 1231 - err = rp.enforcer.AddRepo(user.Active.Did, targetKnot, rbacPath) 1231 + err = rp.enforcer.AddRepo(user.Did, targetKnot, rbacPath) 1232 1232 if err != nil { 1233 1233 l.Error("failed to add ACLs", "err", err) 1234 1234 rp.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 1255 1255 if repoDid != "" { 1256 1256 rp.pages.HxLocation(w, fmt.Sprintf("/%s", repoDid)) 1257 1257 } else { 1258 - rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, forkName)) 1258 + rp.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, forkName)) 1259 1259 } 1260 1260 } 1261 1261 }
+1 -1
appview/repo/settings.go
··· 72 72 func (rp *Repo) Secrets(w http.ResponseWriter, r *http.Request) { 73 73 user := rp.oauth.GetMultiAccountUser(r) 74 74 l := rp.logger.With("handler", "Secrets") 75 - l = l.With("did", user.Active.Did) 75 + l = l.With("did", user.Did) 76 76 77 77 f, err := rp.repoResolver.Resolve(r) 78 78 if err != nil {
+2 -2
appview/reporesolver/resolver.go
··· 78 78 isStarred := false 79 79 roles := repoinfo.RolesInRepo{} 80 80 if user != nil { 81 - isStarred = db.GetStarStatus(rr.execer, user.Active.Did, repoAt) 82 - roles.Roles = rr.enforcer.GetPermissionsInRepo(user.Active.Did, repo.Knot, repo.RepoIdentifier()) 81 + isStarred = db.GetStarStatus(rr.execer, user.Did, repoAt) 82 + roles.Roles = rr.enforcer.GetPermissionsInRepo(user.Did, repo.Knot, repo.RepoIdentifier()) 83 83 } 84 84 85 85 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
··· 60 60 all, err := db.GetSpindles( 61 61 r.Context(), 62 62 s.Db, 63 - orm.FilterEq("owner", user.Active.Did), 63 + orm.FilterEq("owner", user.Did), 64 64 ) 65 65 if err != nil { 66 66 s.Logger.Error("failed to fetch spindles", "err", err) ··· 79 79 l := s.Logger.With("handler", "dashboard") 80 80 81 81 user := s.OAuth.GetMultiAccountUser(r) 82 - l = l.With("user", user.Active.Did) 82 + l = l.With("user", user.Did) 83 83 84 84 instance := chi.URLParam(r, "instance") 85 85 if instance == "" { ··· 91 91 r.Context(), 92 92 s.Db, 93 93 orm.FilterEq("instance", instance), 94 - orm.FilterEq("owner", user.Active.Did), 94 + orm.FilterEq("owner", user.Did), 95 95 orm.FilterIsNot("verified", "null"), 96 96 ) 97 97 if err != nil || len(spindles) != 1 { ··· 162 162 return 163 163 } 164 164 l = l.With("instance", instance) 165 - l = l.With("user", user.Active.Did) 165 + l = l.With("user", user.Did) 166 166 167 167 tx, err := s.Db.Begin() 168 168 if err != nil { ··· 176 176 }() 177 177 178 178 err = db.AddSpindle(tx, models.Spindle{ 179 - Owner: syntax.DID(user.Active.Did), 179 + Owner: syntax.DID(user.Did), 180 180 Instance: instance, 181 181 }) 182 182 if err != nil { ··· 200 200 return 201 201 } 202 202 203 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Active.Did, instance) 203 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.SpindleNSID, user.Did, instance) 204 204 var exCid *string 205 205 if ex != nil { 206 206 exCid = ex.Cid ··· 209 209 // re-announce by registering under same rkey 210 210 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 211 211 Collection: tangled.SpindleNSID, 212 - Repo: user.Active.Did, 212 + Repo: user.Did, 213 213 Rkey: instance, 214 214 Record: &lexutil.LexiconTypeDecoder{ 215 215 Val: &tangled.Spindle{ ··· 240 240 } 241 241 242 242 // begin verification 243 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 243 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 244 244 if err != nil { 245 245 l.Error("verification failed", "err", err) 246 246 s.Pages.HxRefresh(w) 247 247 return 248 248 } 249 249 250 - _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 250 + _, err = serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 251 251 if err != nil { 252 252 l.Error("failed to mark verified", "err", err) 253 253 s.Pages.HxRefresh(w) ··· 278 278 spindles, err := db.GetSpindles( 279 279 r.Context(), 280 280 s.Db, 281 - orm.FilterEq("owner", user.Active.Did), 281 + orm.FilterEq("owner", user.Did), 282 282 orm.FilterEq("instance", instance), 283 283 ) 284 284 if err != nil || len(spindles) != 1 { ··· 287 287 return 288 288 } 289 289 290 - if string(spindles[0].Owner) != user.Active.Did { 291 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 290 + if string(spindles[0].Owner) != user.Did { 291 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 292 292 s.Pages.Notice(w, noticeId, "Failed to delete spindle, unauthorized deletion attempt.") 293 293 return 294 294 } ··· 307 307 // remove spindle members first 308 308 err = db.RemoveSpindleMember( 309 309 tx, 310 - orm.FilterEq("did", user.Active.Did), 310 + orm.FilterEq("did", user.Did), 311 311 orm.FilterEq("instance", instance), 312 312 ) 313 313 if err != nil { ··· 318 318 319 319 err = db.DeleteSpindle( 320 320 tx, 321 - orm.FilterEq("owner", user.Active.Did), 321 + orm.FilterEq("owner", user.Did), 322 322 orm.FilterEq("instance", instance), 323 323 ) 324 324 if err != nil { ··· 346 346 347 347 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 348 348 Collection: tangled.SpindleNSID, 349 - Repo: user.Active.Did, 349 + Repo: user.Did, 350 350 Rkey: instance, 351 351 }) 352 352 if err != nil { ··· 394 394 return 395 395 } 396 396 l = l.With("instance", instance) 397 - l = l.With("user", user.Active.Did) 397 + l = l.With("user", user.Did) 398 398 399 399 spindles, err := db.GetSpindles( 400 400 r.Context(), 401 401 s.Db, 402 - orm.FilterEq("owner", user.Active.Did), 402 + orm.FilterEq("owner", user.Did), 403 403 orm.FilterEq("instance", instance), 404 404 ) 405 405 if err != nil || len(spindles) != 1 { ··· 408 408 return 409 409 } 410 410 411 - if string(spindles[0].Owner) != user.Active.Did { 412 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 411 + if string(spindles[0].Owner) != user.Did { 412 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 413 413 s.Pages.Notice(w, noticeId, "Failed to verify spindle, unauthorized verification attempt.") 414 414 return 415 415 } 416 416 417 417 // begin verification 418 - err = serververify.RunVerification(r.Context(), instance, user.Active.Did, s.Config.Core.Dev) 418 + err = serververify.RunVerification(r.Context(), instance, user.Did, s.Config.Core.Dev) 419 419 if err != nil { 420 420 l.Error("verification failed", "err", err) 421 421 ··· 433 433 return 434 434 } 435 435 436 - rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Active.Did) 436 + rowId, err := serververify.MarkSpindleVerified(s.Db, s.Enforcer, instance, user.Did) 437 437 if err != nil { 438 438 l.Error("failed to mark verified", "err", err) 439 439 s.Pages.Notice(w, noticeId, err.Error()) ··· 472 472 return 473 473 } 474 474 l = l.With("instance", instance) 475 - l = l.With("user", user.Active.Did) 475 + l = l.With("user", user.Did) 476 476 477 477 spindles, err := db.GetSpindles( 478 478 r.Context(), 479 479 s.Db, 480 - orm.FilterEq("owner", user.Active.Did), 480 + orm.FilterEq("owner", user.Did), 481 481 orm.FilterEq("instance", instance), 482 482 ) 483 483 if err != nil || len(spindles) != 1 { ··· 492 492 s.Pages.Notice(w, noticeId, defaultErr) 493 493 } 494 494 495 - if string(spindles[0].Owner) != user.Active.Did { 496 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 495 + if string(spindles[0].Owner) != user.Did { 496 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 497 497 s.Pages.Notice(w, noticeId, "Failed to add member, unauthorized attempt.") 498 498 return 499 499 } ··· 542 542 543 543 // add member to db 544 544 if err = db.AddSpindleMember(tx, models.SpindleMember{ 545 - Did: syntax.DID(user.Active.Did), 545 + Did: syntax.DID(user.Did), 546 546 Rkey: rkey, 547 547 Instance: instance, 548 548 Subject: memberId.DID, ··· 560 560 561 561 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 562 562 Collection: tangled.SpindleMemberNSID, 563 - Repo: user.Active.Did, 563 + Repo: user.Did, 564 564 Rkey: rkey, 565 565 Record: &lexutil.LexiconTypeDecoder{ 566 566 Val: &tangled.SpindleMember{ ··· 609 609 return 610 610 } 611 611 l = l.With("instance", instance) 612 - l = l.With("user", user.Active.Did) 612 + l = l.With("user", user.Did) 613 613 614 614 spindles, err := db.GetSpindles( 615 615 r.Context(), 616 616 s.Db, 617 - orm.FilterEq("owner", user.Active.Did), 617 + orm.FilterEq("owner", user.Did), 618 618 orm.FilterEq("instance", instance), 619 619 ) 620 620 if err != nil || len(spindles) != 1 { ··· 623 623 return 624 624 } 625 625 626 - if string(spindles[0].Owner) != user.Active.Did { 627 - l.Error("unauthorized", "user", user.Active.Did, "owner", spindles[0].Owner) 626 + if string(spindles[0].Owner) != user.Did { 627 + l.Error("unauthorized", "user", user.Did, "owner", spindles[0].Owner) 628 628 s.Pages.Notice(w, noticeId, "Failed to remove member, unauthorized attempt.") 629 629 return 630 630 } ··· 659 659 // get the record from the DB first: 660 660 members, err := db.GetSpindleMembers( 661 661 s.Db, 662 - orm.FilterEq("did", user.Active.Did), 662 + orm.FilterEq("did", user.Did), 663 663 orm.FilterEq("instance", instance), 664 664 orm.FilterEq("subject", memberId.DID), 665 665 ) ··· 672 672 // remove from db 673 673 if err = db.RemoveSpindleMember( 674 674 tx, 675 - orm.FilterEq("did", user.Active.Did), 675 + orm.FilterEq("did", user.Did), 676 676 orm.FilterEq("instance", instance), 677 677 orm.FilterEq("subject", memberId.DID), 678 678 ); err != nil { ··· 698 698 // remove from pds 699 699 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 700 700 Collection: tangled.SpindleMemberNSID, 701 - Repo: user.Active.Did, 701 + Repo: user.Did, 702 702 Rkey: members[0].Rkey, 703 703 }) 704 704 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 l.Warn("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 l.Info("created atproto record", "uri", 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 l.Error("failed to get follow relationship", "err", err) 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 l.Warn("failed to delete follow from DB", "err", err) 112 112 // this is not an issue, the firehose event might have already done this
+1 -1
appview/state/login.go
··· 133 133 return 134 134 } 135 135 136 - currentDid := currentUser.Active.Did 136 + currentDid := currentUser.Did 137 137 138 138 var remainingAccounts []string 139 139 for _, acc := range currentUser.Accounts {
+37 -41
appview/state/profile.go
··· 92 92 loggedInUser := s.oauth.GetMultiAccountUser(r) 93 93 followStatus := models.IsNotFollowing 94 94 if loggedInUser != nil { 95 - followStatus = db.GetFollowStatus(s.db, loggedInUser.Active.Did, did) 95 + followStatus = db.GetFollowStatus(s.db, loggedInUser.Did, did) 96 96 } 97 97 98 - var loggedInDid string 99 - if loggedInUser != nil { 100 - loggedInDid = loggedInUser.Did() 101 - } 102 - showPunchcard := s.shouldShowPunchcard(did, loggedInDid) 98 + showPunchcard := s.shouldShowPunchcard(did, loggedInUser.Did) 103 99 104 100 var punchcard *models.Punchcard 105 101 if showPunchcard { ··· 432 428 433 429 loggedInUserFollowing := make(map[string]struct{}) 434 430 if loggedInUser != nil { 435 - following, err := db.GetFollowing(s.db, loggedInUser.Active.Did) 431 + following, err := db.GetFollowing(s.db, loggedInUser.Did) 436 432 if err != nil { 437 - l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Active.Did) 433 + l.Error("failed to get follow list", "err", err, "loggedInUser", loggedInUser.Did) 438 434 return &params, err 439 435 } 440 436 loggedInUserFollowing = make(map[string]struct{}, len(following)) ··· 449 445 followStatus := models.IsNotFollowing 450 446 if _, exists := loggedInUserFollowing[did]; exists { 451 447 followStatus = models.IsFollowing 452 - } else if loggedInUser != nil && loggedInUser.Active.Did == did { 448 + } else if loggedInUser != nil && loggedInUser.Did == did { 453 449 followStatus = models.IsSelf 454 450 } 455 451 ··· 656 652 return 657 653 } 658 654 659 - profile, err := db.GetProfile(s.db, user.Active.Did) 655 + profile, err := db.GetProfile(s.db, user.Did) 660 656 if err != nil { 661 - l.Error("getting profile data", "did", user.Active.Did, "err", err) 657 + l.Error("getting profile data", "did", user.Did, "err", err) 662 658 } 663 659 if profile == nil { 664 - profile = &models.Profile{Did: user.Active.Did} 660 + profile = &models.Profile{Did: user.Did} 665 661 } 666 662 667 663 profile.Description = r.FormValue("description") ··· 676 672 return 677 673 } 678 674 679 - ident, err := s.idResolver.ResolveIdent(r.Context(), user.Active.Did) 675 + ident, err := s.idResolver.ResolveIdent(r.Context(), user.Did) 680 676 if err != nil || !slices.Contains(ident.AlsoKnownAs, "at://"+rawPreferredHandle) { 681 677 s.pages.Notice(w, "update-profile", "Handle not found in your DID document.") 682 678 return ··· 720 716 return 721 717 } 722 718 723 - profile, err := db.GetProfile(s.db, user.Active.Did) 719 + profile, err := db.GetProfile(s.db, user.Did) 724 720 if err != nil { 725 - l.Error("getting profile data", "did", user.Active.Did, "err", err) 721 + l.Error("getting profile data", "did", user.Did, "err", err) 726 722 } 727 723 if profile == nil { 728 - profile = &models.Profile{Did: user.Active.Did} 724 + profile = &models.Profile{Did: user.Did} 729 725 } 730 726 731 727 i := 0 ··· 775 771 vanityStats = append(vanityStats, string(v.Kind)) 776 772 } 777 773 778 - ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 774 + ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 779 775 var cid *string 780 776 var existingAvatar *lexutil.LexBlob 781 777 if ex != nil { ··· 787 783 788 784 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 789 785 Collection: tangled.ActorProfileNSID, 790 - Repo: user.Active.Did, 786 + Repo: user.Did, 791 787 Rkey: "self", 792 788 Record: &lexutil.LexiconTypeDecoder{ 793 789 Val: &tangled.ActorProfile{ ··· 818 814 819 815 s.notifier.UpdateProfile(r.Context(), profile) 820 816 821 - s.pages.HxRedirect(w, "/"+user.Active.Did) 817 + s.pages.HxRedirect(w, "/"+user.Did) 822 818 } 823 819 824 820 func (s *State) EditBioFragment(w http.ResponseWriter, r *http.Request) { 825 821 l := s.logger.With("handler", "EditBioFragment") 826 822 user := s.oauth.GetMultiAccountUser(r) 827 823 828 - profile, err := db.GetProfile(s.db, user.Active.Did) 824 + profile, err := db.GetProfile(s.db, user.Did) 829 825 if err != nil { 830 - l.Error("getting profile data", "did", user.Active.Did, "err", err) 826 + l.Error("getting profile data", "did", user.Did, "err", err) 831 827 } 832 828 if profile == nil { 833 - profile = &models.Profile{Did: user.Active.Did} 829 + profile = &models.Profile{Did: user.Did} 834 830 } 835 831 836 832 var alsoKnownAs []string 837 - ident, err := s.idResolver.ResolveIdent(r.Context(), user.Active.Did) 833 + ident, err := s.idResolver.ResolveIdent(r.Context(), user.Did) 838 834 if err == nil { 839 835 alsoKnownAs = ident.AlsoKnownAs 840 836 } ··· 850 846 l := s.logger.With("handler", "EditPinsFragment") 851 847 user := s.oauth.GetMultiAccountUser(r) 852 848 853 - profile, err := db.GetProfile(s.db, user.Active.Did) 849 + profile, err := db.GetProfile(s.db, user.Did) 854 850 if err != nil { 855 - l.Error("getting profile data", "did", user.Active.Did, "err", err) 851 + l.Error("getting profile data", "did", user.Did, "err", err) 856 852 } 857 853 if profile == nil { 858 - profile = &models.Profile{Did: user.Active.Did} 854 + profile = &models.Profile{Did: user.Did} 859 855 } 860 856 861 - repos, err := db.GetRepos(s.db, orm.FilterEq("did", user.Active.Did)) 857 + repos, err := db.GetRepos(s.db, orm.FilterEq("did", user.Did)) 862 858 if err != nil { 863 - l.Error("getting repos", "did", user.Active.Did, "err", err) 859 + l.Error("getting repos", "did", user.Did, "err", err) 864 860 } 865 861 866 - collaboratingRepos, err := db.CollaboratingIn(s.db, user.Active.Did) 862 + collaboratingRepos, err := db.CollaboratingIn(s.db, user.Did) 867 863 if err != nil { 868 - l.Error("getting collaborating repos", "did", user.Active.Did, "err", err) 864 + l.Error("getting collaborating repos", "did", user.Did, "err", err) 869 865 } 870 866 871 867 allRepos := []pages.PinnedRepo{} ··· 893 889 func (s *State) UploadProfileAvatar(w http.ResponseWriter, r *http.Request) { 894 890 l := s.logger.With("handler", "UploadProfileAvatar") 895 891 user := s.oauth.GetMultiAccountUser(r) 896 - l = l.With("did", user.Active.Did) 892 + l = l.With("did", user.Did) 897 893 898 894 // Parse multipart form (10MB max) 899 895 if err := r.ParseMultipartForm(10 << 20); err != nil { ··· 940 936 l.Info("uploaded avatar blob", "cid", uploadBlobResp.Blob.Ref.String()) 941 937 942 938 // get current profile record from PDS to get its CID for swap 943 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 939 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 944 940 if err != nil { 945 941 l.Error("failed to get current profile record", "err", err) 946 942 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 964 960 965 961 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 966 962 Collection: tangled.ActorProfileNSID, 967 - Repo: user.Active.Did, 963 + Repo: user.Did, 968 964 Rkey: "self", 969 965 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 970 966 SwapRecord: getRecordResp.Cid, ··· 978 974 979 975 l.Info("successfully updated profile with avatar") 980 976 981 - profile, err := db.GetProfile(s.db, user.Active.Did) 977 + profile, err := db.GetProfile(s.db, user.Did) 982 978 if err != nil { 983 979 l.Warn("getting profile data from DB", "err", err) 984 980 } 985 981 if profile == nil { 986 - profile = &models.Profile{Did: user.Active.Did} 982 + profile = &models.Profile{Did: user.Did} 987 983 } 988 984 profile.Avatar = uploadBlobResp.Blob.Ref.String() 989 985 ··· 1009 1005 func (s *State) RemoveProfileAvatar(w http.ResponseWriter, r *http.Request) { 1010 1006 l := s.logger.With("handler", "RemoveProfileAvatar") 1011 1007 user := s.oauth.GetMultiAccountUser(r) 1012 - l = l.With("did", user.Active.Did) 1008 + l = l.With("did", user.Did) 1013 1009 1014 1010 client, err := s.oauth.AuthorizedClient(r) 1015 1011 if err != nil { ··· 1018 1014 return 1019 1015 } 1020 1016 1021 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 1017 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 1022 1018 if err != nil { 1023 1019 l.Error("failed to get current profile record", "err", err) 1024 1020 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 1042 1038 1043 1039 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 1044 1040 Collection: tangled.ActorProfileNSID, 1045 - Repo: user.Active.Did, 1041 + Repo: user.Did, 1046 1042 Rkey: "self", 1047 1043 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 1048 1044 SwapRecord: getRecordResp.Cid, ··· 1056 1052 1057 1053 l.Info("successfully removed avatar from PDS") 1058 1054 1059 - profile, err := db.GetProfile(s.db, user.Active.Did) 1055 + profile, err := db.GetProfile(s.db, user.Did) 1060 1056 if err != nil { 1061 1057 l.Warn("getting profile data from DB", "err", err) 1062 1058 } 1063 1059 if profile == nil { 1064 - profile = &models.Profile{Did: user.Active.Did} 1060 + profile = &models.Profile{Did: user.Did} 1065 1061 } 1066 1062 profile.Avatar = "" 1067 1063 ··· 1103 1099 hideOthers = true 1104 1100 } 1105 1101 1106 - err = db.UpsertPunchcardPreference(s.db, user.Active.Did, hideMine, hideOthers) 1102 + err = db.UpsertPunchcardPreference(s.db, user.Did, hideMine, hideOthers) 1107 1103 if err != nil { 1108 1104 l.Error("failed to update punchcard preferences", "err", err) 1109 1105 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 l.Error("failed to react", "err", 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 - l.Error("failed to get reaction relationship", "did", currentUser.Active.Did, "subjectUri", subjectUri, "err", err) 92 + l.Error("failed to get reaction relationship", "did", currentUser.Did, "subjectUri", subjectUri, "err", err) 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 l.Warn("failed to delete reaction from DB", "err", err) 110 110 // this is not an issue, the firehose event might have already done this
+5 -5
appview/state/star.go
··· 56 56 57 57 resp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 58 58 Collection: tangled.FeedStarNSID, 59 - Repo: currentUser.Active.Did, 59 + Repo: currentUser.Did, 60 60 Rkey: rkey, 61 61 Record: &lexutil.LexiconTypeDecoder{Val: starRecord}, 62 62 }) ··· 67 67 l.Info("created atproto record", "uri", resp.Uri) 68 68 69 69 star := &models.Star{ 70 - Did: currentUser.Active.Did, 70 + Did: currentUser.Did, 71 71 RepoAt: subjectUri, 72 72 Rkey: rkey, 73 73 } ··· 95 95 return 96 96 case http.MethodDelete: 97 97 // find the record in the db 98 - star, err := db.GetStar(s.db, currentUser.Active.Did, subjectUri) 98 + star, err := db.GetStar(s.db, currentUser.Did, subjectUri) 99 99 if err != nil { 100 100 l.Error("failed to get star relationship", "err", err) 101 101 return ··· 103 103 104 104 _, err = comatproto.RepoDeleteRecord(r.Context(), client, &comatproto.RepoDeleteRecord_Input{ 105 105 Collection: tangled.FeedStarNSID, 106 - Repo: currentUser.Active.Did, 106 + Repo: currentUser.Did, 107 107 Rkey: star.Rkey, 108 108 }) 109 109 ··· 112 112 return 113 113 } 114 114 115 - err = db.DeleteStarByRkey(s.db, currentUser.Active.Did, star.Rkey) 115 + err = db.DeleteStarByRkey(s.db, currentUser.Did, star.Rkey) 116 116 if err != nil { 117 117 l.Warn("failed to delete star from DB", "err", err) 118 118 // this is not an issue, the firehose event might have already done this
+13 -13
appview/state/state.go
··· 286 286 } 287 287 288 288 l := s.logger.With("handler", "UpgradeBanner") 289 - l = l.With("did", user.Active.Did) 289 + l = l.With("did", user.Did) 290 290 291 291 regs, err := db.GetRegistrations( 292 292 s.db, 293 - orm.FilterEq("did", user.Active.Did), 293 + orm.FilterEq("did", user.Did), 294 294 orm.FilterEq("needs_upgrade", 1), 295 295 ) 296 296 if err != nil { ··· 300 300 spindles, err := db.GetSpindles( 301 301 r.Context(), 302 302 s.db, 303 - orm.FilterEq("owner", user.Active.Did), 303 + orm.FilterEq("owner", user.Did), 304 304 orm.FilterEq("needs_upgrade", 1), 305 305 ) 306 306 if err != nil { ··· 390 390 switch r.Method { 391 391 case http.MethodGet: 392 392 user := s.oauth.GetMultiAccountUser(r) 393 - knots, err := s.enforcer.GetKnotsForUser(user.Active.Did) 393 + knots, err := s.enforcer.GetKnotsForUser(user.Did) 394 394 if err != nil { 395 395 s.pages.Notice(w, "repo", "Invalid user account.") 396 396 return ··· 405 405 l := s.logger.With("handler", "NewRepo") 406 406 407 407 user := s.oauth.GetMultiAccountUser(r) 408 - l = l.With("did", user.Active.Did) 408 + l = l.With("did", user.Did) 409 409 410 410 // form validation 411 411 domain := r.FormValue("domain") ··· 441 441 } 442 442 443 443 // ACL validation 444 - ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create") 444 + ok, err := s.enforcer.E.Enforce(user.Did, domain, domain, "repo:create") 445 445 if err != nil || !ok { 446 446 l.Info("unauthorized") 447 447 s.pages.Notice(w, "repo", "You do not have permission to create a repo in this knot.") ··· 451 451 // Check for existing repos 452 452 existingRepo, err := db.GetRepo( 453 453 s.db, 454 - orm.FilterEq("did", user.Active.Did), 454 + orm.FilterEq("did", user.Did), 455 455 orm.FilterEq("name", repoName), 456 456 ) 457 457 if err == nil && existingRepo != nil { ··· 501 501 } 502 502 503 503 repo := &models.Repo{ 504 - Did: user.Active.Did, 504 + Did: user.Did, 505 505 Name: repoName, 506 506 Knot: domain, 507 507 Rkey: rkey, ··· 529 529 } 530 530 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) 531 531 if dErr := tangled.RepoDelete(ctx, deleteClient, &tangled.RepoDelete_Input{ 532 - Did: user.Active.Did, 532 + Did: user.Did, 533 533 Name: repoName, 534 534 Rkey: rkey, 535 535 }); dErr != nil { ··· 542 542 return 543 543 } 544 544 l.Error("exhausted retries for knot cleanup, repo may be orphaned", 545 - "did", user.Active.Did, "repo", repoName, "knot", domain) 545 + "did", user.Did, "repo", repoName, "knot", domain) 546 546 }() 547 547 } 548 548 ··· 556 556 557 557 atresp, err := comatproto.RepoPutRecord(r.Context(), atpClient, &comatproto.RepoPutRecord_Input{ 558 558 Collection: tangled.RepoNSID, 559 - Repo: user.Active.Did, 559 + Repo: user.Did, 560 560 Rkey: rkey, 561 561 Record: &lexutil.LexiconTypeDecoder{ 562 562 Val: &record, ··· 607 607 } 608 608 609 609 rbacPath := repo.RepoIdentifier() 610 - err = s.enforcer.AddRepo(user.Active.Did, domain, rbacPath) 610 + err = s.enforcer.AddRepo(user.Did, domain, rbacPath) 611 611 if err != nil { 612 612 l.Error("acl setup failed", "err", err) 613 613 s.pages.Notice(w, "repo", "Failed to set up repository permissions.") ··· 634 634 if repoDid != "" { 635 635 s.pages.HxLocation(w, fmt.Sprintf("/%s", repoDid)) 636 636 } else { 637 - s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Active.Did, repoName)) 637 + s.pages.HxLocation(w, fmt.Sprintf("/%s/%s", user.Did, repoName)) 638 638 } 639 639 } 640 640 }
+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) {