Monorepo for Tangled tangled.org

appview/{oauth,pages}: cleanup unused codes #1022

open opened by boltless.me targeting master from sl/uvpzuszrulvq
  • AccountRegistry.OtherAccounts() is not used anywhere
  • Removed several legacy session value names from oauth/consts.go
  • We can just embed the oauth.GetUser() now

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/3mdcq5ouz5l22
+12 -12
Interdiff #0 #1
appview/oauth/accounts.go

This file has not been changed.

appview/oauth/accounts_test.go

This file has not been changed.

appview/oauth/consts.go

This file has not been changed.

appview/oauth/oauth.go

This file has not been changed.

appview/pages/templates/user/login.html

This file has not been changed.

+12 -12
appview/state/profile.go
··· 731 731 732 732 func (s *State) UploadProfileAvatar(w http.ResponseWriter, r *http.Request) { 733 733 l := s.logger.With("handler", "UploadProfileAvatar") 734 - user := s.oauth.GetUser(r) 735 - l = l.With("did", user.Did) 734 + user := s.oauth.GetMultiAccountUser(r) 735 + l = l.With("did", user.Active.Did) 736 736 737 737 // Parse multipart form (10MB max) 738 738 if err := r.ParseMultipartForm(10 << 20); err != nil { ··· 779 779 l.Info("uploaded avatar blob", "cid", uploadBlobResp.Blob.Ref.String()) 780 780 781 781 // get current profile record from PDS to get its CID for swap 782 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 782 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 783 783 if err != nil { 784 784 l.Error("failed to get current profile record", "err", err) 785 785 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 803 803 804 804 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 805 805 Collection: tangled.ActorProfileNSID, 806 - Repo: user.Did, 806 + Repo: user.Active.Did, 807 807 Rkey: "self", 808 808 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 809 809 SwapRecord: getRecordResp.Cid, ··· 817 817 818 818 l.Info("successfully updated profile with avatar") 819 819 820 - profile, err := db.GetProfile(s.db, user.Did) 820 + profile, err := db.GetProfile(s.db, user.Active.Did) 821 821 if err != nil { 822 822 l.Warn("getting profile data from DB", "err", err) 823 - profile = &models.Profile{Did: user.Did} 823 + profile = &models.Profile{Did: user.Active.Did} 824 824 } 825 825 profile.Avatar = uploadBlobResp.Blob.Ref.String() 826 826 ··· 845 845 846 846 func (s *State) RemoveProfileAvatar(w http.ResponseWriter, r *http.Request) { 847 847 l := s.logger.With("handler", "RemoveProfileAvatar") 848 - user := s.oauth.GetUser(r) 849 - l = l.With("did", user.Did) 848 + user := s.oauth.GetMultiAccountUser(r) 849 + l = l.With("did", user.Active.Did) 850 850 851 851 client, err := s.oauth.AuthorizedClient(r) 852 852 if err != nil { ··· 855 855 return 856 856 } 857 857 858 - getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Did, "self") 858 + getRecordResp, err := comatproto.RepoGetRecord(r.Context(), client, "", tangled.ActorProfileNSID, user.Active.Did, "self") 859 859 if err != nil { 860 860 l.Error("failed to get current profile record", "err", err) 861 861 s.pages.Notice(w, "avatar-error", "Failed to get current profile from your PDS") ··· 879 879 880 880 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 881 881 Collection: tangled.ActorProfileNSID, 882 - Repo: user.Did, 882 + Repo: user.Active.Did, 883 883 Rkey: "self", 884 884 Record: &lexutil.LexiconTypeDecoder{Val: profileRecord}, 885 885 SwapRecord: getRecordResp.Cid, ··· 893 893 894 894 l.Info("successfully removed avatar from PDS") 895 895 896 - profile, err := db.GetProfile(s.db, user.Did) 896 + profile, err := db.GetProfile(s.db, user.Active.Did) 897 897 if err != nil { 898 898 l.Warn("getting profile data from DB", "err", err) 899 - profile = &models.Profile{Did: user.Did} 899 + profile = &models.Profile{Did: user.Active.Did} 900 900 } 901 901 profile.Avatar = "" 902 902

History

3 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/{oauth,pages}: cleanup unused codes
3/3 success
expand
merge conflicts detected
expand
  • appview/pages/templates/user/login.html:33
  • appview/state/profile.go:817
expand 0 comments
1 commit
expand
appview/{oauth,pages}: cleanup unused codes
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{oauth,pages}: cleanup unused codes
2/3 failed, 1/3 success
expand
expand 0 comments