Currently, when saving a diagram, the existing .png and .svg image attachments are deleted and then new images are attached to prevent versioning of these attachments. The deletion of attachments in DiagramResourcesImpl.deleteAttachments() clones the document, removes the attachment and then saves the document. This results in a new revision with the last user that saved the document as the author and causes confusing entries in the recent activty feed of that user.
Proposal: Deleting the attachments should be done as the user that is currently saving the diagram.
Could look like this:
UserReference currentUser = userReferenceResolver.resolve(context.getUserReference());
clonedDiagramDocument.getAuthors().setEffectiveMetadataAuthor(currentUser);
clonedDiagramDocument.getAuthors().setOriginalMetadataAuthor(currentUser);
xwiki.saveDocument(clonedDiagramDocument, "Clean old diagram attachments", false, context);
Currently, when saving a diagram, the existing .png and .svg image attachments are deleted and then new images are attached to prevent versioning of these attachments. The deletion of attachments in
DiagramResourcesImpl.deleteAttachments()clones the document, removes the attachment and then saves the document. This results in a new revision with the last user that saved the document as the author and causes confusing entries in the recent activty feed of that user.Proposal: Deleting the attachments should be done as the user that is currently saving the diagram.
Could look like this: