Monorepo for Tangled tangled.org

appview/oauth: remove .Handle from oauth.AccountInfo #1025

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

We should resolve handle on render and we are already doing that. Removing the unused field.

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/3mdcq5ouzgr22
+9 -15
Diff #2
-3
appview/oauth/accounts.go
··· 13 14 type AccountInfo struct { 15 Did string `json:"did"` 16 - Handle string `json:"handle"` 17 SessionId string `json:"session_id"` 18 AddedAt int64 `json:"added_at"` 19 } ··· 74 for i, acc := range r.Accounts { 75 if acc.Did == did { 76 r.Accounts[i].SessionId = sessionId 77 - r.Accounts[i].Handle = handle 78 return nil 79 } 80 } ··· 85 86 r.Accounts = append(r.Accounts, AccountInfo{ 87 Did: did, 88 - Handle: handle, 89 SessionId: sessionId, 90 AddedAt: time.Now().Unix(), 91 })
··· 13 14 type AccountInfo struct { 15 Did string `json:"did"` 16 SessionId string `json:"session_id"` 17 AddedAt int64 `json:"added_at"` 18 } ··· 73 for i, acc := range r.Accounts { 74 if acc.Did == did { 75 r.Accounts[i].SessionId = sessionId 76 return nil 77 } 78 } ··· 83 84 r.Accounts = append(r.Accounts, AccountInfo{ 85 Did: did, 86 SessionId: sessionId, 87 AddedAt: time.Now().Unix(), 88 })
+9 -12
appview/oauth/accounts_test.go
··· 28 { 29 name: "add second account", 30 initial: []AccountInfo{ 31 - {Did: "did:plc:abc123", Handle: "alice.bsky.social", SessionId: "session-1", AddedAt: 1000}, 32 }, 33 addDid: "did:plc:def456", 34 addHandle: "bob.bsky.social", ··· 40 { 41 name: "update existing account session", 42 initial: []AccountInfo{ 43 - {Did: "did:plc:abc123", Handle: "alice.bsky.social", SessionId: "old-session", AddedAt: 1000}, 44 }, 45 addDid: "did:plc:abc123", 46 addHandle: "alice.bsky.social", ··· 112 { 113 name: "remove existing account", 114 initial: []AccountInfo{ 115 - {Did: "did:plc:abc123", Handle: "alice", SessionId: "s1"}, 116 - {Did: "did:plc:def456", Handle: "bob", SessionId: "s2"}, 117 }, 118 removeDid: "did:plc:abc123", 119 wantLen: 1, ··· 122 { 123 name: "remove non-existing account", 124 initial: []AccountInfo{ 125 - {Did: "did:plc:abc123", Handle: "alice", SessionId: "s1"}, 126 }, 127 removeDid: "did:plc:notfound", 128 wantLen: 1, ··· 131 { 132 name: "remove last account", 133 initial: []AccountInfo{ 134 - {Did: "did:plc:abc123", Handle: "alice", SessionId: "s1"}, 135 }, 136 removeDid: "did:plc:abc123", 137 wantLen: 0, ··· 171 func TestAccountRegistry_FindAccount(t *testing.T) { 172 registry := &AccountRegistry{ 173 Accounts: []AccountInfo{ 174 - {Did: "did:plc:first", Handle: "first", SessionId: "s1", AddedAt: 1000}, 175 - {Did: "did:plc:second", Handle: "second", SessionId: "s2", AddedAt: 2000}, 176 - {Did: "did:plc:third", Handle: "third", SessionId: "s3", AddedAt: 3000}, 177 }, 178 } 179 ··· 182 if found == nil { 183 t.Fatal("FindAccount() returned nil for existing account") 184 } 185 - if found.Handle != "second" { 186 - t.Errorf("FindAccount() handle = %s, want second", found.Handle) 187 - } 188 if found.SessionId != "s2" { 189 t.Errorf("FindAccount() sessionId = %s, want s2", found.SessionId) 190 }
··· 28 { 29 name: "add second account", 30 initial: []AccountInfo{ 31 + {Did: "did:plc:abc123", SessionId: "session-1", AddedAt: 1000}, 32 }, 33 addDid: "did:plc:def456", 34 addHandle: "bob.bsky.social", ··· 40 { 41 name: "update existing account session", 42 initial: []AccountInfo{ 43 + {Did: "did:plc:abc123", SessionId: "old-session", AddedAt: 1000}, 44 }, 45 addDid: "did:plc:abc123", 46 addHandle: "alice.bsky.social", ··· 112 { 113 name: "remove existing account", 114 initial: []AccountInfo{ 115 + {Did: "did:plc:abc123", SessionId: "s1"}, 116 + {Did: "did:plc:def456", SessionId: "s2"}, 117 }, 118 removeDid: "did:plc:abc123", 119 wantLen: 1, ··· 122 { 123 name: "remove non-existing account", 124 initial: []AccountInfo{ 125 + {Did: "did:plc:abc123", SessionId: "s1"}, 126 }, 127 removeDid: "did:plc:notfound", 128 wantLen: 1, ··· 131 { 132 name: "remove last account", 133 initial: []AccountInfo{ 134 + {Did: "did:plc:abc123", SessionId: "s1"}, 135 }, 136 removeDid: "did:plc:abc123", 137 wantLen: 0, ··· 171 func TestAccountRegistry_FindAccount(t *testing.T) { 172 registry := &AccountRegistry{ 173 Accounts: []AccountInfo{ 174 + {Did: "did:plc:first", SessionId: "s1", AddedAt: 1000}, 175 + {Did: "did:plc:second", SessionId: "s2", AddedAt: 2000}, 176 + {Did: "did:plc:third", SessionId: "s3", AddedAt: 3000}, 177 }, 178 } 179 ··· 182 if found == nil { 183 t.Fatal("FindAccount() returned nil for existing account") 184 } 185 if found.SessionId != "s2" { 186 t.Errorf("FindAccount() sessionId = %s, want s2", found.SessionId) 187 }

History

3 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/oauth: remove .Handle from oauth.AccountInfo
3/3 success
expand
merge conflicts detected
expand
  • appview/pages/templates/user/login.html:33
  • appview/state/profile.go:817
  • appview/pages/templates/user/login.html:31
  • appview/pages/templates/user/login.html:93
expand 0 comments
1 commit
expand
appview/oauth: remove .Handle from oauth.AccountInfo
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/oauth: remove .Handle from oauth.AccountInfo
2/3 failed, 1/3 success
expand
expand 0 comments