Skip to content

Commit

Permalink
Make mod_webpresence works with any sm backend
Browse files Browse the repository at this point in the history
  • Loading branch information
prefiks committed Feb 19, 2024
1 parent 3362bbd commit 7e5af66
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mod_webpresence/src/mod_webpresence.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
-record(state, {host, server_host, base_url, access}).
-record(presence2, {resource, show, priority, status}).

%% Copied from ejabberd_sm.erl
-record(session, {sid, usr, us, priority, info}).

-define(AUTO_ACL, webpresence_auto).

%%====================================================================
Expand Down Expand Up @@ -591,7 +588,7 @@ get_status_weight(Show) ->
_ -> 9
end.

session_to_presence(#session{sid = {_, Pid}}) ->
sid_to_presence({_, Pid}) ->
P = ejabberd_c2s:get_presence(Pid),
#presence2{resource = (P#presence.from)#jid.resource,
show = misc:atom_to_binary(humanize_show(P#presence.show)),
Expand All @@ -604,8 +601,8 @@ humanize_show(Show) ->
Show.

get_presences({bare, LUser, LServer}) ->
[session_to_presence(Session) ||
Session <- mnesia:dirty_index_read(session, {LUser, LServer}, #session.us)];
Sids = ejabberd_sm:get_session_sids(LUser, LServer),
lists:map(fun sid_to_presence/1, Sids);

get_presences({sorted, LUser, LServer}) ->
lists:sort(
Expand Down

0 comments on commit 7e5af66

Please sign in to comment.