Skip to content

Attach to a note only a file uploaded for its record - #1093

Merged
KrzysztofPajak merged 2 commits into
developfrom
fix/note-attachment-ownership
Nov 23, 2026
Merged

KrzysztofPajak merged 2 commits into
developfrom
fix/note-attachment-ownership

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

The note forms post the id of the file they uploaded, and the panels saved whatever id they were given. A shipment, merchandise return or customer note could point at a file uploaded for another record, even one of another store, and the customer could then download it from the note. Deleting the note also deleted that file. Order notes already checked this.

Changes

  • DownloadExtensions.IsAttachmentOf(downloadType, referenceId) (Grand.Web.AdminShared/Extensions): the one check for every note kind; the private copy in OrderNoteViewModelService is replaced by it.
  • ShipmentViewModelService.InsertShipmentNote, MerchandiseReturnViewModelService.InsertMerchandiseReturnNote and CustomerNoteViewModelService.InsertCustomerNote: accept a download only when its type is Shipment / MerchandiseReturn / Customer and its reference is that record. They return false otherwise (InsertCustomerNote returned the note before).
  • The delete methods remove the attached file only when it belongs to that record.
  • BaseShipmentController, BaseMerchandiseReturnController and the admin CustomerNoteController answer Result = false with a message, and the note views show it instead of reloading the grid silently.
  • Resources (DefaultLanguage.xml and Upgrade/en_250.xml): Admin.Orders.Shipments.ShipmentNotes.DownloadNotOfShipment, Admin.Orders.MerchandiseReturns.MerchandiseReturnNotes.DownloadNotOfMerchandiseReturn, Admin.Customers.Customers.CustomerNotes.DownloadNotOfCustomer.

Tests

  • ShipmentViewModelServiceTests: own file saved, file of another shipment or type refused, delete keeps a foreign file.
  • MerchandiseReturnViewModelServiceTests: only a file uploaded for the return is saved.
  • CustomerNoteViewModelServiceTests: own file saved, file of another type or customer refused, delete keeps a foreign file.
  • Controller tests for the refused case.
  • Grand.Web.Admin.Tests (2109), Grand.Web.Store.Tests (245), Grand.Web.Vendor.Tests (53) pass.

…for it

The note forms post the id of the file they uploaded, and the panels saved any id they were given. A note could point at a file uploaded for another record, even one of another store, and the customer could then download it from the note; deleting the note deleted that file.

Shipment and merchandise return notes now take only a file uploaded for that shipment or return, as order notes already do, and deleting a note removes only such a file. The panels show a message when the file is refused.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 04:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

var result = await _controller.MerchandiseReturnNoteAdd("mr1", "download-x", false, "msg");

var json = result as JsonResult;
Assert.IsFalse((bool)json.Value.GetType().GetProperty("Result").GetValue(json.Value));
…ck every note kind one way

Customer notes saved any file id the request gave and deleted that file with the note, the gap shipment and merchandise return notes had. They now take only a file uploaded for that customer, and deleting a note removes only such a file.

The order, shipment and merchandise return notes each had their own copy of the check; the four note kinds now share one Download extension.
@KrzysztofPajak KrzysztofPajak changed the title Attach to a shipment or merchandise return note only a file uploaded for it Attach to a note only a file uploaded for its record Nov 23, 2026
@KrzysztofPajak
KrzysztofPajak merged commit 72cc703 into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/note-attachment-ownership branch November 25, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants