aboutsummaryrefslogtreecommitdiff
path: root/src/mod_pres_counter.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_pres_counter.erl')
-rw-r--r--src/mod_pres_counter.erl41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/mod_pres_counter.erl b/src/mod_pres_counter.erl
index e6f2cfbab..786ba97f2 100644
--- a/src/mod_pres_counter.erl
+++ b/src/mod_pres_counter.erl
@@ -33,7 +33,7 @@
-include("ejabberd.hrl").
-include("logger.hrl").
--include("jlib.hrl").
+-include("xmpp.hrl").
-record(pres_counter,
{dir, start, count, logged = false}).
@@ -52,27 +52,24 @@ depends(_Host, _Opts) ->
[].
check_packet(_, _User, Server, _PrivacyList,
- {From, To, #xmlel{name = Name, attrs = Attrs}}, Dir) ->
- case Name of
- <<"presence">> ->
- IsSubscription = case fxml:get_attr_s(<<"type">>, Attrs)
- of
- <<"subscribe">> -> true;
- <<"subscribed">> -> true;
- <<"unsubscribe">> -> true;
- <<"unsubscribed">> -> true;
- _ -> false
- end,
- if IsSubscription ->
- JID = case Dir of
- in -> To;
- out -> From
- end,
- update(Server, JID, Dir);
- true -> allow
- end;
- _ -> allow
- end.
+ {From, To, #presence{type = Type}}, Dir) ->
+ IsSubscription = case Type of
+ subscribe -> true;
+ subscribed -> true;
+ unsubscribe -> true;
+ unsubscribed -> true;
+ _ -> false
+ end,
+ if IsSubscription ->
+ JID = case Dir of
+ in -> To;
+ out -> From
+ end,
+ update(Server, JID, Dir);
+ true -> allow
+ end;
+check_packet(_, _User, _Server, _PrivacyList, _Pkt, _Dir) ->
+ allow.
update(Server, JID, Dir) ->
StormCount = gen_mod:get_module_opt(Server, ?MODULE, count,