mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
* Fix bug where updated webhook options failed to save This bug was caused by Mongoose not creating getters/setters for array elements (https://mongoosejs.com/docs/faq.html#array-changes-not-saved). So, although the webhook was being updated properly, Mongoose was not actually committing it to the database. Telling Mongoose that the array of webhooks has changed via `markModified` fixes the issue. Additionally, the relevant API test case was only checking whether or not the webhook returned from the PUT endpoint matched the expected update. Since the endpoint was returning the updated webhook without querying the database again, this test case would pass. It has been updated to check both the returned webhook as well as the version of the webhook that is saved to the database against the expected. In other words: `assert returned === saved === expected` Fixes #12336 * Call markModified on webhook.options instead of user.webhooks This tells Mongoose that only the modified webhook's options changed instead of telling it that the entire user.webhooks array changed, saving a costly DB update.