2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import ()
|
|
|
|
|
|
|
|
func domainGet(dmn string) (domain, error) {
|
|
|
|
if dmn == "" {
|
|
|
|
return domain{}, errorMissingField
|
|
|
|
}
|
|
|
|
|
|
|
|
statement := `
|
2019-04-20 07:03:34 +08:00
|
|
|
SELECT
|
|
|
|
domain,
|
|
|
|
ownerHex,
|
|
|
|
name,
|
|
|
|
creationDate,
|
|
|
|
state,
|
|
|
|
importedComments,
|
|
|
|
autoSpamFilter,
|
|
|
|
requireModeration,
|
|
|
|
requireIdentification,
|
|
|
|
moderateAllAnonymous,
|
|
|
|
emailNotificationPolicy,
|
|
|
|
commentoProvider,
|
|
|
|
googleProvider,
|
|
|
|
twitterProvider,
|
|
|
|
githubProvider,
|
2019-04-21 08:34:25 +08:00
|
|
|
gitlabProvider,
|
|
|
|
ssoProvider,
|
|
|
|
ssoSecret,
|
|
|
|
ssoUrl
|
2018-05-27 22:40:42 +08:00
|
|
|
FROM domains
|
|
|
|
WHERE domain = $1;
|
|
|
|
`
|
|
|
|
row := db.QueryRow(statement, dmn)
|
|
|
|
|
|
|
|
var err error
|
|
|
|
d := domain{}
|
2019-04-20 07:03:34 +08:00
|
|
|
if err = row.Scan(
|
|
|
|
&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,
|
|
|
|
&d.SsoUrl); 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
|
|
|
|
}
|