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