diff --git a/model/sharing/files.go b/model/sharing/files.go index b1faa8b1190..0f78ea9b3d2 100644 --- a/model/sharing/files.go +++ b/model/sharing/files.go @@ -701,6 +701,12 @@ func (s *Sharing) FixRevokedNotes(inst *instance.Instance) error { var errm error for _, doc := range docs { + // If the note came from another cozy via a sharing that is now revoked, we + // may need to recreate the trigger. + if err := note.SetupTrigger(inst, doc.ID()); err != nil { + errm = multierror.Append(errm, fmt.Errorf("failed to setup revoked note trigger: %w", err)) + } + if err := note.ImportImages(inst, doc); err != nil { errm = multierror.Append(errm, fmt.Errorf("failed to import revoked note images: %w", err)) } diff --git a/model/sharing/open_note.go b/model/sharing/open_note.go index 33b7a62a3d5..938307aeb9c 100644 --- a/model/sharing/open_note.go +++ b/model/sharing/open_note.go @@ -81,6 +81,9 @@ func (o *NoteOpener) GetResult(memberIndex int, readOnly bool) (jsonapi.Object, func (o *NoteOpener) openLocalNote(memberIndex int, readOnly bool) (*apiNoteURL, error) { // If the note came from another cozy via a sharing that is now revoked, we // may need to recreate the trigger. + // This should be taken care of when revoking the sharing now but we leave + // this call to make sure notes from previously revoked sharings will + // continue to work. _ = note.SetupTrigger(o.Inst, o.File.ID()) code, err := o.GetSharecode(memberIndex, readOnly)