aboutsummaryrefslogtreecommitdiff
path: root/src/mod_roster.erl
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2020-09-22 13:48:49 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2020-09-22 13:48:49 +0200
commit583dd15beb19c2cb365b8e03844247d9eedaf4e4 (patch)
tree1298b6c25d0d2dc1fd50df58903af9edd824d7ef /src/mod_roster.erl
parentrebar3 plugin to support configure-deps command (#3392) (diff)
Make roster subscriptions work better with invalid roster state in db
Sometimes we can observer combinations of subscription/ask that shouldn't happen normally, but can be generated with api calls, let's try to handle that gracefully instead of crashing.
Diffstat (limited to 'src/mod_roster.erl')
-rw-r--r--src/mod_roster.erl53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/mod_roster.erl b/src/mod_roster.erl
index 6d7ae46e2..f41c5bf1a 100644
--- a/src/mod_roster.erl
+++ b/src/mod_roster.erl
@@ -708,6 +708,30 @@ in_state_change(both, none, subscribe) -> none;
in_state_change(both, none, subscribed) -> none;
in_state_change(both, none, unsubscribe) -> {to, none};
in_state_change(both, none, unsubscribed) ->
+ {from, none};
+% Invalid states that can occurs from roster modification from API
+in_state_change(to, out, subscribe) -> {to, in};
+in_state_change(to, out, subscribed) -> none;
+in_state_change(to, out, unsubscribe) -> none;
+in_state_change(to, out, unsubscribed) -> {none, none};
+in_state_change(to, both, subscribe) -> none;
+in_state_change(to, both, subscribed) -> none;
+in_state_change(to, both, unsubscribe) -> {to, none};
+in_state_change(to, both, unsubscribed) -> {none, in};
+in_state_change(from, in, subscribe) -> none;
+in_state_change(from, in, subscribed) -> {both, none};
+in_state_change(from, in, unsubscribe) ->
+ {none, none};
+in_state_change(from, in, unsubscribed) -> none;
+in_state_change(from, both, subscribe) -> none;
+in_state_change(from, both, subscribed) -> {both, none};
+in_state_change(from, both, unsubscribe) -> {none, out};
+in_state_change(from, both, unsubscribed) ->
+ {from, none};
+in_state_change(both, _, subscribe) -> none;
+in_state_change(both, _, subscribed) -> none;
+in_state_change(both, _, unsubscribe) -> {to, none};
+in_state_change(both, _, unsubscribed) ->
{from, none}.
out_state_change(none, none, subscribe) -> {none, out};
@@ -715,8 +739,7 @@ out_state_change(none, none, subscribed) -> none;
out_state_change(none, none, unsubscribe) -> none;
out_state_change(none, none, unsubscribed) -> none;
out_state_change(none, out, subscribe) ->
- {none,
- out}; %% We need to resend query (RFC3921, section 9.2)
+ {none, out}; %% We need to resend query (RFC3921, section 9.2)
out_state_change(none, out, subscribed) -> none;
out_state_change(none, out, unsubscribe) ->
{none, none};
@@ -755,6 +778,32 @@ out_state_change(both, none, subscribed) -> none;
out_state_change(both, none, unsubscribe) ->
{from, none};
out_state_change(both, none, unsubscribed) ->
+ {to, none};
+% Invalid states that can occurs from roster modification from API
+out_state_change(to, out, subscribe) -> none;
+out_state_change(to, out, subscribed) -> {both, none};
+out_state_change(to, out, unsubscribe) -> {none, none};
+out_state_change(to, out, unsubscribed) -> none;
+out_state_change(to, both, subscribe) -> none;
+out_state_change(to, both, subscribed) -> {both, none};
+out_state_change(to, both, unsubscribe) -> {none, in};
+out_state_change(to, both, unsubscribed) -> {to, none};
+out_state_change(from, in, subscribe) -> {from, out};
+out_state_change(from, in, subscribed) -> none;
+out_state_change(from, in, unsubscribe) -> none;
+out_state_change(from, in, unsubscribed) ->
+ {none, none};
+out_state_change(from, both, subscribe) -> none;
+out_state_change(from, both, subscribed) -> none;
+out_state_change(from, both, unsubscribe) ->
+ {from, none};
+out_state_change(from, both, unsubscribed) ->
+ {none, out};
+out_state_change(both, _, subscribe) -> none;
+out_state_change(both, _, subscribed) -> none;
+out_state_change(both, _, unsubscribe) ->
+ {from, none};
+out_state_change(both, _, unsubscribed) ->
{to, none}.
in_auto_reply(from, none, subscribe) -> subscribed;