This commit is contained in:
parent
08f6de0bd7
commit
5e93ecee73
12 changed files with 241 additions and 109 deletions
|
@ -158,12 +158,13 @@ func createLocalUser(w http.ResponseWriter, r *http.Request) {
|
|||
PasskeyId: pkeyId,
|
||||
}
|
||||
if data.Birthday != nil {
|
||||
user.Birthday = sql.NullTime{Valid: true, Time: *data.Birthday}
|
||||
user.Birthday = sql.NullString{Valid: true, String: data.Birthday.Format("2006-Jan-02")}
|
||||
// user.Birthday = sql.NullTime{Valid: true, Time: *data.Birthday}
|
||||
}
|
||||
if data.Location != nil {
|
||||
user.Location = sql.NullString{Valid: true, String: *data.Location}
|
||||
}
|
||||
if err = u.Create(&user); err != nil {
|
||||
if err = query.Create(&user); err != nil {
|
||||
log.Error().Err(err).Msg("failed to create new local user")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
webutils "git.mstar.dev/mstar/goutils/http"
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
"git.mstar.dev/mstar/goutils/sliceutils"
|
||||
"github.com/rs/zerolog/hlog"
|
||||
|
||||
|
@ -119,7 +118,7 @@ func users(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
if sliceutils.ContainsFunc(user.BeingTypes, func(t models.UserToBeing) bool {
|
||||
return t.Being == models.BEING_CAT
|
||||
return t.Being == string(models.BEING_CAT)
|
||||
}) {
|
||||
data.IsCat = true
|
||||
// data.SpeakAsCat = true // TODO: Move to check of separate field in db model
|
||||
|
@ -128,10 +127,16 @@ func users(w http.ResponseWriter, r *http.Request) {
|
|||
data.Location = &user.Location.String
|
||||
}
|
||||
if user.Birthday.Valid {
|
||||
data.Birthday = other.IntoPointer(user.Birthday.Time.Format("2006-Jan-02")) //YYYY-Month-DD
|
||||
data.Birthday = &user.Birthday.String
|
||||
// data.Birthday = other.IntoPointer(user.Birthday.Time.Format("2006-Jan-02")) //YYYY-Month-DD
|
||||
}
|
||||
|
||||
encoded, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to marshal response")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Add("Content-Type", "application/activity+json")
|
||||
fmt.Fprint(w, string(encoded))
|
||||
}
|
||||
|
|
|
@ -15,21 +15,21 @@ type User struct {
|
|||
// All data here will always be included, even if empty,
|
||||
// in which case it will be marked as null instead of omitted
|
||||
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ServerId uint `json:"server_id"`
|
||||
Displayname string `json:"displayname"`
|
||||
Username string `json:"username"`
|
||||
Description string `json:"description"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
IconId *string `json:"icon_id"`
|
||||
BackgroundId *string `json:"background_id"`
|
||||
BannerId *string `json:"banner_id"`
|
||||
Indexable bool `json:"indexable"`
|
||||
PublicKey []byte `json:"public_key"`
|
||||
RestrictedFollow bool `json:"restricted_follow"`
|
||||
Location *string `json:"location"`
|
||||
Birthday *time.Time `json:"birthday"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ServerId uint `json:"server_id"`
|
||||
Displayname string `json:"displayname"`
|
||||
Username string `json:"username"`
|
||||
Description string `json:"description"`
|
||||
IsBot bool `json:"is_bot"`
|
||||
IconId *string `json:"icon_id"`
|
||||
BackgroundId *string `json:"background_id"`
|
||||
BannerId *string `json:"banner_id"`
|
||||
Indexable bool `json:"indexable"`
|
||||
PublicKey []byte `json:"public_key"`
|
||||
RestrictedFollow bool `json:"restricted_follow"`
|
||||
Location *string `json:"location"`
|
||||
Birthday *string `json:"birthday"`
|
||||
|
||||
// ---- Section Debug data ----
|
||||
// All these entries should only be available
|
||||
|
@ -113,7 +113,7 @@ func (u *User) FromModel(m *models.User) {
|
|||
u.Location = &m.Location.String
|
||||
}
|
||||
if m.Birthday.Valid {
|
||||
u.Birthday = &m.Birthday.Time
|
||||
u.Birthday = &m.Birthday.String
|
||||
}
|
||||
u.Verified = &m.Verified
|
||||
u.FinishedRegistration = &m.FinishedRegistration
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue