mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-16 22:05:29 +02:00
support presence_delivery in cluster
SVN Revision: 702
This commit is contained in:
parent
827fb3d8e0
commit
cf3ec810d5
|
@ -40,6 +40,7 @@
|
||||||
-define(MAX_PAYLOAD_SIZE, 100000).
|
-define(MAX_PAYLOAD_SIZE, 100000).
|
||||||
|
|
||||||
-record(pubsub_node, {host_node, host_parent, info}).
|
-record(pubsub_node, {host_node, host_parent, info}).
|
||||||
|
-record(pubsub_presence, {key, presence}).
|
||||||
-record(nodeinfo, {items = [],
|
-record(nodeinfo, {items = [],
|
||||||
options = [],
|
options = [],
|
||||||
entities = ?DICT:new()
|
entities = ?DICT:new()
|
||||||
|
@ -118,6 +119,9 @@ init([ServerHost, Opts]) ->
|
||||||
mnesia:create_table(pubsub_node,
|
mnesia:create_table(pubsub_node,
|
||||||
[{disc_only_copies, [node()]},
|
[{disc_only_copies, [node()]},
|
||||||
{attributes, record_info(fields, pubsub_node)}]),
|
{attributes, record_info(fields, pubsub_node)}]),
|
||||||
|
mnesia:create_table(pubsub_presence,
|
||||||
|
[{ram_copies, [node()]},
|
||||||
|
{attributes, record_info(fields, pubsub_presence)}]),
|
||||||
Host = gen_mod:get_opt(host, Opts, "pubsub." ++ ServerHost),
|
Host = gen_mod:get_opt(host, Opts, "pubsub." ++ ServerHost),
|
||||||
update_table(Host),
|
update_table(Host),
|
||||||
mnesia:add_table_index(pubsub_node, host_parent),
|
mnesia:add_table_index(pubsub_node, host_parent),
|
||||||
|
@ -132,8 +136,6 @@ init([ServerHost, Opts]) ->
|
||||||
lists:foreach(fun(H) ->
|
lists:foreach(fun(H) ->
|
||||||
create_new_node(Host, ["home", H], ?MYJID)
|
create_new_node(Host, ["home", H], ?MYJID)
|
||||||
end, ServedHosts),
|
end, ServedHosts),
|
||||||
ets:new(gen_mod:get_module_proc(Host, pubsub_presence),
|
|
||||||
[set, named_table]),
|
|
||||||
{ok, #state{host = Host, server_host = ServerHost, access = Access}}.
|
{ok, #state{host = Host, server_host = ServerHost, access = Access}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -279,13 +281,9 @@ do_route(Host, ServerHost, Access, From, To, Packet) ->
|
||||||
Type = xml:get_attr_s("type", Attrs),
|
Type = xml:get_attr_s("type", Attrs),
|
||||||
if
|
if
|
||||||
(Type == "unavailable") or (Type == "error") ->
|
(Type == "unavailable") or (Type == "error") ->
|
||||||
ets:delete(
|
mnesia:dirty_delete(pubsub_presence, {Host, From#jid.luser, From#jid.lserver});
|
||||||
gen_mod:get_module_proc(Host, pubsub_presence),
|
|
||||||
{From#jid.luser, From#jid.lserver});
|
|
||||||
true ->
|
true ->
|
||||||
ets:insert(
|
mnesia:dirty_write(#pubsub_presence{key={Host, From#jid.luser, From#jid.lserver}, presence=[]})
|
||||||
gen_mod:get_module_proc(Host, pubsub_presence),
|
|
||||||
{{From#jid.luser, From#jid.lserver}, []})
|
|
||||||
end,
|
end,
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -1177,17 +1175,12 @@ broadcast_publish_item(Host, Node, ItemID, Payload) ->
|
||||||
Present = case get_node_option(
|
Present = case get_node_option(
|
||||||
Info, presence_based_delivery) of
|
Info, presence_based_delivery) of
|
||||||
true ->
|
true ->
|
||||||
case ets:lookup(
|
case mnesia:dirty_read(pubsub_presence, {Host, element(1, JID), element(2, JID)}) of
|
||||||
gen_mod:get_module_proc(Host, pubsub_presence),
|
[_] -> true;
|
||||||
{element(1, JID),
|
[] -> false
|
||||||
element(2, JID)}) of
|
end;
|
||||||
[_] ->
|
|
||||||
true;
|
|
||||||
[] ->
|
|
||||||
false
|
|
||||||
end;
|
|
||||||
false ->
|
false ->
|
||||||
true
|
true
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
(Subscription /= none) and
|
(Subscription /= none) and
|
||||||
|
@ -1300,17 +1293,12 @@ broadcast_config_notification(Host, Node, Lang) ->
|
||||||
Present = case get_node_option(
|
Present = case get_node_option(
|
||||||
Info, presence_based_delivery) of
|
Info, presence_based_delivery) of
|
||||||
true ->
|
true ->
|
||||||
case ets:lookup(
|
case mnesia:dirty_read(pubsub_presence, {Host, element(1, JID), element(2, JID)}) of
|
||||||
gen_mod:get_module_proc(Host, pubsub_presence),
|
[_] -> true;
|
||||||
{element(1, JID),
|
[] -> false
|
||||||
element(2, JID)}) of
|
end;
|
||||||
[_] ->
|
false ->
|
||||||
true;
|
true
|
||||||
[] ->
|
|
||||||
false
|
|
||||||
end;
|
|
||||||
false ->
|
|
||||||
true
|
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
(Subscription /= none) and
|
(Subscription /= none) and
|
||||||
|
|
Loading…
Reference in New Issue
Block a user