-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support dynamic domains in mod_caps #3156
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3156 +/- ##
==========================================
- Coverage 79.89% 79.82% -0.07%
==========================================
Files 396 396
Lines 32335 32316 -19
==========================================
- Hits 25834 25797 -37
- Misses 6501 6519 +18
Continue to review full report at Codecov.
|
f3f6f58
to
436059b
Compare
Also: - add type specs - extract common presence handling code to 'handle_presence'
- Remove hooks with no handlers. This is legacy code and it will be easier to refactor without these hooks. - Get host type from Acc
436059b
to
47428af
Compare
Insert = (Type == <<>> orelse Type == <<"available">>) | ||
and (Subscription == both orelse Subscription == to), | ||
Delete = Type == <<"unavailable">> orelse Type == <<"error">>, | ||
case Insert orelse Delete of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer or
, when operations on booleans are made. because of better type checking at runtime
5> true or 4.
** exception error: bad argument
in operator or/2
called as true or 4
6> true orelse 4.
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, short-circuit expressions are tail-recursive, quicker to execute and they make it obvious to the reader that the side-effects are not important.
In this particular case, it's priority that makes orelse
the natural choice for me. Less parentheses needed, see this:
A == B or C
It is a bit counter-intuitive, that B or C
is evaluated first here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Add support for dynamic domains to mod_caps.
Hooks handled or triggered by
mod_caps
are refactored according to the following rule:mongoose_acc:t()
is passed as an argument, do not add host type to the hook and handlers.Some lines remain untested as they are quite difficult to hit in the tests. Caps are mostly needed for PEP and it does not support dynamic domains, so the coverage for
dynamic_domains
is even lower. It could be increased in the future with the conversion of PubSub and PEP.See individual commits for more details.