attach points the document at the URLs of its attachments that uploaded, given urls, which holds an empty string for each file that did not. The error is a failure to rewrite the markdown, which is also in the result.
(assets []UserAsset, urls []string, uploadErr error)
| 211 | // given urls, which holds an empty string for each file that did not. The |
| 212 | // error is a failure to rewrite the markdown, which is also in the result. |
| 213 | func (d attachableDocument) attach(assets []UserAsset, urls []string, uploadErr error) (DocumentResult, error) { |
| 214 | result := DocumentResult{Markdown: d.md.markdown} |
| 215 | for i, a := range assets { |
| 216 | if !d.isAttachment[i] { |
| 217 | continue |
| 218 | } |
| 219 | if urls[i] == "" { |
| 220 | result.Err = uploadErr |
| 221 | continue |
| 222 | } |
| 223 | d.args[i].URL = urls[i] |
| 224 | result.Uploaded = append(result.Uploaded, a) |
| 225 | } |
| 226 | |
| 227 | attachedMD, err := attachAssetsToMarkdown(d.md) |
| 228 | if err != nil { |
| 229 | result.Err = errors.Join(result.Err, err) |
| 230 | return result, err |
| 231 | } |
| 232 | |
| 233 | result.Markdown = appendUnreferenced(attachedMD, assets) |
| 234 | result.AppendOperations = len(attachedMD.ToAppend) |
| 235 | result.ReplaceOperations = attachedMD.ReplaceOperations |
| 236 | return result, nil |
| 237 | } |
| 238 | |
| 239 | // appendUnreferenced adds a paragraph for every attachment the author never |
| 240 | // referenced, in the order they were attached. Each one renders itself, since |
no test coverage detected