diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-03-28 16:25:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-28 16:25:26 +0100 |
commit | 7972915806348847ecd9a9b8a1b1ff0609cb883c (patch) | |
tree | dfbf719e8229dc4faeef133b150b2d7a6dc7eac8 /userapi/storage/postgres/profile_table.go | |
parent | 0692be44d91a42945dde0eab3e2f7481cc2e0896 (diff) |
User directory for nearby Pinecone peers (P2P demo) (#2311)
* User directory for nearby Pinecone peers
* Fix mux routing
* Use config to determine which server notices user to exclude
Diffstat (limited to 'userapi/storage/postgres/profile_table.go')
-rw-r--r-- | userapi/storage/postgres/profile_table.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/userapi/storage/postgres/profile_table.go b/userapi/storage/postgres/profile_table.go index 32a4b550..6d336eb8 100644 --- a/userapi/storage/postgres/profile_table.go +++ b/userapi/storage/postgres/profile_table.go @@ -53,6 +53,7 @@ const selectProfilesBySearchSQL = "" + "SELECT localpart, display_name, avatar_url FROM account_profiles WHERE localpart LIKE $1 OR display_name LIKE $1 LIMIT $2" type profilesStatements struct { + serverNoticesLocalpart string insertProfileStmt *sql.Stmt selectProfileByLocalpartStmt *sql.Stmt setAvatarURLStmt *sql.Stmt @@ -60,8 +61,10 @@ type profilesStatements struct { selectProfilesBySearchStmt *sql.Stmt } -func NewPostgresProfilesTable(db *sql.DB) (tables.ProfileTable, error) { - s := &profilesStatements{} +func NewPostgresProfilesTable(db *sql.DB, serverNoticesLocalpart string) (tables.ProfileTable, error) { + s := &profilesStatements{ + serverNoticesLocalpart: serverNoticesLocalpart, + } _, err := db.Exec(profilesSchema) if err != nil { return nil, err @@ -126,7 +129,9 @@ func (s *profilesStatements) SelectProfilesBySearch( if err := rows.Scan(&profile.Localpart, &profile.DisplayName, &profile.AvatarURL); err != nil { return nil, err } - profiles = append(profiles, profile) + if profile.Localpart != s.serverNoticesLocalpart { + profiles = append(profiles, profile) + } } return profiles, nil } |