Skip to content

Commit

Permalink
refactoring and check on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
seletskiy committed Sep 22, 2015
1 parent 064b388 commit fa09917
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ func updatePage(
) error {
nextPageVersion := pageInfo.Version.Number + 1

if len(pageInfo.Ancestors) == 0 {
return fmt.Errorf(
"Page '%s' info does not contain any information about parents",
pageID,
)
}

// picking only the last one, which is required by confluence
oldAncestors := []map[string]interface{}{
{"id": pageInfo.Ancestors[len(pageInfo.Ancestors)-1].Id},
}

payload := map[string]interface{}{
"id": pageID,
"type": "page",
Expand All @@ -193,9 +205,7 @@ func updatePage(
"number": nextPageVersion,
"minorEdit": false,
},
"ancestors": []map[string]interface{}{
{"id": pageInfo.Ancestors[len(pageInfo.Ancestors)-1].Id},
},
"ancestors": oldAncestors,
"body": map[string]interface{}{
"storage": map[string]interface{}{
"value": string(newContent),
Expand Down

0 comments on commit fa09917

Please sign in to comment.