mirror of
https://github.com/processone/ejabberd.git
synced 2025-01-01 17:53:00 +01:00
* src/mod_pubsub/gen_pubsub_node.erl: API improvement: Added a way to generate custom item name
* src/mod_pubsub/node_dispatch.erl: Likewise * src/mod_pubsub/node_buddy.erl: Likewise * src/mod_pubsub/node_private.erl: Likewise * src/mod_pubsub/node_club.erl: Likewise * src/mod_pubsub/node_public.erl: Likewise * src/mod_pubsub/node_default.erl: Likewise * src/mod_pubsub/node_pep.erl: Likewise * src/mod_pubsub/mod_pubsub.erl: Small API improvements and refactoring SVN Revision: 1173
This commit is contained in:
parent
ba419eae59
commit
4e096f1590
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2008-02-06 Mickael Remond <mremond@process-one.net>
|
||||
|
||||
* src/mod_pubsub/gen_pubsub_node.erl: API improvement: Added a way
|
||||
to generate custom item name
|
||||
* src/mod_pubsub/node_dispatch.erl: Likewise
|
||||
* src/mod_pubsub/node_buddy.erl: Likewise
|
||||
* src/mod_pubsub/node_private.erl: Likewise
|
||||
* src/mod_pubsub/node_club.erl: Likewise
|
||||
* src/mod_pubsub/node_public.erl: Likewise
|
||||
* src/mod_pubsub/node_default.erl: Likewise
|
||||
* src/mod_pubsub/node_pep.erl: Likewise
|
||||
* src/mod_pubsub/mod_pubsub.erl: Small API improvements and
|
||||
refactoring
|
||||
|
||||
2008-02-04 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/ejabberd.hrl: Updated version to 2.1.0-alpha
|
||||
|
@ -64,7 +64,8 @@ behaviour_info(callbacks) ->
|
||||
{set_state, 1},
|
||||
{get_items, 2},
|
||||
{get_item, 3},
|
||||
{set_item, 1}
|
||||
{set_item, 1},
|
||||
{get_item_name, 3}
|
||||
];
|
||||
behaviour_info(_Other) ->
|
||||
undefined.
|
||||
|
@ -89,7 +89,9 @@
|
||||
string_to_subscription/1,
|
||||
string_to_affiliation/1,
|
||||
extended_error/2,
|
||||
extended_error/3
|
||||
extended_error/3,
|
||||
make_stanza/3,
|
||||
route_stanza/3
|
||||
]).
|
||||
|
||||
%% API and gen_server callbacks
|
||||
@ -386,7 +388,7 @@ disco_sm_items(Acc, _From, To, Node, _Lang) ->
|
||||
%% "node" is forbidden by XEP-0060.
|
||||
{xmlelement, "item",
|
||||
[{"jid", jlib:jid_to_string(LJID)},
|
||||
{"name", Id}],
|
||||
{"name", get_item_name(Host, Node, Id)}],
|
||||
[]}
|
||||
end, AllItems),
|
||||
{result, NodeItems ++ Items}
|
||||
@ -770,12 +772,14 @@ iq_disco_items(Host, Item, From) ->
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
SN = node_to_string(SubNode),
|
||||
RN = lists:last(SubNode),
|
||||
{xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", RN}], []}
|
||||
{xmlelement, "item", [{"jid", Host}, {"node", SN},
|
||||
{"name", RN}], []}
|
||||
end, tree_call(Host, get_subnodes, [Host, Node, From])),
|
||||
Items = lists:map(
|
||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||
SN = node_to_string(Node) ++ "!" ++ RN,
|
||||
{xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", RN}], []}
|
||||
{xmlelement, "item", [{"jid", Host}, {"node", SN},
|
||||
{"name", get_item_name(Host, Node, RN)}], []}
|
||||
end, NodeItems),
|
||||
{result, Nodes ++ Items}
|
||||
end,
|
||||
@ -2055,11 +2059,7 @@ broadcast_publish_item(Host, Node, ItemId, _From, Payload) ->
|
||||
"" -> [];
|
||||
_ -> [{"id", ItemId}]
|
||||
end,
|
||||
Stanza = {xmlelement, "message", [],
|
||||
[{xmlelement, "event",
|
||||
[{"xmlns", ?NS_PUBSUB_EVENT}],
|
||||
[{xmlelement, "items", [{"node", node_to_string(Node)}],
|
||||
[{xmlelement, "item", ItemAttrs, Content}]}]}]},
|
||||
Stanza = make_stanza(Node, ItemAttrs, Content),
|
||||
lists:foreach(
|
||||
fun(#pubsub_state{stateid = {LJID, _},
|
||||
subscription = Subscription}) ->
|
||||
@ -2069,10 +2069,7 @@ broadcast_publish_item(Host, Node, ItemId, _From, Payload) ->
|
||||
true -> ejabberd_sm:get_user_resources(element(1, LJID), element(2, LJID));
|
||||
false -> [LJID]
|
||||
end,
|
||||
lists:foreach(
|
||||
fun(DestJID) ->
|
||||
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(DestJID), Stanza}
|
||||
end, DestJIDs);
|
||||
route_stanza(Host, DestJIDs, Stanza);
|
||||
false ->
|
||||
ok
|
||||
end
|
||||
@ -2083,6 +2080,22 @@ broadcast_publish_item(Host, Node, ItemId, _From, Payload) ->
|
||||
end,
|
||||
transaction(Host, Node, Action, sync_dirty).
|
||||
|
||||
%% ItemAttrs is a list of tuples:
|
||||
%% For example: [{"id", ItemId}]
|
||||
make_stanza(Node, ItemAttrs, Payload) ->
|
||||
{xmlelement, "message", [],
|
||||
[{xmlelement, "event",
|
||||
[{"xmlns", ?NS_PUBSUB_EVENT}],
|
||||
[{xmlelement, "items", [{"node", node_to_string(Node)}],
|
||||
[{xmlelement, "item", ItemAttrs, Payload}]}]}]}.
|
||||
|
||||
%% DestJIDs = [{LUser, LServer, LResource}]
|
||||
route_stanza(Host, DestJIDs, Stanza) ->
|
||||
lists:foreach(
|
||||
fun(DestJID) ->
|
||||
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(DestJID), Stanza}
|
||||
end, DestJIDs).
|
||||
|
||||
broadcast_retract_item(Host, Node, ItemId) ->
|
||||
broadcast_retract_item(Host, Node, ItemId, false).
|
||||
broadcast_retract_item(Host, Node, ItemId, ForceNotify) ->
|
||||
@ -2725,3 +2738,8 @@ extended_error({xmlelement, Error, Attrs, SubEls}, Ext, ExtAttrs) ->
|
||||
uniqid() ->
|
||||
{T1, T2, T3} = now(),
|
||||
lists:flatten(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
|
||||
|
||||
%% @doc Return the name of a given node if available.
|
||||
get_item_name(Host, Node, Id) ->
|
||||
{result, Name} = node_action(Host, Node, get_item_name, [Host, Node, Id]),
|
||||
Name.
|
||||
|
@ -64,7 +64,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
|
||||
@ -176,3 +177,6 @@ get_item(Host, Node, ItemId) ->
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
@ -64,7 +64,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
|
||||
@ -176,3 +177,6 @@ get_item(Host, Node, ItemId) ->
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
@ -71,7 +71,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
%% ================
|
||||
@ -726,3 +727,8 @@ set_item(Item) when is_record(Item, pubsub_item) ->
|
||||
mnesia:write(Item);
|
||||
set_item(_) ->
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}.
|
||||
|
||||
%% @doc <p>Return the name of the node if known: Default is to return
|
||||
%% node id.</p>
|
||||
get_item_name(_Host, _Node, Id) ->
|
||||
Id.
|
||||
|
@ -62,7 +62,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
|
||||
@ -179,3 +180,6 @@ get_item(Host, Node, ItemId) ->
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
@ -59,7 +59,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
init(Host, ServerHost, Opts) ->
|
||||
@ -204,3 +205,6 @@ get_item(Host, Node, ItemId) ->
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
@ -64,7 +64,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
|
||||
@ -179,3 +180,6 @@ get_item(Host, Node, ItemId) ->
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
@ -64,7 +64,8 @@
|
||||
set_state/1,
|
||||
get_items/2,
|
||||
get_item/3,
|
||||
set_item/1
|
||||
set_item/1,
|
||||
get_item_name/3
|
||||
]).
|
||||
|
||||
|
||||
@ -172,7 +173,12 @@ get_items(Host, Node) ->
|
||||
node_default:get_items(Host, Node).
|
||||
|
||||
get_item(Host, Node, ItemId) ->
|
||||
node_default:get_items(Host, Node, ItemId).
|
||||
node_default:get_item(Host, Node, ItemId).
|
||||
|
||||
set_item(Item) ->
|
||||
node_default:set_item(Item).
|
||||
|
||||
%% @doc <p>Return the name of the node if known: Default is to return
|
||||
%% node id.</p>
|
||||
get_item_name(Host, Node, Id) ->
|
||||
node_default:get_item_name(Host, Node, Id).
|
||||
|
Loading…
Reference in New Issue
Block a user