diff --git a/backend/api_media_extended_description.go b/backend/api_media_extended_description.go index 86738bc..bdf5f9b 100644 --- a/backend/api_media_extended_description.go +++ b/backend/api_media_extended_description.go @@ -4,6 +4,7 @@ package main import ( "encoding/json" + "fmt" "net/http" "os" "strconv" @@ -15,6 +16,10 @@ type ExtendedDescriptionSetBody struct { ExtendedDescription string `json:"ext_desc"` } +type ExtendedDescriptionSetResponse struct { + Url string `json:"url"` +} + func api_setExtendedDescription(response http.ResponseWriter, request *http.Request) { session := GetSessionFromRequest(request) @@ -47,6 +52,10 @@ func api_setExtendedDescription(response http.ResponseWriter, request *http.Requ assetData := []byte(p.ExtendedDescription) + result := ThumbnailAPIResponse{ + Url: "", + } + if len(assetData) > 0 { // Encrypt the description file @@ -146,6 +155,7 @@ func api_setExtendedDescription(response http.ResponseWriter, request *http.Requ meta.HasExtendedDescription = true meta.ExtendedDescriptionAsset = desc_asset + result.Url = "/assets/b/" + fmt.Sprint(media_id) + "/" + fmt.Sprint(desc_asset) + "/ext_desc.txt" + "?fp=" + GetVault().credentials.GetFingerprint() // Save err = media.EndWrite(meta, session.key, false) @@ -226,5 +236,14 @@ func api_setExtendedDescription(response http.ResponseWriter, request *http.Requ // Response - response.WriteHeader(200) + jsonResult, err := json.Marshal(result) + + if err != nil { + LogError(err) + + ReturnAPIError(response, 500, "INTERNAL_ERROR", "Internal server error, Check the logs for details.") + return + } + + ReturnAPI_JSON(response, request, jsonResult) } diff --git a/backend/api_media_image_notes.go b/backend/api_media_image_notes.go index 6182558..e2aba5e 100644 --- a/backend/api_media_image_notes.go +++ b/backend/api_media_image_notes.go @@ -4,6 +4,7 @@ package main import ( "encoding/json" + "fmt" "net/http" "os" "strconv" @@ -19,6 +20,10 @@ type ImageNote struct { Text string `json:"text"` } +type ImageNotesSetResponse struct { + Url string `json:"url"` +} + func api_setImageNotes(response http.ResponseWriter, request *http.Request) { session := GetSessionFromRequest(request) @@ -58,6 +63,10 @@ func api_setImageNotes(response http.ResponseWriter, request *http.Request) { return } + result := ImageNotesSetResponse{ + Url: "", + } + // Encrypt the notes file notes_encrypted_file, err := EncryptAssetData(assetData, session.key) @@ -164,6 +173,7 @@ func api_setImageNotes(response http.ResponseWriter, request *http.Request) { meta.HasImageNotes = true meta.ImageNotesAsset = notes_asset + result.Url = "/assets/b/" + fmt.Sprint(media_id) + "/" + fmt.Sprint(notes_asset) + "/notes.json" + "?fp=" + GetVault().credentials.GetFingerprint() // Save err = media.EndWrite(meta, session.key, false) @@ -181,5 +191,14 @@ func api_setImageNotes(response http.ResponseWriter, request *http.Request) { // Response - response.WriteHeader(200) + jsonResult, err := json.Marshal(result) + + if err != nil { + LogError(err) + + ReturnAPIError(response, 500, "INTERNAL_ERROR", "Internal server error, Check the logs for details.") + return + } + + ReturnAPI_JSON(response, request, jsonResult) } diff --git a/backend/doc/api-docs.yml b/backend/doc/api-docs.yml index b050da9..ca6f582 100644 --- a/backend/doc/api-docs.yml +++ b/backend/doc/api-docs.yml @@ -857,6 +857,12 @@ paths: description: Not found 200: description: Success + schema: + properties: + url: + type: string + description: "New notes URL" + example: "/assets/b/0/0/notes.json" "/api/media/{id}/edit/ext_desc": post: @@ -895,6 +901,12 @@ paths: description: Not found 200: description: Success + schema: + properties: + url: + type: string + description: "New extended description URL" + example: "/assets/b/0/0/ext_desc.txt" "/api/media/{id}/edit/thumbnail": post: