2022-09-27 17:59:05 +08:00
|
|
|
package schema
|
|
|
|
|
2022-11-10 11:00:26 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
2022-12-02 17:27:30 +08:00
|
|
|
const PermaLinkQuestionIDAndTitle = 1
|
|
|
|
const PermaLinkQuestionID = 2
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
// SiteGeneralReq site general request
|
|
|
|
type SiteGeneralReq struct {
|
2022-11-02 15:02:27 +08:00
|
|
|
Name string `validate:"required,gt=1,lte=128" form:"name" json:"name"`
|
2022-11-29 12:17:20 +08:00
|
|
|
ShortDescription string `validate:"omitempty,gt=3,lte=255" form:"short_description" json:"short_description"`
|
|
|
|
Description string `validate:"omitempty,gt=3,lte=2000" form:"description" json:"description"`
|
2022-11-07 18:03:51 +08:00
|
|
|
SiteUrl string `validate:"required,gt=1,lte=512,url" form:"site_url" json:"site_url"`
|
|
|
|
ContactEmail string `validate:"required,gt=1,lte=512,email" form:"contact_email" json:"contact_email"`
|
2022-12-02 17:27:30 +08:00
|
|
|
PermaLink int `validate:"required,lte=3,gte=0" form:"permalink" json:"permalink"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
2022-12-05 17:18:56 +08:00
|
|
|
type SiteSeoReq struct {
|
|
|
|
Robots string `validate:"required" form:"robots" json:"robots"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
2022-11-10 11:00:26 +08:00
|
|
|
func (r *SiteGeneralReq) FormatSiteUrl() {
|
|
|
|
parsedUrl, err := url.Parse(r.SiteUrl)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
r.SiteUrl = fmt.Sprintf("%s://%s", parsedUrl.Scheme, parsedUrl.Host)
|
|
|
|
}
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
// SiteInterfaceReq site interface request
|
|
|
|
type SiteInterfaceReq struct {
|
2022-11-02 15:02:27 +08:00
|
|
|
Theme string `validate:"required,gt=1,lte=128" form:"theme" json:"theme"`
|
|
|
|
Language string `validate:"required,gt=1,lte=128" form:"language" json:"language"`
|
2022-11-10 13:02:19 +08:00
|
|
|
TimeZone string `validate:"required,gt=1,lte=128" form:"time_zone" json:"time_zone"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
2022-11-14 11:50:00 +08:00
|
|
|
// SiteBrandingReq site branding request
|
|
|
|
type SiteBrandingReq struct {
|
2022-11-14 14:56:56 +08:00
|
|
|
Logo string `validate:"required,gt=0,lte=512" form:"logo" json:"logo"`
|
2022-11-14 11:50:00 +08:00
|
|
|
MobileLogo string `validate:"omitempty,gt=0,lte=512" form:"mobile_logo" json:"mobile_logo"`
|
|
|
|
SquareIcon string `validate:"required,gt=0,lte=512" form:"square_icon" json:"square_icon"`
|
|
|
|
Favicon string `validate:"omitempty,gt=0,lte=512" form:"favicon" json:"favicon"`
|
|
|
|
}
|
|
|
|
|
2022-11-14 15:17:49 +08:00
|
|
|
// SiteWriteReq site write request
|
|
|
|
type SiteWriteReq struct {
|
2022-11-16 15:02:11 +08:00
|
|
|
RequiredTag bool `validate:"omitempty" form:"required_tag" json:"required_tag"`
|
2022-11-16 14:39:58 +08:00
|
|
|
RecommendTags []string `validate:"omitempty" form:"recommend_tags" json:"recommend_tags"`
|
|
|
|
ReservedTags []string `validate:"omitempty" form:"reserved_tags" json:"reserved_tags"`
|
2022-11-15 11:24:39 +08:00
|
|
|
UserID string `json:"-"`
|
2022-11-14 15:17:49 +08:00
|
|
|
}
|
|
|
|
|
2022-11-14 17:04:25 +08:00
|
|
|
// SiteLegalReq site branding request
|
|
|
|
type SiteLegalReq struct {
|
2022-11-15 17:07:50 +08:00
|
|
|
TermsOfServiceOriginalText string `json:"terms_of_service_original_text"`
|
|
|
|
TermsOfServiceParsedText string `json:"terms_of_service_parsed_text"`
|
|
|
|
PrivacyPolicyOriginalText string `json:"privacy_policy_original_text"`
|
|
|
|
PrivacyPolicyParsedText string `json:"privacy_policy_parsed_text"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSiteLegalInfoReq site site legal request
|
|
|
|
type GetSiteLegalInfoReq struct {
|
|
|
|
InfoType string `validate:"required,oneof=tos privacy" form:"info_type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetSiteLegalInfoReq) IsTOS() bool {
|
|
|
|
return r.InfoType == "tos"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetSiteLegalInfoReq) IsPrivacy() bool {
|
|
|
|
return r.InfoType == "privacy"
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSiteLegalInfoResp get site legal info response
|
|
|
|
type GetSiteLegalInfoResp struct {
|
|
|
|
TermsOfServiceOriginalText string `json:"terms_of_service_original_text,omitempty"`
|
|
|
|
TermsOfServiceParsedText string `json:"terms_of_service_parsed_text,omitempty"`
|
|
|
|
PrivacyPolicyOriginalText string `json:"privacy_policy_original_text,omitempty"`
|
|
|
|
PrivacyPolicyParsedText string `json:"privacy_policy_parsed_text,omitempty"`
|
2022-11-14 17:04:25 +08:00
|
|
|
}
|
|
|
|
|
2022-12-07 15:21:05 +08:00
|
|
|
// SiteLoginReq site login request
|
|
|
|
type SiteLoginReq struct {
|
|
|
|
AllowNewRegistrations bool `json:"allow_new_registrations"`
|
|
|
|
LoginRequired bool `json:"login_required"`
|
|
|
|
}
|
|
|
|
|
2022-12-09 14:20:50 +08:00
|
|
|
// SiteCustomCssHTMLReq site custom css html
|
|
|
|
type SiteCustomCssHTMLReq struct {
|
|
|
|
CustomHead string `validate:"omitempty,gt=0,lte=65536" json:"custom_head"`
|
|
|
|
CustomCss string `validate:"omitempty,gt=0,lte=65536" json:"custom_css"`
|
|
|
|
CustomHeader string `validate:"omitempty,gt=0,lte=65536" json:"custom_header"`
|
|
|
|
CustomFooter string `validate:"omitempty,gt=0,lte=65536" json:"custom_footer"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// SiteThemeReq site theme config
|
|
|
|
type SiteThemeReq struct {
|
|
|
|
Theme string `validate:"required,gt=0,lte=255" json:"theme"`
|
|
|
|
ThemeConfig map[string]interface{} `validate:"omitempty" json:"theme_config"`
|
|
|
|
}
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
// SiteGeneralResp site general response
|
|
|
|
type SiteGeneralResp SiteGeneralReq
|
|
|
|
|
|
|
|
// SiteInterfaceResp site interface response
|
|
|
|
type SiteInterfaceResp SiteInterfaceReq
|
|
|
|
|
2022-11-14 11:50:00 +08:00
|
|
|
// SiteBrandingResp site branding response
|
|
|
|
type SiteBrandingResp SiteBrandingReq
|
|
|
|
|
2022-12-07 15:21:05 +08:00
|
|
|
// SiteLoginResp site login response
|
|
|
|
type SiteLoginResp SiteLoginReq
|
|
|
|
|
2022-12-09 14:20:50 +08:00
|
|
|
// SiteCustomCssHTMLResp site custom css html response
|
|
|
|
type SiteCustomCssHTMLResp SiteCustomCssHTMLReq
|
|
|
|
|
|
|
|
// SiteThemeResp site theme response
|
|
|
|
type SiteThemeResp SiteThemeReq
|
|
|
|
|
2022-11-14 15:17:49 +08:00
|
|
|
// SiteWriteResp site write response
|
|
|
|
type SiteWriteResp SiteWriteReq
|
|
|
|
|
2022-11-14 17:04:25 +08:00
|
|
|
// SiteLegalResp site write response
|
|
|
|
type SiteLegalResp SiteLegalReq
|
|
|
|
|
2022-12-09 14:20:50 +08:00
|
|
|
// SiteSeoResp site write response
|
2022-12-05 17:18:56 +08:00
|
|
|
type SiteSeoResp SiteSeoReq
|
|
|
|
|
2022-11-14 11:50:00 +08:00
|
|
|
// SiteInfoResp get site info response
|
2022-09-27 17:59:05 +08:00
|
|
|
type SiteInfoResp struct {
|
2022-11-14 11:50:00 +08:00
|
|
|
General *SiteGeneralResp `json:"general"`
|
|
|
|
Interface *SiteInterfaceResp `json:"interface"`
|
|
|
|
Branding *SiteBrandingResp `json:"branding"`
|
2022-12-07 15:21:05 +08:00
|
|
|
Login *SiteLoginResp `json:"login"`
|
2022-12-09 14:20:50 +08:00
|
|
|
Theme *SiteThemeResp `json:"theme"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
2022-11-30 18:10:38 +08:00
|
|
|
type TemplateSiteInfoResp struct {
|
2022-12-06 12:17:45 +08:00
|
|
|
General *SiteGeneralResp `json:"general"`
|
|
|
|
Interface *SiteInterfaceResp `json:"interface"`
|
|
|
|
Branding *SiteBrandingResp `json:"branding"`
|
|
|
|
Year string
|
|
|
|
Canonical string
|
|
|
|
JsonLD string
|
|
|
|
Keywords string
|
|
|
|
Description string
|
2022-11-30 18:10:38 +08:00
|
|
|
}
|
2022-10-20 16:38:56 +08:00
|
|
|
|
|
|
|
// UpdateSMTPConfigReq get smtp config request
|
|
|
|
type UpdateSMTPConfigReq struct {
|
2022-10-21 17:04:41 +08:00
|
|
|
FromEmail string `validate:"omitempty,gt=0,lte=256" json:"from_email"`
|
|
|
|
FromName string `validate:"omitempty,gt=0,lte=256" json:"from_name"`
|
|
|
|
SMTPHost string `validate:"omitempty,gt=0,lte=256" json:"smtp_host"`
|
|
|
|
SMTPPort int `validate:"omitempty,min=1,max=65535" json:"smtp_port"`
|
|
|
|
Encryption string `validate:"omitempty,oneof=SSL" json:"encryption"` // "" SSL
|
|
|
|
SMTPUsername string `validate:"omitempty,gt=0,lte=256" json:"smtp_username"`
|
|
|
|
SMTPPassword string `validate:"omitempty,gt=0,lte=256" json:"smtp_password"`
|
|
|
|
SMTPAuthentication bool `validate:"omitempty" json:"smtp_authentication"`
|
|
|
|
TestEmailRecipient string `validate:"omitempty,email" json:"test_email_recipient"`
|
2022-10-20 16:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetSMTPConfigResp get smtp config response
|
|
|
|
type GetSMTPConfigResp struct {
|
2022-10-21 17:04:41 +08:00
|
|
|
FromEmail string `json:"from_email"`
|
|
|
|
FromName string `json:"from_name"`
|
|
|
|
SMTPHost string `json:"smtp_host"`
|
|
|
|
SMTPPort int `json:"smtp_port"`
|
|
|
|
Encryption string `json:"encryption"` // "" SSL
|
|
|
|
SMTPUsername string `json:"smtp_username"`
|
|
|
|
SMTPPassword string `json:"smtp_password"`
|
|
|
|
SMTPAuthentication bool `json:"smtp_authentication"`
|
2022-10-20 16:38:56 +08:00
|
|
|
}
|
2022-11-27 15:47:46 +08:00
|
|
|
|
|
|
|
// GetManifestJsonResp get manifest json response
|
|
|
|
type GetManifestJsonResp struct {
|
2022-12-08 10:06:01 +08:00
|
|
|
ManifestVersion int `json:"manifest_version"`
|
|
|
|
Version string `json:"version"`
|
2022-11-27 15:47:46 +08:00
|
|
|
ShortName string `json:"short_name"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Icons map[string]string `json:"icons"`
|
|
|
|
StartUrl string `json:"start_url"`
|
|
|
|
Display string `json:"display"`
|
|
|
|
ThemeColor string `json:"theme_color"`
|
|
|
|
BackgroundColor string `json:"background_color"`
|
|
|
|
}
|