Conversation
Webhook filters on nested relations (e.g. event.card.labels.title) failed because getWebhookSerializable() returned Label/Assignment objects inside the card array, which PHPMongoQuery cannot traverse. Serialize the card and acl through json_encode/json_decode so the payload is plain arrays. Resolves: nextcloud#8245 Signed-off-by: Vladimir Babin <vovababin@gmail.com>
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
labelsin mongo filters #8245Summary
Webhook event filters like
{"event.card.labels.title": "foo"}crash inwebhook_listenerswith:ACardEvent::getWebhookSerializable()returned$this->card->jsonSerialize(), which is only one level deep:labels,assignedUsers,attachmentsetc. stay asLabel/Assignmentobjects inside the array.json_encodewould resolve them later, butPHPMongoQueryruns the filter on the raw array before encoding and can only traverse arrays.Fix: serialize the card / acl through
json_encode+json_decodeso the payload handed to the webhook listener is plain nested arrays. Same change onAAclEventfor consistency (itsparticipantrelation has the same shape).Validation
Reproduced against a local
nextcloud/servermaster checkout withwebhook_listeners' ownPHPMongoQuery:executeQuery(['event.card.labels.title' => 'foo'], $data)→ the exactTypeErrorfrom the issuetruefor a matching label title,falsefor a non-matching oneRegression test
testCardEventSerializesNestedEntitiesAsArraysadded to the existingWebhookCompatibleEventsTest; it fails onmain(Failed asserting that OCA\Deck\Db\Label Object ... is of type array) and passes with this change.composer run test:unit— 425 tests, 4088 assertions, OK (the singleSUBJECT_LABEL_DELETEwarning is pre-existing on main)composer run cs:check— cleancomposer run psalm— no errorsChecklist