Fix sensor registration and webhook trigger registration #927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes sensor registration and webhook trigger registration (which appears never worked).
Here is a context on this bug - https://gist.github.com/Kami/7fd428765fe516673880
I'm too tired now to recap it in a more "friendly" and "readable" manner, but I will do it tomorrow.
P.S. 1 The change which introduced a bug didn't just broke registration, it also changed the behavior. Previously trigger information in the DB was updated every time the registration code was called. With the new / broken code, DB models were never updated, just created.
P.S. 2 We need tests for sensor / action / rules registration and for webhook trigger type registration.
P.S. 3 I mostly reverted to the old way of doing it. In the future, I will probably update
services.triggers
methods to also update a model if it already exists in the DB, but before doing that, I want full test coverage for those code paths. Last thing we want is another regression.