2017-06-06 13:51:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
color.Yellow("Updating user references")
|
|
|
|
|
2017-06-12 18:06:31 +00:00
|
|
|
arn.DB.DeleteTable("NickToUser")
|
|
|
|
arn.DB.DeleteTable("EmailToUser")
|
2017-06-15 21:03:55 +00:00
|
|
|
arn.DB.DeleteTable("GoogleToUser")
|
2017-07-02 21:42:46 +00:00
|
|
|
arn.DB.DeleteTable("FacebookToUser")
|
2017-06-06 13:51:22 +00:00
|
|
|
|
2017-06-21 19:45:41 +00:00
|
|
|
// Get a stream of all users
|
2017-06-27 12:38:36 +00:00
|
|
|
allUsers, err := arn.StreamUsers()
|
2017-06-06 13:51:22 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate over the stream
|
|
|
|
count := 0
|
|
|
|
for user := range allUsers {
|
|
|
|
count++
|
|
|
|
println(count, user.Nick)
|
|
|
|
|
2017-06-24 00:10:04 +00:00
|
|
|
user.ForceSetNick(user.Nick)
|
2017-06-08 09:51:34 +00:00
|
|
|
|
|
|
|
if user.Email != "" {
|
|
|
|
user.SetEmail(user.Email)
|
|
|
|
}
|
2017-06-15 21:03:55 +00:00
|
|
|
|
|
|
|
if user.Accounts.Google.ID != "" {
|
2017-07-02 21:42:46 +00:00
|
|
|
user.ConnectGoogle(user.Accounts.Google.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
if user.Accounts.Facebook.ID != "" {
|
|
|
|
user.ConnectFacebook(user.Accounts.Facebook.ID)
|
2017-06-15 21:03:55 +00:00
|
|
|
}
|
2017-06-06 13:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
color.Green("Finished.")
|
|
|
|
}
|