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)
| 353 | // Callers must call this after every prompt, since nothing that can prompt or |
| 354 | // cancel may follow an upload. |
| 355 | func bodyForWrite(opts *CommentableOptions, uploader *attachments.Uploader) (body string, write bool, err error) { |
| 356 | if uploader == nil { |
| 357 | return opts.Body, true, nil |
| 358 | } |
| 359 | body, uploadResult, err := uploader.UploadAndAttach(context.Background(), opts.Body, opts.Assets) |
| 360 | opts.AttachEvent.RecordOperations(uploadResult) |
| 361 | if err != nil && uploadResult.Uploaded == 0 { |
| 362 | return "", false, err |
| 363 | } |
| 364 | return body, true, err |
| 365 | } |
| 366 | |
| 367 | func deleteComment(commentable Commentable, opts *CommentableOptions) error { |
| 368 | comments := commentable.CurrentUserComments() |
no test coverage detected