diff --git a/main.go b/main.go index a18304e..fc7db58 100644 --- a/main.go +++ b/main.go @@ -7,15 +7,15 @@ import ( ) // WP Config -const baseUrl = "http://go-api-playground.local/" -const wordpressKey = "admin" -const wordpressSecret = "KStj VH7E 9UZf FV8C ptGQ F4Tl" +const baseUrl = "https://slowtwitch.cloud/" +const wordpressKey = "admin@slowtwitch.cloud" +const wordpressSecret = "rcI0 7qAM Q1CR xi6n sGcB 4XFN" // DB Config const slowtwitchAdminUser = "admin" const slowtwitchAdminPass = "yxnh93Ybbz2Nm8#mp28zCVv" const slowtwitchDbName = "slowtwitch" -const migrationDbName = "slowtwitch_transfer_threaded_test" +const migrationDbName = "slowtwitch_transfer" const federatedDbUrl = "slowtwitch.northend.network" const federatedDbPort = "3306" diff --git a/results.txt b/results.txt index eead398..be57bfa 100644 Binary files a/results.txt and b/results.txt differ diff --git a/services/migration/migrate-authors.go b/services/migration/migrate-authors.go index 61439ba..2231004 100644 --- a/services/migration/migrate-authors.go +++ b/services/migration/migrate-authors.go @@ -44,6 +44,8 @@ func (migration *MigrateAuthors) Execute() []EditorResult { if err == nil { wordpressId = result.Id isSuccess = true + } else { + fmt.Println("error creating user:", err) } editorResult := EditorResult{ diff --git a/services/migration/migrate-posts.go b/services/migration/migrate-posts.go index ec51668..9aa4fbe 100644 --- a/services/migration/migrate-posts.go +++ b/services/migration/migrate-posts.go @@ -180,7 +180,9 @@ func (migration MigratePosts) Execute() []PostResult { } imageResults = append(imageResults, imageResult) //replace old links with new in post html - strings.ReplaceAll(html, imageUrl, wordpressImage.Link) + //TODO Wordpress path vs link? If path works I prefer that + newImagePath := "/wp-content/uploads/" + wordpressImage.MediaDetails.File + html = strings.ReplaceAll(html, imagePath, newImagePath) //create redirect imageRedirect := wordpress.CreateRedirect{ Title: postBase.Title + "image-" + string((i + 1)), @@ -271,7 +273,7 @@ func (migration MigratePosts) Execute() []PostResult { postResults = append(postResults, batchResults...) } } - // Update related posts once work is done + // Update related posts once work is done -- Why are there duplicates? updatePostRelationships(postResults, migration) return postResults @@ -366,7 +368,7 @@ func getSuccessfulWordpressImageIds(imageResults []ImageResult) []int { var output []int for _, imageResult := range imageResults { - if imageResult.IsSuccess { + if imageResult.WordpressId > 0 && imageResult.IsSuccess { output = append(output, imageResult.WordpressId) } } @@ -392,3 +394,12 @@ func updateAcfImages(imageResults []ImageResult, postId int, baseUrl, user, pass } } } + +func getContentType(filename string) string { + if strings.Contains(filename, "png") { + return ".png" + } else if strings.Contains(filename, "gif") { + return ".gif" + } + return ".jpeg" +} diff --git a/services/wordpress/create-image.go b/services/wordpress/create-image.go index b02972e..0b2b887 100644 --- a/services/wordpress/create-image.go +++ b/services/wordpress/create-image.go @@ -14,9 +14,14 @@ type CreateImage struct { } type CreateImageResponse struct { - Id int `json:"id"` - Link string `json:"link"` - Slug string `json:"slug"` + Id int `json:"id"` + Link string `json:"link"` + Slug string `json:"slug"` + MediaDetails MediaDetails `json:"media_details"` +} + +type MediaDetails struct { + File string `json:"file"` } func (parameters *CreateImage) Execute(baseUrl, user, pass string) (CreateImageResponse, error) {