package model import ( "encoding/json" "git.canopymc.net/Etzelia/go-mcm/internal" "git.canopymc.net/Etzelia/go-mcm/model/django" ) type Results int64 const ( Results10 Results = 10 Results25 Results = 25 Results50 Results = 50 Results100 Results = 100 ResultsAll Results = -1 ) type Theme string const ( ThemesDefault Theme = "DE" ThemesDark Theme = "DA" ThemesSolar Theme = "SO" ThemesSlate Theme = "SL" ) type UserSettings struct { ID int64 `json:"id"` AuthUserID int64 `json:"auth_user_id"` DefaultResults Results `json:"default_results"` DefaultTheme Theme `json:"default_theme"` DefaultTimezone string `json:"default_timezone"` SearchPlayerIP bool `json:"search_player_ip"` ShowTimestampChat bool `json:"show_timestamp_chat"` LastIP string `json:"last_ip"` Link string `json:"link"` model *Model `json:"-"` } func (q *Model) UserSettings(builder *django.Builder) ([]*UserSettings, error) { endpoint := q.queryEndpoint("usersettings", builder.QueryString()) userSettingss := make([]*UserSettings, 0) resp, err := internal.ResponseGet(endpoint) if err != nil { return nil, err } err = json.Unmarshal(resp, &userSettingss) if err != nil { return nil, err } for _, userSetting := range userSettingss { userSetting.model = q } return userSettingss, nil } func (u *UserSettings) Save() (*internal.Status, error) { endpoint := u.model.endpoint("usersettings") return internal.ResponseStatus(endpoint, u.model.Values(u)) }