Monorepo for Tangled

appview/{db,models}: add avatar to profile

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

authored by

Anirudh Oppiliappan and committed by tangled.org 332c39c6 1a682db3

+20 -4
+9 -1
appview/db/db.go
··· 260 did text not null, 261 262 -- data 263 description text not null, 264 include_bluesky integer not null default 0, 265 location text, ··· 1078 // transfer data, constructing pull_at from pulls table 1079 _, err = tx.Exec(` 1080 insert into pull_submissions_new (id, pull_at, round_number, patch, created) 1081 - select 1082 ps.id, 1083 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, 1084 ps.round_number, ··· 1169 1170 create index if not exists idx_stars_created on stars(created); 1171 create index if not exists idx_stars_subject_at_created on stars(subject_at, created); 1172 `) 1173 return err 1174 })
··· 260 did text not null, 261 262 -- data 263 + avatar text, 264 description text not null, 265 include_bluesky integer not null default 0, 266 location text, ··· 1079 // transfer data, constructing pull_at from pulls table 1080 _, err = tx.Exec(` 1081 insert into pull_submissions_new (id, pull_at, round_number, patch, created) 1082 + select 1083 ps.id, 1084 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, 1085 ps.round_number, ··· 1170 1171 create index if not exists idx_stars_created on stars(created); 1172 create index if not exists idx_stars_subject_at_created on stars(subject_at, created); 1173 + `) 1174 + return err 1175 + }) 1176 + 1177 + orm.RunMigration(conn, logger, "add-avatar-to-profile", func(tx *sql.Tx) error { 1178 + _, err := tx.Exec(` 1179 + alter table profile add column avatar text; 1180 `) 1181 return err 1182 })
+10 -3
appview/db/profile.go
··· 158 _, err = tx.Exec( 159 `insert or replace into profile ( 160 did, 161 description, 162 include_bluesky, 163 location, 164 pronouns 165 ) 166 - values (?, ?, ?, ?, ?)`, 167 profile.Did, 168 profile.Description, 169 includeBskyValue, 170 profile.Location, ··· 347 func GetProfile(e Execer, did string) (*models.Profile, error) { 348 var profile models.Profile 349 var pronouns sql.Null[string] 350 351 profile.Did = did 352 353 includeBluesky := 0 354 355 err := e.QueryRow( 356 - `select description, include_bluesky, location, pronouns from profile where did = ?`, 357 did, 358 - ).Scan(&profile.Description, &includeBluesky, &profile.Location, &pronouns) 359 if err == sql.ErrNoRows { 360 profile := models.Profile{} 361 profile.Did = did ··· 372 373 if pronouns.Valid { 374 profile.Pronouns = pronouns.V 375 } 376 377 rows, err := e.Query(`select link from profile_links where did = ?`, did)
··· 158 _, err = tx.Exec( 159 `insert or replace into profile ( 160 did, 161 + avatar, 162 description, 163 include_bluesky, 164 location, 165 pronouns 166 ) 167 + values (?, ?, ?, ?, ?, ?)`, 168 profile.Did, 169 + profile.Avatar, 170 profile.Description, 171 includeBskyValue, 172 profile.Location, ··· 349 func GetProfile(e Execer, did string) (*models.Profile, error) { 350 var profile models.Profile 351 var pronouns sql.Null[string] 352 + var avatar sql.Null[string] 353 354 profile.Did = did 355 356 includeBluesky := 0 357 358 err := e.QueryRow( 359 + `select avatar, description, include_bluesky, location, pronouns from profile where did = ?`, 360 did, 361 + ).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns) 362 if err == sql.ErrNoRows { 363 profile := models.Profile{} 364 profile.Did = did ··· 375 376 if pronouns.Valid { 377 profile.Pronouns = pronouns.V 378 + } 379 + 380 + if avatar.Valid { 381 + profile.Avatar = avatar.V 382 } 383 384 rows, err := e.Query(`select link from profile_links where did = ?`, did)
+1
appview/models/profile.go
··· 13 Did string 14 15 // data 16 Description string 17 IncludeBluesky bool 18 Location string
··· 13 Did string 14 15 // data 16 + Avatar string // CID of the avatar blob 17 Description string 18 IncludeBluesky bool 19 Location string