Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/models: move db.Email into models

Signed-off-by: oppiliappan <me@oppi.li>

+37 -28
+16 -25
appview/db/email.go
··· 3 3 import ( 4 4 "strings" 5 5 "time" 6 + 7 + "tangled.org/core/appview/models" 6 8 ) 7 9 8 - type Email struct { 9 - ID int64 10 - Did string 11 - Address string 12 - Verified bool 13 - Primary bool 14 - VerificationCode string 15 - LastSent *time.Time 16 - CreatedAt time.Time 17 - } 18 - 19 - func GetPrimaryEmail(e Execer, did string) (Email, error) { 10 + func GetPrimaryEmail(e Execer, did string) (models.Email, error) { 20 11 query := ` 21 12 select id, did, email, verified, is_primary, verification_code, last_sent, created 22 13 from emails 23 14 where did = ? and is_primary = true 24 15 ` 25 - var email Email 16 + var email models.Email 26 17 var createdStr string 27 18 var lastSent string 28 19 err := e.QueryRow(query, did).Scan(&email.ID, &email.Did, &email.Address, &email.Verified, &email.Primary, &email.VerificationCode, &lastSent, &createdStr) 29 20 if err != nil { 30 - return Email{}, err 21 + return models.Email{}, err 31 22 } 32 23 email.CreatedAt, err = time.Parse(time.RFC3339, createdStr) 33 24 if err != nil { 34 - return Email{}, err 25 + return models.Email{}, err 35 26 } 36 27 parsedTime, err := time.Parse(time.RFC3339, lastSent) 37 28 if err != nil { 38 - return Email{}, err 29 + return models.Email{}, err 39 30 } 40 31 email.LastSent = &parsedTime 41 32 return email, nil 42 33 } 43 34 44 - func GetEmail(e Execer, did string, em string) (Email, error) { 35 + func GetEmail(e Execer, did string, em string) (models.Email, error) { 45 36 query := ` 46 37 select id, did, email, verified, is_primary, verification_code, last_sent, created 47 38 from emails 48 39 where did = ? and email = ? 49 40 ` 50 - var email Email 41 + var email models.Email 51 42 var createdStr string 52 43 var lastSent string 53 44 err := e.QueryRow(query, did, em).Scan(&email.ID, &email.Did, &email.Address, &email.Verified, &email.Primary, &email.VerificationCode, &lastSent, &createdStr) 54 45 if err != nil { 55 - return Email{}, err 46 + return models.Email{}, err 56 47 } 57 48 email.CreatedAt, err = time.Parse(time.RFC3339, createdStr) 58 49 if err != nil { 59 - return Email{}, err 50 + return models.Email{}, err 60 51 } 61 52 parsedTime, err := time.Parse(time.RFC3339, lastSent) 62 53 if err != nil { 63 - return Email{}, err 54 + return models.Email{}, err 64 55 } 65 56 email.LastSent = &parsedTime 66 57 return email, nil ··· 178 187 return count > 0, nil 179 188 } 180 189 181 - func AddEmail(e Execer, email Email) error { 190 + func AddEmail(e Execer, email models.Email) error { 182 191 // Check if this is the first email for this DID 183 192 countQuery := ` 184 193 select count(*) ··· 245 254 return err 246 255 } 247 256 248 - func GetAllEmails(e Execer, did string) ([]Email, error) { 257 + func GetAllEmails(e Execer, did string) ([]models.Email, error) { 249 258 query := ` 250 259 select did, email, verified, is_primary, verification_code, last_sent, created 251 260 from emails ··· 257 266 } 258 267 defer rows.Close() 259 268 260 - var emails []Email 269 + var emails []models.Email 261 270 for rows.Next() { 262 - var email Email 271 + var email models.Email 263 272 var createdStr string 264 273 var lastSent string 265 274 err := rows.Scan(&email.Did, &email.Address, &email.Verified, &email.Primary, &email.VerificationCode, &lastSent, &createdStr)
+16
appview/models/email.go
··· 1 + package models 2 + 3 + import ( 4 + "time" 5 + ) 6 + 7 + type Email struct { 8 + ID int64 9 + Did string 10 + Address string 11 + Verified bool 12 + Primary bool 13 + VerificationCode string 14 + LastSent *time.Time 15 + CreatedAt time.Time 16 + }
+1 -1
appview/pages/pages.go
··· 314 314 315 315 type UserEmailsSettingsParams struct { 316 316 LoggedInUser *oauth.User 317 - Emails []db.Email 317 + Emails []models.Email 318 318 Tabs []map[string]any 319 319 Tab string 320 320 }
+2 -1
appview/settings/settings.go
··· 16 16 "tangled.org/core/appview/db" 17 17 "tangled.org/core/appview/email" 18 18 "tangled.org/core/appview/middleware" 19 + "tangled.org/core/appview/models" 19 20 "tangled.org/core/appview/oauth" 20 21 "tangled.org/core/appview/pages" 21 22 "tangled.org/core/tid" ··· 186 185 } 187 186 defer tx.Rollback() 188 187 189 - if err := db.AddEmail(tx, db.Email{ 188 + if err := db.AddEmail(tx, models.Email{ 190 189 Did: did, 191 190 Address: emAddr, 192 191 Verified: false,
+2 -1
appview/signup/signup.go
··· 14 14 "tangled.org/core/appview/db" 15 15 "tangled.org/core/appview/dns" 16 16 "tangled.org/core/appview/email" 17 + "tangled.org/core/appview/models" 17 18 "tangled.org/core/appview/pages" 18 19 "tangled.org/core/appview/state/userutil" 19 20 "tangled.org/core/appview/xrpcclient" ··· 230 229 return 231 230 } 232 231 233 - err = db.AddEmail(s.db, db.Email{ 232 + err = db.AddEmail(s.db, models.Email{ 234 233 Did: did, 235 234 Address: email, 236 235 Verified: true,