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 313036db f2ac2c7e

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