summaryrefslogtreecommitdiff
path: root/internal/processing/fromcommon.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-06-24 17:17:40 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-24 17:17:40 +0200
commit0846b76e9343fd90a33f5a8864f39cf071d3841e (patch)
treef5bc3b506cd87b09a46d6f17982c3633c909b14f /internal/processing/fromcommon.go
parent[bugfix] allow setting empty email via instance patch (#665) (diff)
downloadgotosocial-0846b76e9343fd90a33f5a8864f39cf071d3841e.tar.xz
[bugfix] Fix 404 on status delete redraft (#668)
* add unattach function to media processor * call delete or unattach appropriately unattach from client api, delete from federated api * typo fix
Diffstat (limited to 'internal/processing/fromcommon.go')
-rw-r--r--internal/processing/fromcommon.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go
index e9a2e4994..2cac20193 100644
--- a/internal/processing/fromcommon.go
+++ b/internal/processing/fromcommon.go
@@ -444,11 +444,23 @@ func (p *processor) deleteStatusFromTimelines(ctx context.Context, status *gtsmo
// wipeStatus contains common logic used to totally delete a status
// + all its attachments, notifications, boosts, and timeline entries.
-func (p *processor) wipeStatus(ctx context.Context, statusToDelete *gtsmodel.Status) error {
- // delete all attachments for this status
- for _, a := range statusToDelete.AttachmentIDs {
- if err := p.mediaProcessor.Delete(ctx, a); err != nil {
- return err
+func (p *processor) wipeStatus(ctx context.Context, statusToDelete *gtsmodel.Status, deleteAttachments bool) error {
+ // either delete all attachments for this status, or simply
+ // unattach all attachments for this status, so they'll be
+ // cleaned later by a separate process; reason to unattach rather
+ // than delete is that the poster might want to reattach them
+ // to another status immediately (in case of delete + redraft)
+ if deleteAttachments {
+ for _, a := range statusToDelete.AttachmentIDs {
+ if err := p.mediaProcessor.Delete(ctx, a); err != nil {
+ return err
+ }
+ }
+ } else {
+ for _, a := range statusToDelete.AttachmentIDs {
+ if _, err := p.mediaProcessor.Unattach(ctx, statusToDelete.Account, a); err != nil {
+ return err
+ }
}
}