Skip to content

Commit

Permalink
refactor: Fix note trigger upon sharing revocation
Browse files Browse the repository at this point in the history
  Don't wait until the user tries to open a note from a revoked sharing
  to recreate its trigger but do it instead upon the sharing revocation.
  • Loading branch information
taratatach committed Feb 27, 2024
1 parent 506b9ce commit 617580c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 6 additions & 0 deletions model/sharing/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
4 changes: 0 additions & 4 deletions model/sharing/open_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ func (o *Opener) GetResult(memberIndex int, readOnly bool) (jsonapi.Object, erro
}

func (o *Opener) 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.
_ = note.SetupTrigger(o.Inst, o.File.ID())

code, err := o.GetSharecode(memberIndex, readOnly)
if err != nil {
return nil, err
Expand Down

0 comments on commit 617580c

Please sign in to comment.