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