2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import ()
|
|
|
|
|
2019-12-28 09:13:06 +08:00
|
|
|
var domainsRowColumns = `
|
|
|
|
domains.domain,
|
|
|
|
domains.ownerHex,
|
|
|
|
domains.name,
|
|
|
|
domains.creationDate,
|
|
|
|
domains.state,
|
|
|
|
domains.importedComments,
|
|
|
|
domains.autoSpamFilter,
|
|
|
|
domains.requireModeration,
|
|
|
|
domains.requireIdentification,
|
|
|
|
domains.moderateAllAnonymous,
|
|
|
|
domains.emailNotificationPolicy,
|
|
|
|
domains.commentoProvider,
|
|
|
|
domains.googleProvider,
|
|
|
|
domains.twitterProvider,
|
|
|
|
domains.githubProvider,
|
|
|
|
domains.gitlabProvider,
|
|
|
|
domains.ssoProvider,
|
|
|
|
domains.ssoSecret,
|
|
|
|
domains.ssoUrl,
|
|
|
|
domains.defaultSortPolicy
|
|
|
|
`
|
2018-05-27 22:40:42 +08:00
|
|
|
|
2019-12-28 09:13:06 +08:00
|
|
|
func domainsRowScan(s sqlScanner, d *domain) error {
|
|
|
|
return s.Scan(
|
2019-04-20 07:03:34 +08:00
|
|
|
&d.Domain,
|
|
|
|
&d.OwnerHex,
|
|
|
|
&d.Name,
|
|
|
|
&d.CreationDate,
|
|
|
|
&d.State,
|
|
|
|
&d.ImportedComments,
|
|
|
|
&d.AutoSpamFilter,
|
|
|
|
&d.RequireModeration,
|
|
|
|
&d.RequireIdentification,
|
|
|
|
&d.ModerateAllAnonymous,
|
|
|
|
&d.EmailNotificationPolicy,
|
|
|
|
&d.CommentoProvider,
|
|
|
|
&d.GoogleProvider,
|
|
|
|
&d.TwitterProvider,
|
|
|
|
&d.GithubProvider,
|
2019-04-21 08:34:25 +08:00
|
|
|
&d.GitlabProvider,
|
|
|
|
&d.SsoProvider,
|
|
|
|
&d.SsoSecret,
|
2019-12-05 10:50:50 +08:00
|
|
|
&d.SsoUrl,
|
2019-12-28 09:13:06 +08:00
|
|
|
&d.DefaultSortPolicy,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func domainGet(dmn string) (domain, error) {
|
|
|
|
if dmn == "" {
|
|
|
|
return domain{}, errorMissingField
|
|
|
|
}
|
|
|
|
|
|
|
|
statement := `
|
|
|
|
SELECT ` + domainsRowColumns + `
|
|
|
|
FROM domains
|
|
|
|
WHERE domain = $1;
|
|
|
|
`
|
|
|
|
row := db.QueryRow(statement, dmn)
|
|
|
|
|
|
|
|
var err error
|
|
|
|
d := domain{}
|
|
|
|
if err = domainsRowScan(row, &d); err != nil {
|
2018-05-27 22:40:42 +08:00
|
|
|
return d, errorNoSuchDomain
|
|
|
|
}
|
|
|
|
|
|
|
|
d.Moderators, err = domainModeratorList(d.Domain)
|
|
|
|
if err != nil {
|
|
|
|
return domain{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return d, nil
|
|
|
|
}
|