fixed user attributes for /users

This commit is contained in:
Arya Kiran 2023-01-18 22:20:51 +05:30
parent d4218382f7
commit e934aa5a92
Signed by: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 19 additions and 20 deletions

View File

@ -1,3 +1,2 @@
# TODO # TODO
- Get Users attribute to work correctly

38
main.go
View File

@ -18,14 +18,14 @@ type Userstruct struct {
Users []Userinfo Users []Userinfo
} }
type Userinfo struct { type Userinfo struct {
name string Name string
fullname string FullName string
loc string Loc string
email string Email string
desc string Desc string
website string Website string
capsule string Capsule string
online bool Online bool
} }
func Dedup(input string) string { func Dedup(input string) string {
@ -61,9 +61,9 @@ func userdata(username, usersonline string) Userinfo {
log.Error(username + " does not have a meta-info.env") log.Error(username + " does not have a meta-info.env")
var user Userinfo var user Userinfo
if strings.Contains(usersonline, " "+username) == true { if strings.Contains(usersonline, " "+username) == true {
user.online = true user.Online = true
} else { } else {
user.online = false user.Online = false
} }
return user return user
} }
@ -71,17 +71,17 @@ func userdata(username, usersonline string) Userinfo {
viper.SetConfigFile(filename) viper.SetConfigFile(filename)
viper.ReadInConfig() viper.ReadInConfig()
var user Userinfo var user Userinfo
user.name = viper.GetString("USERNAME") user.Name = viper.GetString("USERNAME")
user.fullname = viper.GetString("FULL_NAME") user.FullName = viper.GetString("FULL_NAME")
user.capsule = viper.GetString("GEMINI_CAPSULE") user.Capsule = viper.GetString("GEMINI_CAPSULE")
user.website = viper.GetString("WEBSITE") user.Website = viper.GetString("WEBSITE")
user.desc = viper.GetString("DESCRIPTION") user.Desc = viper.GetString("DESCRIPTION")
user.email = viper.GetString("EMAIL") user.Email = viper.GetString("EMAIL")
user.loc = viper.GetString("LOCATION") user.Loc = viper.GetString("LOCATION")
if strings.Contains(usersonline, " "+username) == true { if strings.Contains(usersonline, " "+username) == true {
user.online = true user.Online = true
} else { } else {
user.online = false user.Online = false
} }
return user return user
} }