sync/structs/config.go

59 lines
1.8 KiB
Go

package structs
type SyncData struct {
Followers []FanslyFollowResponse `json:"followers"` // List of followers
Subscriptions []Subscription `json:"subscriptions"` // List of subscriptions
}
type Config struct {
Version int // The version of the config file
IsFirstRun bool // Is this the first run of the application
FanslyAccessToken string // The access token for the Fansly API
AutoSyncEnabled bool // Is auto-sync enabled
SyncToken string // The token used for syncing
SyncInterval int // The interval for syncing in hours
LastSyncTime string // The last time the sync was performed
LastSyncData SyncData // The data from the last sync
}
type OldConfig struct {
Version int `json:"version"`
IsFirstRun bool `json:"is_first_run"`
FanslyToken string `json:"fansly_token"`
AutoSyncEnabled bool `json:"auto_sync_enabled"`
SyncToken string `json:"sync_token"`
SyncInterval int `json:"sync_interval"`
}
func NewConfig() *Config {
return &Config{
Version: 3,
IsFirstRun: true,
FanslyAccessToken: "",
AutoSyncEnabled: false,
SyncToken: "",
SyncInterval: 8,
LastSyncTime: "",
LastSyncData: SyncData{
Followers: []FanslyFollowResponse{},
Subscriptions: []Subscription{},
},
}
}
func NewConfigFromOld(oldConfig *OldConfig) *Config {
return &Config{
Version: 3,
IsFirstRun: oldConfig.IsFirstRun,
FanslyAccessToken: oldConfig.FanslyToken,
AutoSyncEnabled: oldConfig.AutoSyncEnabled,
SyncToken: oldConfig.SyncToken,
SyncInterval: oldConfig.SyncInterval,
LastSyncTime: "",
LastSyncData: SyncData{
Followers: []FanslyFollowResponse{},
Subscriptions: []Subscription{},
},
}
}