fix ID import

This commit is contained in:
Eugene
2017-12-24 13:51:56 -06:00
parent 24d0d0f498
commit a653c0af42
2 changed files with 23 additions and 16 deletions
+16 -15
View File
@@ -17,21 +17,22 @@ import (
)
var opts struct {
DBFile string `long:"db" env:"BOLTDB_FILE" default:"/tmp/remark.db" description:"bolt file name"`
SessionStore string `long:"session" env:"SESSION_STORE" default:"/tmp" description:"path to session store directory"`
StoreKey string `long:"store-key" env:"STORE_KEY" default:"secure-store-key" description:"store key"`
GoogleCID string `long:"google-cid" env:"REMARK_GOOGLE_CID" description:"Google OAuth client ID"`
GoogleCSEC string `long:"google-csec" env:"REMARK_GOOGLE_CSEC" description:"Google OAuth client secret"`
GithubCID string `long:"github-cid" env:"REMARK_GITHUB_CID" description:"Github OAuth client ID"`
GithubCSEC string `long:"github-csec" env:"REMARK_GITHUB_CSEC" description:"Github OAuth client secret"`
DBFile string `long:"db" env:"BOLTDB_FILE" default:"/tmp/remark.db" description:"bolt file name"`
SiteURL string `long:"site-url" env:"REMARK_URL" default:"http://remark.umputun.com:8080" description:"url to remark site"`
Admins []string `long:"admin" env:"ADMIN" default:"umputun@gmail.com" description:"admin(s) names" env-delim:","`
DevMode bool `long:"dev" env:"DEV" description:"development mode, no auth enforced"`
Dbg bool `long:"dbg" env:"DEBUG" description:"debug mode"`
ServerCommand struct {
SessionStore string `long:"session" env:"SESSION_STORE" default:"/tmp" description:"path to session store directory"`
StoreKey string `long:"store-key" env:"STORE_KEY" default:"secure-store-key" description:"store key"`
GoogleCID string `long:"google-cid" env:"REMARK_GOOGLE_CID" description:"Google OAuth client ID"`
GoogleCSEC string `long:"google-csec" env:"REMARK_GOOGLE_CSEC" description:"Google OAuth client secret"`
GithubCID string `long:"github-cid" env:"REMARK_GITHUB_CID" description:"Github OAuth client ID"`
GithubCSEC string `long:"github-csec" env:"REMARK_GITHUB_CSEC" description:"Github OAuth client secret"`
} `command:"server" description:"run server"`
ImportCommand struct {
Provider string `long:"provider" default:"disqus" description:"provider type"`
SiteID string `long:"site" default:"site" description:"site ID"`
@@ -63,7 +64,7 @@ func main() {
return
}
sessionStore := sessions.NewFilesystemStore(opts.SessionStore, []byte(opts.StoreKey))
sessionStore := sessions.NewFilesystemStore(opts.ServerCommand.SessionStore, []byte(opts.ServerCommand.StoreKey))
srv := rest.Server{
Version: revision,
@@ -72,14 +73,14 @@ func main() {
Admins: opts.Admins,
DevMode: opts.DevMode,
AuthGoogle: auth.NewGoogle(auth.Params{
Cid: opts.GoogleCID,
Csecret: opts.GoogleCSEC,
Cid: opts.ServerCommand.GoogleCID,
Csecret: opts.ServerCommand.GoogleCSEC,
SessionStore: sessionStore,
SiteURL: opts.SiteURL,
}),
AuthGithub: auth.NewGithub(auth.Params{
Cid: opts.GithubCID,
Csecret: opts.GithubCSEC,
Cid: opts.ServerCommand.GithubCID,
Csecret: opts.ServerCommand.GithubCSEC,
SessionStore: sessionStore,
SiteURL: opts.SiteURL,
}),
+7 -1
View File
@@ -103,13 +103,19 @@ func (d *Disqus) convert(r io.Reader, siteID string) (ch chan store.Comment) {
continue
}
c := store.Comment{
ID: comment.ID,
ID: comment.UID,
Locator: store.Locator{URL: postsMap[comment.Tid.Val], SiteID: siteID},
User: store.User{ID: comment.AuthorUserName, Name: comment.AuthorName, IP: comment.IP},
Text: d.cleanText(comment.Message),
Timestamp: comment.CreatedAt,
ParentID: comment.Pid.Val,
}
if c.User.ID == "" {
c.User.ID = "import_" + c.User.Name
}
if c.ID == "" {
c.ID = comment.ID
}
commentsCh <- c
commentsCount++
if commentsCount%1000 == 0 {