Monorepo for Tangled tangled.org

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

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>

boltless.me 79ba72a6 ae3c8205

verified
+9 -11
-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
··· 237 238 type User struct { 239 Did string 240 - Pds string 241 } 242 243 func (o *OAuth) GetUser(r *http.Request) *User { ··· 248 249 return &User{ 250 Did: sess.Data.AccountDID.String(), 251 - Pds: sess.Data.HostURL, 252 } 253 } 254
··· 237 238 type User struct { 239 Did string 240 } 241 242 func (o *OAuth) GetUser(r *http.Request) *User { ··· 247 248 return &User{ 249 Did: sess.Data.AccountDID.String(), 250 } 251 } 252
+7
appview/pages/funcmap.go
··· 77 78 return identity.Handle.String() 79 }, 80 "ownerSlashRepo": func(repo *models.Repo) string { 81 ownerId, err := p.resolver.ResolveIdent(context.Background(), repo.Did) 82 if err != nil {
··· 77 78 return identity.Handle.String() 79 }, 80 + "resolvePds": func(s string) string { 81 + identity, err := p.resolver.ResolveIdent(context.Background(), s) 82 + if err != nil { 83 + return "" 84 + } 85 + return identity.PDSEndpoint() 86 + }, 87 "ownerSlashRepo": func(repo *models.Repo) string { 88 ownerId, err := p.resolver.ResolveIdent(context.Background(), repo.Did) 89 if err != nil {
+1 -1
appview/pages/templates/user/settings/profile.html
··· 34 </div> 35 <div class="flex flex-col gap-1 p-4"> 36 <span class="text-sm text-gray-500 dark:text-gray-400">Personal Data Server (PDS)</span> 37 - <span class="font-bold">{{ .LoggedInUser.Pds }}</span> 38 </div> 39 </div> 40 </div>
··· 34 </div> 35 <div class="flex flex-col gap-1 p-4"> 36 <span class="text-sm text-gray-500 dark:text-gray-400">Personal Data Server (PDS)</span> 37 + <span class="font-bold">{{ resolvePds .LoggedInUser.Did }}</span> 38 </div> 39 </div> 40 </div>