mirror of
https://github.com/kovetskiy/mark.git
synced 2026-01-22 10:47:36 +08:00
feat: enhance Confluence link generation by utilizing base URL from API response
Signed-off-by: Nikolai Emil Damm <ndam@tv2.dk>
This commit is contained in:
parent
bb4d4e2dab
commit
a334c1c1cc
@ -61,6 +61,7 @@ type PageInfo struct {
|
|||||||
|
|
||||||
Links struct {
|
Links struct {
|
||||||
Full string `json:"webui"`
|
Full string `json:"webui"`
|
||||||
|
Base string `json:"-"` // Not from JSON; populated from response _links.base
|
||||||
} `json:"_links"`
|
} `json:"_links"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +194,9 @@ func (api *API) FindPage(
|
|||||||
) (*PageInfo, error) {
|
) (*PageInfo, error) {
|
||||||
result := struct {
|
result := struct {
|
||||||
Results []PageInfo `json:"results"`
|
Results []PageInfo `json:"results"`
|
||||||
|
Links struct {
|
||||||
|
Base string `json:"base"`
|
||||||
|
} `json:"_links"`
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
payload := map[string]string{
|
payload := map[string]string{
|
||||||
@ -222,7 +226,13 @@ func (api *API) FindPage(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result.Results[0], nil
|
page := &result.Results[0]
|
||||||
|
// Populate the base URL from the response _links.base
|
||||||
|
if result.Links.Base != "" {
|
||||||
|
page.Links.Base = result.Links.Base
|
||||||
|
}
|
||||||
|
|
||||||
|
return page, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) CreateAttachment(
|
func (api *API) CreateAttachment(
|
||||||
|
|||||||
10
page/link.go
10
page/link.go
@ -217,7 +217,15 @@ func getConfluenceLink(
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
tiny, err := GenerateTinyLink(api.BaseURL, page.ID)
|
// Prefer the base URL from the API response (_links.base) as it contains
|
||||||
|
// the canonical user-facing wiki URL (e.g., https://tenant.atlassian.net/wiki).
|
||||||
|
// Fall back to api.BaseURL if _links.base is not available.
|
||||||
|
baseURL := page.Links.Base
|
||||||
|
if baseURL == "" {
|
||||||
|
baseURL = api.BaseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
tiny, err := GenerateTinyLink(baseURL, page.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", karma.Format(err, "generate tiny link for page %s", page.ID)
|
return "", karma.Format(err, "generate tiny link for page %s", page.ID)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user