bodyForWrite uploads the assets and reports whether the body it produced is worth writing. A failed upload that produced nothing writes nothing, since there is nothing to salvage and a comment that promises an attachment it does not have only compounds the failure. Callers must call this after ever
(opts *CommentableOptions, uploader *attachments.Uploader)
| 350 | // Callers must call this after every prompt, since nothing that can prompt or |
| 351 | // cancel may follow an upload. |
| 352 | func bodyForWrite(opts *CommentableOptions, uploader *attachments.Uploader) (body string, write bool, err error) { |
| 353 | if uploader == nil { |
| 354 | return opts.Body, true, nil |
| 355 | } |
| 356 | body, uploaded, err := uploader.UploadAndAttach(context.Background(), opts.Body, opts.Assets) |
| 357 | if err != nil && uploaded == 0 { |
| 358 | return "", false, err |
| 359 | } |
| 360 | return body, true, err |
| 361 | } |
| 362 | |
| 363 | func deleteComment(commentable Commentable, opts *CommentableOptions) error { |
| 364 | comments := commentable.CurrentUserComments() |
no test coverage detected