mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
feat: allow to configure custom api url for relay and import (resolve #105)
This commit is contained in:
@@ -29,7 +29,8 @@ type User struct {
|
||||
ShareLabels bool `json:"-" gorm:"default:false; type:bool"`
|
||||
IsAdmin bool `json:"-" gorm:"default:false; type:bool"`
|
||||
HasData bool `json:"-" gorm:"default:false; type:bool"`
|
||||
WakatimeApiKey string `json:"-"`
|
||||
WakatimeApiKey string `json:"-"` // for relay middleware and imports
|
||||
WakatimeApiUrl string `json:"-"` // for relay middleware and imports
|
||||
ResetToken string `json:"-"`
|
||||
ReportsWeekly bool `json:"-" gorm:"default:false; type:bool"`
|
||||
}
|
||||
@@ -109,6 +110,14 @@ func (u *User) AvatarURL(urlTemplate string) string {
|
||||
return urlTemplate
|
||||
}
|
||||
|
||||
// WakaTimeURL returns the user's effective WakaTime URL, i.e. a custom one (which could also point to another Wakapi instance) or fallback if not specified otherwise.
|
||||
func (u *User) WakaTimeURL(fallback string) string {
|
||||
if u.WakatimeApiUrl != "" {
|
||||
return strings.TrimSuffix(u.WakatimeApiUrl, "/")
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func (c *CredentialsReset) IsValid() bool {
|
||||
return ValidatePassword(c.PasswordNew) &&
|
||||
c.PasswordNew == c.PasswordRepeat
|
||||
|
Reference in New Issue
Block a user