Monorepo for Tangled tangled.org

appview/{oauth,pages}: remove Pds field from oauth.User #1028

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

The Pds field is only used to render it on settings/profile page. We can get user PDS from DID instead.

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/3mdcq5ouyxq22
+9 -11
Diff #2
-7
appview/oauth/accounts.go
··· 34 return m.Active.Did 35 } 36 37 - func (m *MultiAccountUser) Pds() string { 38 - if m.Active == nil { 39 - return "" 40 - } 41 - return m.Active.Pds 42 - } 43 - 44 func (o *OAuth) GetAccounts(r *http.Request) *AccountRegistry { 45 session, err := o.SessStore.Get(r, AccountsName) 46 if err != nil || session.IsNew {
··· 34 return m.Active.Did 35 } 36 37 func (o *OAuth) GetAccounts(r *http.Request) *AccountRegistry { 38 session, err := o.SessStore.Get(r, AccountsName) 39 if err != nil || session.IsNew {
+1 -1
appview/oauth/accounts_test.go
··· 249 func TestMultiAccountUser_Did(t *testing.T) { 250 t.Run("with active user", func(t *testing.T) { 251 user := &MultiAccountUser{ 252 - Active: &User{Did: "did:plc:test", Pds: "https://bsky.social"}, 253 } 254 if user.Did() != "did:plc:test" { 255 t.Errorf("Did() = %s, want did:plc:test", user.Did())
··· 249 func TestMultiAccountUser_Did(t *testing.T) { 250 t.Run("with active user", func(t *testing.T) { 251 user := &MultiAccountUser{ 252 + Active: &User{Did: "did:plc:test"}, 253 } 254 if user.Did() != "did:plc:test" { 255 t.Errorf("Did() = %s, want did:plc:test", user.Did())
-2
appview/oauth/oauth.go
··· 233 234 type User struct { 235 Did string 236 - Pds string 237 } 238 239 func (o *OAuth) GetUser(r *http.Request) *User { ··· 244 245 return &User{ 246 Did: sess.Data.AccountDID.String(), 247 - Pds: sess.Data.HostURL, 248 } 249 } 250
··· 233 234 type User struct { 235 Did string 236 } 237 238 func (o *OAuth) GetUser(r *http.Request) *User { ··· 243 244 return &User{ 245 Did: sess.Data.AccountDID.String(), 246 } 247 } 248
+7
appview/pages/funcmap.go
··· 76 77 return identity.Handle.String() 78 }, 79 "ownerSlashRepo": func(repo *models.Repo) string { 80 ownerId, err := p.resolver.ResolveIdent(context.Background(), repo.Did) 81 if err != nil {
··· 76 77 return identity.Handle.String() 78 }, 79 + "resolvePds": func(s string) string { 80 + identity, err := p.resolver.ResolveIdent(context.Background(), s) 81 + if err != nil { 82 + return "" 83 + } 84 + return identity.PDSEndpoint() 85 + }, 86 "ownerSlashRepo": func(repo *models.Repo) string { 87 ownerId, err := p.resolver.ResolveIdent(context.Background(), repo.Did) 88 if err != nil {
+1 -1
appview/pages/templates/user/settings/profile.html
··· 54 <span>Personal Data Server (PDS)</span> 55 </div> 56 <span class="font-bold"> 57 - {{ .LoggedInUser.Pds }} 58 </span> 59 </div> 60 </div>
··· 54 <span>Personal Data Server (PDS)</span> 55 </div> 56 <span class="font-bold"> 57 + {{ resolvePds .LoggedInUser.Did }} 58 </span> 59 </div> 60 </div>

History

3 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/{oauth,pages}: remove Pds field from oauth.User
1/3 failed, 2/3 success
expand
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview/{oauth,pages}: remove Pds field from oauth.User
1/3 failed, 2/3 success
expand
expand 0 comments
1 commit
expand
appview/{oauth,pages}: remove Pds field from oauth.User
1/3 failed, 2/3 success
expand
expand 0 comments