mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
refactoring and check on errors
This commit is contained in:
parent
064b3886ec
commit
fa099176f9
16
main.go
16
main.go
@ -185,6 +185,18 @@ func updatePage(
|
|||||||
) error {
|
) error {
|
||||||
nextPageVersion := pageInfo.Version.Number + 1
|
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{}{
|
payload := map[string]interface{}{
|
||||||
"id": pageID,
|
"id": pageID,
|
||||||
"type": "page",
|
"type": "page",
|
||||||
@ -193,9 +205,7 @@ func updatePage(
|
|||||||
"number": nextPageVersion,
|
"number": nextPageVersion,
|
||||||
"minorEdit": false,
|
"minorEdit": false,
|
||||||
},
|
},
|
||||||
"ancestors": []map[string]interface{}{
|
"ancestors": oldAncestors,
|
||||||
{"id": pageInfo.Ancestors[len(pageInfo.Ancestors)-1].Id},
|
|
||||||
},
|
|
||||||
"body": map[string]interface{}{
|
"body": map[string]interface{}{
|
||||||
"storage": map[string]interface{}{
|
"storage": map[string]interface{}{
|
||||||
"value": string(newContent),
|
"value": string(newContent),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user