make user creation time string

This commit is contained in:
Arya 2023-01-23 20:30:41 +05:30
parent f37252e8ba
commit a15ca30325
Signed by untrusted user: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -1,16 +1,16 @@
package pages package pages
import ( import (
"os"
"os/exec"
"regexp"
"runtime"
"strings"
"github.com/ProjectSegfault/publapi/utils" "github.com/ProjectSegfault/publapi/utils"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
"os"
"os/exec"
"regexp"
"runtime"
"strconv"
"strings"
) )
type Userstruct struct { type Userstruct struct {
@ -26,7 +26,7 @@ type Userinfo struct {
Desc string `json:"desc"` Desc string `json:"desc"`
Online bool `json:"online"` Online bool `json:"online"`
Op bool `json:"op"` Op bool `json:"op"`
Created string `json:"created"` Created int `json:"created"`
Email string `json:"email"` Email string `json:"email"`
Matrix string `json:"matrix"` Matrix string `json:"matrix"`
Fediverse string `json:"fediverse"` Fediverse string `json:"fediverse"`
@ -51,6 +51,7 @@ func userdata(username, usersonline, ops string) Userinfo {
log.Error(crerr) log.Error(crerr)
} }
crdstr := string(crd) crdstr := string(crd)
crdstr = strings.TrimSuffix(crdstr, "\n")
filename := "/home/" + username + "/meta-info.env" filename := "/home/" + username + "/meta-info.env"
_, error := os.Stat(filename) _, error := os.Stat(filename)
if error != nil { if error != nil {
@ -58,7 +59,7 @@ func userdata(username, usersonline, ops 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
user.Name = username user.Name = username
user.Created = strings.TrimSuffix(crdstr, "\n") user.Created, _ = strconv.Atoi(crdstr)
if isonline == true { if isonline == true {
user.Online = true user.Online = true
} else { } else {
@ -76,7 +77,7 @@ func userdata(username, usersonline, ops string) Userinfo {
viper.ReadInConfig() viper.ReadInConfig()
var user Userinfo var user Userinfo
user.Name = username user.Name = username
user.Created = strings.TrimSuffix(crdstr, "\n") user.Created, _ = strconv.Atoi(crdstr)
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")