a mini social media app for small communities
1module entity 2 3import time 4 5pub struct User { 6pub mut: 7 id int @[primary; sql: serial] 8 username string @[unique] 9 nickname ?string 10 11 password string 12 password_salt string 13 14 muted bool 15 admin bool 16 17 theme ?string 18 19 bio string 20 pronouns string 21 22 created_at time.Time = time.now() 23} 24 25@[inline] 26pub fn (user User) get_name() string { 27 return user.nickname or { user.username } 28} 29 30@[inline] 31pub fn (user User) get_theme() string { 32 return user.theme or { '' } 33} 34 35@[inline] 36pub fn (user User) to_str_without_sensitive_data() string { 37 return user.str() 38 .replace(user.password, '*'.repeat(16)) 39 .replace(user.password_salt, '*'.repeat(16)) 40}