mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
mod_mix_pam: Provide MIX channels as roster entries via hook
This commit is contained in:
parent
e858738736
commit
7564a4e953
@ -28,7 +28,8 @@
|
|||||||
ask = none :: ask() | '_',
|
ask = none :: ask() | '_',
|
||||||
groups = [] :: [binary()] | '_',
|
groups = [] :: [binary()] | '_',
|
||||||
askmessage = <<"">> :: binary() | '_',
|
askmessage = <<"">> :: binary() | '_',
|
||||||
xs = [] :: [fxml:xmlel()] | '_'
|
xs = [] :: [fxml:xmlel()] | '_',
|
||||||
|
mix_participant_id = <<>> :: binary() | '_'
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(roster_version,
|
-record(roster_version,
|
||||||
|
@ -32,11 +32,13 @@
|
|||||||
disco_sm_features/5,
|
disco_sm_features/5,
|
||||||
remove_user/2,
|
remove_user/2,
|
||||||
process_iq/1,
|
process_iq/1,
|
||||||
|
get_mix_roster_items/2,
|
||||||
webadmin_user/4,
|
webadmin_user/4,
|
||||||
webadmin_page/3]).
|
webadmin_page/3]).
|
||||||
|
|
||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("mod_roster.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
-include("ejabberd_http.hrl").
|
-include("ejabberd_http.hrl").
|
||||||
-include("ejabberd_web_admin.hrl").
|
-include("ejabberd_web_admin.hrl").
|
||||||
@ -65,6 +67,7 @@ start(Host, Opts) ->
|
|||||||
ejabberd_hooks:add(bounce_sm_packet, Host, ?MODULE, bounce_sm_packet, 50),
|
ejabberd_hooks:add(bounce_sm_packet, Host, ?MODULE, bounce_sm_packet, 50),
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, disco_sm_features, 50),
|
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, disco_sm_features, 50),
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50),
|
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50),
|
||||||
|
ejabberd_hooks:add(roster_get, Host, ?MODULE, get_mix_roster_items, 50),
|
||||||
ejabberd_hooks:add(webadmin_user, Host, ?MODULE, webadmin_user, 50),
|
ejabberd_hooks:add(webadmin_user, Host, ?MODULE, webadmin_user, 50),
|
||||||
ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE, webadmin_page, 50),
|
ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE, webadmin_page, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MIX_PAM_0,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MIX_PAM_0,
|
||||||
@ -77,6 +80,7 @@ stop(Host) ->
|
|||||||
ejabberd_hooks:delete(bounce_sm_packet, Host, ?MODULE, bounce_sm_packet, 50),
|
ejabberd_hooks:delete(bounce_sm_packet, Host, ?MODULE, bounce_sm_packet, 50),
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, disco_sm_features, 50),
|
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, disco_sm_features, 50),
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50),
|
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50),
|
||||||
|
ejabberd_hooks:delete(roster_get, Host, ?MODULE, get_mix_roster_items, 50),
|
||||||
ejabberd_hooks:delete(webadmin_user, Host, ?MODULE, webadmin_user, 50),
|
ejabberd_hooks:delete(webadmin_user, Host, ?MODULE, webadmin_user, 50),
|
||||||
ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE, webadmin_page, 50),
|
ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE, webadmin_page, 50),
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MIX_PAM_0).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MIX_PAM_0).
|
||||||
@ -208,6 +212,28 @@ process_iq(#iq{type = set,
|
|||||||
process_iq(IQ) ->
|
process_iq(IQ) ->
|
||||||
xmpp:make_error(IQ, unsupported_query_error(IQ)).
|
xmpp:make_error(IQ, unsupported_query_error(IQ)).
|
||||||
|
|
||||||
|
-spec get_mix_roster_items([#roster{}], {binary(), binary()}) -> [#roster{}].
|
||||||
|
get_mix_roster_items(Acc, {LUser, LServer}) ->
|
||||||
|
JID = jid:make(LUser, LServer),
|
||||||
|
case get_channels(JID) of
|
||||||
|
{ok, Channels} ->
|
||||||
|
lists:map(
|
||||||
|
fun({#jid{luser=Channel, lserver=Service}, Id}) ->
|
||||||
|
#roster{
|
||||||
|
jid = {Channel, Service, <<>>},
|
||||||
|
name = <<>>,
|
||||||
|
subscription = both,
|
||||||
|
ask = none,
|
||||||
|
groups = [<<"Channels">>],
|
||||||
|
askmessage = <<>>,
|
||||||
|
xs = [],
|
||||||
|
mix_participant_id = Id
|
||||||
|
}
|
||||||
|
end, Channels);
|
||||||
|
_ ->
|
||||||
|
[]
|
||||||
|
end ++ Acc.
|
||||||
|
|
||||||
-spec remove_user(binary(), binary()) -> ok | {error, db_failure}.
|
-spec remove_user(binary(), binary()) -> ok | {error, db_failure}.
|
||||||
remove_user(LUser, LServer) ->
|
remove_user(LUser, LServer) ->
|
||||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||||
|
@ -426,7 +426,11 @@ encode_item(Item) ->
|
|||||||
both -> subscribe;
|
both -> subscribe;
|
||||||
_ -> undefined
|
_ -> undefined
|
||||||
end,
|
end,
|
||||||
groups = Item#roster.groups}.
|
groups = Item#roster.groups,
|
||||||
|
mix_channel = case Item#roster.mix_participant_id of
|
||||||
|
<<>> -> undefined;
|
||||||
|
_ -> #mix_roster_channel{'participant-id' = Item#roster.mix_participant_id}
|
||||||
|
end}.
|
||||||
|
|
||||||
-spec decode_item(roster_item(), #roster{}, boolean()) -> #roster{}.
|
-spec decode_item(roster_item(), #roster{}, boolean()) -> #roster{}.
|
||||||
decode_item(#roster_item{subscription = remove} = Item, R, _) ->
|
decode_item(#roster_item{subscription = remove} = Item, R, _) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user