25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

improve type specification

This commit is contained in:
Christophe Romain 2010-09-20 16:54:37 +02:00
parent 9bde1dc9af
commit 2e75faefae
22 changed files with 240 additions and 146 deletions

View File

@ -49,8 +49,6 @@
-behaviour(gen_server).
-behaviour(gen_mod).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("adhoc.hrl").
-include("pubsub.hrl").
@ -2219,7 +2217,7 @@ delete_item(Host, Node, Publisher, ItemId, ForceNotify) ->
Options = TNode#pubsub_node.options,
broadcast_retract_items(Host, Node, Nidx, Type, Options, [ItemId], ForceNotify),
case get_cached_item(Host, Nidx) of
#pubsub_item{id = {ItemId, Nidx}, _ = '_'} -> unset_cached_item(Host, Nidx);
#pubsub_item{id = {ItemId, Nidx}} -> unset_cached_item(Host, Nidx);
_ -> ok
end,
case Result of

View File

@ -49,8 +49,6 @@
-behaviour(gen_server).
-behaviour(gen_mod).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("adhoc.hrl").
-include("pubsub.hrl").
@ -2029,7 +2027,7 @@ delete_item(Host, Node, Publisher, ItemId, ForceNotify) ->
Options = TNode#pubsub_node.options,
broadcast_retract_items(Host, Node, Nidx, Type, Options, [ItemId], ForceNotify),
case get_cached_item(Host, Nidx) of
#pubsub_item{id = {ItemId, Nidx}, _ = '_'} -> unset_cached_item(Host, Nidx);
#pubsub_item{id = {ItemId, Nidx}} -> unset_cached_item(Host, Nidx);
_ -> ok
end,
case Result of

View File

@ -26,8 +26,6 @@
-module(node_buddy).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").
-behaviour(gen_pubsub_node).

View File

@ -27,7 +27,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_node).

View File

@ -27,7 +27,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_node).

View File

@ -42,7 +42,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_node).

View File

@ -42,7 +42,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-include("jlib.hrl"). %% for rsm_in and rsm_out records definitions
-define(PUBSUB, mod_pubsub_odbc).

View File

@ -26,7 +26,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_node).

View File

@ -26,7 +26,6 @@
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_node).

View File

@ -36,8 +36,6 @@
-module(node_mb).
-author('eric@ohmforce.com').
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("pubsub.hrl").

View File

@ -29,8 +29,6 @@
-module(node_pep).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("pubsub.hrl").

View File

@ -29,8 +29,6 @@
-module(node_pep_odbc).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("pubsub.hrl").

View File

@ -26,8 +26,6 @@
-module(node_private).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").
-behaviour(gen_pubsub_node).

View File

@ -26,8 +26,6 @@
-module(node_public).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").
-behaviour(gen_pubsub_node).

View File

@ -39,7 +39,6 @@
-include("ejabberd.hrl").
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-behaviour(gen_pubsub_nodetree).

View File

@ -37,7 +37,6 @@
-author('christophe.romain@process-one.net').
-include_lib("stdlib/include/qlc.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").

View File

@ -36,7 +36,6 @@
-author('christophe.romain@process-one.net').
-include_lib("stdlib/include/qlc.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").

View File

@ -33,8 +33,6 @@
-module(nodetree_virtual).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
-include("pubsub.hrl").
-behaviour(gen_pubsub_nodetree).

View File

@ -21,6 +21,11 @@
%%% This file contains pubsub types definition.
%%% ====================================================================
-include_lib("exmpp/include/exmpp.hrl").
-include_lib("exmpp/include/exmpp_jid.hrl").
%% -------------------------------
%% Pubsub constants
-define(ERR_EXTENDED(E,C), mod_pubsub:extended_error(E,C)).
@ -32,15 +37,22 @@
%% Would be nice to have it configurable.
-define(MAX_PAYLOAD_SIZE, 60000).
%% -------------------------------
%% ------------
%% Pubsub types
%% ------------
%%% @type host() = binary().
%%%
%%% <p><tt>host</tt> is the name of the PubSub service. For example, it can be
%%% <tt>pubsub.localhost</tt>.</p>
%%% @type node() = binary().
%%% <p>A <tt>node</tt> is the name of a Node. It can be anything and may represent
-type(host() :: binary()).
%%% @type nodeId() = binary().
%%%
%%% <p>A <tt>nodeId</tt> is the name of a Node. It can be anything and may represent
%%% some hierarchical tree depending of the node type.
%%% For example:
%%% /home/localhost/user/node
@ -48,14 +60,66 @@
%%% http://jabber.org/protocol/tune
%%% My-Own_Node</p>
%%% @type item() = binary().
%%% <p>An <tt>item</tt> is the name of an Item. It can be anything.
-type(nodeId() :: binary()).
%%% @type itemId() = binary().
%%%
%%% <p>An <tt>itemId</tt> is the name of an Item. It can be anything.
%%% For example:
%%% 38964
%%% my-tune
%%% FD6SBE6a27d</p>
-type(itemId() :: binary()).
%%% @type subId() = binary().
-type(subId() :: binary()).
%%% @type nodeType() = string().
%%%
%%% <p>The <tt>nodeType</tt> is a string containing the name of the PubSub
%%% plugin to use to manage a given node. For example, it can be
%%% <tt>"flat"</tt>, <tt>"hometree"</tt> or <tt>"blog"</tt>.</p>
-type(nodeType() :: string()).
%%% @type ljid() = {User::binary(), Server::binary(), Resource::binary()}.
-type(ljid() :: {User::binary(), Server::binary(), Resource::binary()}).
%%% @type nodeIdx() = integer().
-type(nodeIdx() :: integer()).
%%% @type now() = {Megaseconds::integer(), Seconds::integer(), Microseconds::integer()}.
-type(now() :: {Megaseconds::integer(), Seconds::integer(), Microseconds::integer()}).
%%% @type affiliation() = none | owner | publisher | member | outcast.
-type(affiliation() :: none | owner | publisher | member | outcast).
%%% @type subscription() = none | pending | unconfigured | subscribed.
-type(subscription() :: none | pending | unconfigured | subscribed).
%%% @type payload() = string().
-type(payload() :: string()).
%%% @type stanzaError() = #xmlel{}.
%%%
%%% Example:
%%% ```#xmlel{name = 'error'
%%% ns = ?NS_STANZAS,
@ -73,7 +137,11 @@
%%% }
%%% ]}'''
-type(stanzaError() :: #xmlel{}).
%%% @type pubsubIQResponse() = #xmlel{}.
%%%
%%% Example:
%%% ```#xmlel{name = 'pubsub',
%%% ns = ?NS_PUBSUB,
@ -84,84 +152,139 @@
%%% ]
%%% }'''
%%% @type nodeOption() = {Option::atom(), Value::term()}.
-type(pubsubIQResponse() :: #xmlel{}).
%%% @type nodeOption() = {Option, Value}.
%%% Option = atom()
%%% Value = term().
%%%
%%% Example:
%%% ```{deliver_payloads, true}'''
%%% @type nodeType() = string().
%%% <p>The <tt>nodeType</tt> is a string containing the name of the PubSub
%%% plugin to use to manage a given node. For example, it can be
%%% <tt>"flat"</tt>, <tt>"hometree"</tt> or <tt>"blog"</tt>.</p>
-type(nodeOption() :: {Option::atom(), Value::term()}).
%%% @type ljid() = {User::binary(), Server::binary(), Resource::binary()}.
%%% @type subOption() = {Option, Value}.
%%% Option = atom()
%%% Value = term().
%%% @type nodeidx() = int()
-type(subOption() :: {Option::atom(), Value::term()}).
%%% @type affiliation() = none | owner | publisher | member | outcast.
%%% @type subscription() = none | pending | unconfigured | subscribed.
%%% internal pubsub index table
-record(pubsub_index, {index, last, free}).
%%% @type pubsubIndex() = {pubsub_index, Index, Last, Free}.
%%% Index = atom()
%%% Last = nodeIdx()
%%% Free = [nodeIdx()].
%%%
%%% Internal pubsub index table.
%%% @type pubsubNode() = #pubsub_node{
%%% id = {host(), node()},
%%% idx = nodeidx(),
%%% parents = [Node::pubsubNode()],
%%% type = nodeType(),
%%% owners = [ljid()],
%%% options = [nodeOption()]}.
-record(pubsub_index,
{
index :: atom(),
last :: integer(),
free :: [integer()]
}).
-type(pubsubIndex() :: #pubsub_index{}).
%%% @type pubsubNode() = {pubsub_node, Id, Idx, Parents, Type, Owners, Options}
%%% Id = {host(), nodeId()}
%%% Idx = nodeIdx()
%%% Parents = [nodeId()]
%%% Type = nodeType()
%%% Owners = [ljid()]
%%% Options = [nodeOption()].
%%%
%%% <p>This is the format of the <tt>nodes</tt> table. The type of the table
%%% is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
%%% <p>The <tt>parents</tt> and <tt>type</tt> fields are indexed.</p>
%%% <p><tt>nodeidx</tt> is an integer.</p>
-record(pubsub_node, {id,
idx,
parents = [],
type = "flat",
owners = [],
options = []
}).
%%% <p><tt>idx</tt> is an integer.</p>
%%% @type pubsubState() = #pubsub_state{
%%% id = {ljid(), nodeidx()},
%%% items = [item()],
%%% affiliation = affiliation(),
%%% subscriptions = [subscription()]}.
%%% <p>This is the format of the <tt>affiliations</tt> table. The type of the
%%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
-record(pubsub_state, {id,
items = [],
affiliation = none,
subscriptions = []
-record(pubsub_node,
{
id :: {host(), nodeId()},
idx :: nodeIdx(),
parents = [] :: [nodeId()],
type = "flat" :: nodeType(),
owners = [] :: [ljid()],
options = [] :: [nodeOption()]
}).
%%% @type pubsubItem() = #pubsub_item{
%%% id = {item(), nodeidx()},
%%% creation = {now(), ljid()},
%%% modification = {now(), ljid()},
%%% payload = XMLContent::string()}.
-type(pubsubNode() :: #pubsub_node{}).
%%% @type pubsubState() = {pubsub_state, Id, Items, Affiliation, Subscriptions}
%%% Id = {ljid(), nodeIdx()}
%%% Items = [itemId()]
%%% Affiliation = affiliation()
%%% Subscriptions = [subscription()].
%%%
%%% <p>This is the format of the <tt>affiliations</tt> table. The type of the
%%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
-record(pubsub_state,
{
id :: {ljid(), nodeIdx()},
items = [] :: [itemId()],
affiliation = none :: affiliation(),
subscriptions = [] :: [subscription()]
}).
-type(pubsubState() :: #pubsub_state{}).
%%% @type pubsubItem() = {pubsub_item, Id, Creation, Modification, Payload}
%%% Id = {itemId(), nodeIdx()}
%%% Creation = {now(), ljid()}
%%% Modification = {now(), ljid()}
%%% Payload = payload().
%%%
%%% <p>This is the format of the <tt>published items</tt> table. The type of the
%%% table is: <tt>set</tt>,<tt>disc</tt>,<tt>fragmented</tt>.</p>
-record(pubsub_item, {id,
creation = {unknown,unknown},
modification = {unknown,unknown},
payload = []
}).
%% @type pubsubSubscription() = #pubsub_subscription{
%% subid = string(),
%% state_key = {ljid(), nodeidx()},
%% options = [{atom(), term()}]
%% }.
-record(pubsub_item,
{
id :: {itemId(), nodeIdx()},
creation = {unknown,unknown} :: {now(), ljid()},
modification = {unknown,unknown} :: {now(), ljid()},
payload = [] :: payload()
}).
-type(pubsubItem() :: #pubsub_item{}).
%%% @type pubsubSubscription() = {pubsub_subscription, SubId, Options}
%%% SubId = subId()
%%% Options = [nodeOption()].
%%%
%% <p>This is the format of the <tt>subscriptions</tt> table. The type of the
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
-record(pubsub_subscription, {subid, options}).
%% @type pubsubLastItem() = #pubsub_last_item{
%% nodeid = nodeidx(),
%% itemid = item(),
%% creation = {now(), ljid()},
%% payload = XMLContent::string()}.
-record(pubsub_subscription,
{
subid :: subId(),
options :: [subOption()]
}).
-type(pubsubSubscription() :: #pubsub_subscription{}).
%%% @type pubsubLastItem() = {pubsub_last_item, NodeId, ItemId, Creation, Payload}
%%% NodeId = nodeIdx()
%%% ItemId = itemId()
%%% Creation = {now(), ljid()}()
%%% Payload = payload().
%%%
%% <p>This is the format of the <tt>last items</tt> table. it stores last item payload
%% for every node</p>
-record(pubsub_last_item, {nodeid, itemid, creation, payload}).
-record(pubsub_last_item,
{
nodeid :: nodeIdx(),
itemid :: itemId(),
creation :: {now(), ljid()},
payload :: payload()
}).
-type(pubsubLastItem() :: #pubsub_last_item{}).

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2010-09-10 18:04:47.000000000 +0200
+++ mod_pubsub_odbc.erl 2010-09-10 19:43:53.000000000 +0200
--- mod_pubsub.erl 2010-09-20 15:56:56.000000000 +0200
+++ mod_pubsub_odbc.erl 2010-09-20 16:50:49.000000000 +0200
@@ -42,7 +42,7 @@
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
%%% XEP-0060 section 12.18.
@ -9,7 +9,7 @@
-author('christophe.romain@process-one.net').
-version('1.13-0').
@@ -55,9 +55,9 @@
@@ -53,9 +53,9 @@
-include("adhoc.hrl").
-include("pubsub.hrl").
@ -22,7 +22,7 @@
%% exports for hooks
-export([presence_probe/3,
@@ -104,7 +104,7 @@
@@ -102,7 +102,7 @@
string_to_affiliation/1,
extended_error/2,
extended_error/3,
@ -31,7 +31,7 @@
]).
%% API and gen_server callbacks
@@ -123,7 +123,7 @@
@@ -121,7 +121,7 @@
-export([send_loop/1
]).
@ -40,7 +40,7 @@
-define(LOOPNAME, ejabberd_mod_pubsub_loop).
-define(PLUGIN_PREFIX, "node_").
-define(TREE_PREFIX, "nodetree_").
@@ -220,8 +220,6 @@
@@ -218,8 +218,6 @@
ok
end,
ejabberd_router:register_route(Host),
@ -49,7 +49,7 @@
init_nodes(Host, ServerHost, NodeTree, Plugins),
State = #state{host = Host,
server_host = ServerHost,
@@ -280,209 +278,14 @@
@@ -278,209 +276,14 @@
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
%% TODO, this call should be done plugin side
@ -262,7 +262,7 @@
send_loop(State) ->
receive
{presence, JID, Pid} ->
@@ -493,7 +296,10 @@
@@ -491,7 +294,10 @@
%% for each node From is subscribed to
%% and if the node is so configured, send the last published item to From
lists:foreach(fun(PType) ->
@ -274,7 +274,7 @@
lists:foreach(
fun({Node, subscribed, _, SubJID}) ->
if (SubJID == LJID) or (SubJID == BJID) ->
@@ -618,7 +424,8 @@
@@ -616,7 +422,8 @@
[#xmlel{name = 'identity', ns = ?NS_DISCO_INFO,
attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}];
disco_identity(Host, Node, From) ->
@ -284,7 +284,7 @@
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
{result, _} ->
{result,
@@ -649,7 +456,8 @@
@@ -647,7 +454,8 @@
[?NS_PUBSUB_s
| [?NS_PUBSUB_s++"#"++Feature || Feature <- features("pep")]];
disco_features(Host, Node, From) ->
@ -294,7 +294,7 @@
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
{result, _} ->
{result, [?NS_PUBSUB_s
@@ -668,7 +476,8 @@
@@ -666,7 +474,8 @@
{result, disco_items(To, Node, From) ++ OtherItems}.
disco_items(Host, <<>>, From) ->
@ -304,7 +304,7 @@
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
{result, _} ->
[#xmlel{name = 'item', ns = ?NS_DISCO_INFO,
@@ -682,13 +491,14 @@
@@ -680,13 +489,14 @@
_ -> Acc
end
end,
@ -321,7 +321,7 @@
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
{result, Items} ->
{result,
@@ -774,10 +584,10 @@
@@ -772,10 +582,10 @@
lists:foreach(fun(PType) ->
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
lists:foreach(fun
@ -334,7 +334,7 @@
true ->
node_action(Host, PType, unsubscribe_node, [Nidx, Entity, JID, all]);
false ->
@@ -952,10 +762,11 @@
@@ -950,10 +760,11 @@
end,
ejabberd_router:route(To, From, Res);
#iq{type = get, ns = ?NS_DISCO_ITEMS,
@ -348,7 +348,7 @@
{result, IQRes} ->
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
name = 'query', attrs = QAttrs,
@@ -1092,7 +903,7 @@
@@ -1090,7 +901,7 @@
[] ->
["leaf"]; %% No sub-nodes: it's a leaf node
_ ->
@ -357,7 +357,7 @@
{result, []} -> ["collection"];
{result, _} -> ["leaf", "collection"];
_ -> []
@@ -1108,8 +919,9 @@
@@ -1106,8 +917,9 @@
[];
true ->
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
@ -369,7 +369,7 @@
end, features(Type))]
end,
%% TODO: add meta-data info (spec section 5.4)
@@ -1138,8 +950,9 @@
@@ -1136,8 +948,9 @@
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
@ -381,7 +381,7 @@
end, features(Host, Node))};
?NS_ADHOC_b ->
command_disco_info(Host, Node, From);
@@ -1149,7 +962,7 @@
@@ -1147,7 +960,7 @@
node_disco_info(Host, Node, From)
end.
@ -390,7 +390,7 @@
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
Nodes when is_list(Nodes) ->
{result, lists:map(
@@ -1166,7 +979,7 @@
@@ -1164,7 +977,7 @@
Other ->
Other
end;
@ -399,7 +399,7 @@
%% TODO: support localization of this string
CommandItems = [
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
@@ -1175,19 +988,20 @@
@@ -1173,19 +986,20 @@
?XMLATTR('name', "Get Pending")
]}],
{result, CommandItems};
@ -425,7 +425,7 @@
end,
Nodes = lists:map(
fun(#pubsub_node{id = {_, SubNode}, options = SubOptions}) ->
@@ -1205,7 +1019,7 @@
@@ -1203,7 +1017,7 @@
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('name', Name)]}
end, NodeItems),
@ -434,7 +434,7 @@
end,
case transaction(Host, Node, Action, sync_dirty) of
{result, {_, Result}} -> {result, Result};
@@ -1213,12 +1027,6 @@
@@ -1211,12 +1025,6 @@
end
end.
@ -447,7 +447,7 @@
get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups) ->
if (AccessModel == presence) or (AccessModel == roster) ->
case Host of
@@ -1336,7 +1144,7 @@
@@ -1334,7 +1142,7 @@
(_, Acc) ->
Acc
end, [], exmpp_xml:remove_cdata_from_list(Els)),
@ -456,7 +456,7 @@
{get, 'subscriptions'} ->
get_subscriptions(Host, Node, From, Plugins);
{get, 'affiliations'} ->
@@ -1493,7 +1301,8 @@
@@ -1491,7 +1299,8 @@
_ -> []
end
end,
@ -466,7 +466,7 @@
sync_dirty) of
{result, Res} -> Res;
Err -> Err
@@ -1537,7 +1346,7 @@
@@ -1535,7 +1344,7 @@
%%% authorization handling
@ -475,7 +475,7 @@
Lang = <<"en">>, %% TODO fix
{U, S, R} = Subscriber,
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
@@ -1567,7 +1376,7 @@
@@ -1565,7 +1374,7 @@
lists:foreach(fun(Owner) ->
{U, S, R} = Owner,
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
@ -484,7 +484,7 @@
find_authorization_response(Packet) ->
Els = Packet#xmlel.children,
@@ -1626,8 +1435,8 @@
@@ -1624,8 +1433,8 @@
"true" -> true;
_ -> false
end,
@ -495,7 +495,7 @@
{result, Subscriptions} = node_call(Type, get_subscriptions, [Nidx, Subscriber]),
if
not IsApprover ->
@@ -1826,7 +1635,7 @@
@@ -1824,7 +1633,7 @@
end,
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
@ -504,7 +504,7 @@
{result, {NodeId, SubsByDepth, {Result, broadcast}}} ->
broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth),
case Result of
@@ -1930,7 +1739,7 @@
@@ -1928,7 +1737,7 @@
%%<li>The node does not exist.</li>
%%</ul>
subscribe_node(Host, Node, From, JID, Configuration) ->
@ -513,7 +513,7 @@
{result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid
end,
@@ -1940,7 +1749,7 @@
@@ -1938,7 +1747,7 @@
_:_ ->
{undefined, undefined, undefined}
end,
@ -522,7 +522,7 @@
Features = features(Type),
SubscribeFeature = lists:member("subscribe", Features),
OptionsFeature = lists:member("subscription-options", Features),
@@ -1949,6 +1758,7 @@
@@ -1947,6 +1756,7 @@
AccessModel = get_option(Options, access_model),
SendLast = get_option(Options, send_last_published_item),
AllowedGroups = get_option(Options, roster_groups_allowed, []),
@ -530,7 +530,7 @@
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
if
not SubscribeFeature ->
@@ -2293,7 +2103,7 @@
@@ -2291,7 +2101,7 @@
%% <p>The permission are not checked in this function.</p>
%% @todo We probably need to check that the user doing the query has the right
%% to read the items.
@ -539,7 +539,7 @@
MaxItems =
if
SMaxItems == "" -> get_max_items_node(Host);
@@ -2307,12 +2117,13 @@
@@ -2305,12 +2115,13 @@
{error, Error} ->
{error, Error};
_ ->
@ -554,7 +554,7 @@
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
if
not RetreiveFeature ->
@@ -2325,11 +2136,11 @@
@@ -2323,11 +2134,11 @@
node_call(Type, get_items,
[Nidx, From,
AccessModel, PresenceSubscription, RosterGroup,
@ -568,7 +568,7 @@
SendItems = case ItemIds of
[] ->
Items;
@@ -2342,7 +2153,7 @@
@@ -2340,7 +2151,7 @@
%% number of items sent to MaxItems:
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
@ -577,7 +577,7 @@
Error ->
Error
end
@@ -2365,6 +2176,17 @@
@@ -2363,6 +2174,17 @@
{result, {_, Items}} -> Items;
Error -> Error
end.
@ -595,7 +595,7 @@
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
%% Host = pubsubHost()
@@ -2376,16 +2198,29 @@
@@ -2374,16 +2196,29 @@
%% @doc <p>Resend the items of a node to the user.</p>
%% @todo use cache-last-item feature
send_items(Host, Node, NodeId, Type, LJID, last) ->
@ -631,7 +631,7 @@
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
{result, []} ->
@@ -2512,7 +2347,8 @@
@@ -2510,7 +2345,8 @@
error ->
{error, 'bad-request'};
_ ->
@ -641,7 +641,7 @@
case lists:member(Owner, Owners) of
true ->
OwnerJID = exmpp_jid:make(Owner),
@@ -2522,24 +2358,8 @@
@@ -2520,24 +2356,8 @@
end,
lists:foreach(
fun({JID, Affiliation}) ->
@ -668,7 +668,7 @@
end, FilteredEntities),
{result, []};
_ ->
@@ -2594,11 +2414,11 @@
@@ -2592,11 +2412,11 @@
end.
read_sub(Subscriber, Node, NodeId, SubId, Lang) ->
@ -682,7 +682,7 @@
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
?XMLATTR('subid', SubId) | nodeAttr(Node)],
@@ -2625,7 +2445,7 @@
@@ -2623,7 +2443,7 @@
end.
set_options_helper(Configuration, JID, NodeId, SubId, Type) ->
@ -691,7 +691,7 @@
{result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid
end,
@@ -2655,7 +2475,7 @@
@@ -2653,7 +2473,7 @@
write_sub(_Subscriber, _NodeId, _SubId, invalid) ->
{error, extended_error('bad-request', "invalid-options")};
write_sub(Subscriber, NodeId, SubId, Options) ->
@ -700,7 +700,7 @@
{error, notfound} ->
{error, extended_error('not-acceptable', "invalid-subid")};
{result, _} ->
@@ -2829,8 +2649,8 @@
@@ -2827,8 +2647,8 @@
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
ejabberd_router:route(service_jid(Host), JID, Stanza)
end,
@ -711,7 +711,7 @@
true ->
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
@@ -3179,7 +2999,7 @@
@@ -3177,7 +2997,7 @@
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
end,
@ -720,7 +720,7 @@
{result, CollSubs} -> CollSubs;
_ -> []
end.
@@ -3192,7 +3012,7 @@
@@ -3190,7 +3010,7 @@
get_options_for_subs(Nidx, Subs) ->
lists:foldl(fun({JID, subscribed, SubId}, Acc) ->
@ -729,7 +729,7 @@
{error, notfound} -> [{JID, SubId, []} | Acc];
#pubsub_subscription{options = Options} -> [{JID, SubId, Options} | Acc];
_ -> Acc
@@ -3416,6 +3236,30 @@
@@ -3414,6 +3234,30 @@
Result
end.
@ -760,7 +760,7 @@
%% @spec (Host, Options) -> MaxItems
%% Host = host()
%% Options = [Option]
@@ -3819,7 +3663,13 @@
@@ -3817,7 +3661,13 @@
tree_action(Host, Function, Args) ->
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
Fun = fun() -> tree_call(Host, Function, Args) end,
@ -775,7 +775,7 @@
%% @doc <p>node plugin call.</p>
node_call(Type, Function, Args) ->
@@ -3839,13 +3689,13 @@
@@ -3837,13 +3687,13 @@
node_action(Host, Type, Function, Args) ->
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
@ -791,7 +791,7 @@
case tree_call(Host, get_node, [Host, Node]) of
N when is_record(N, pubsub_node) ->
case Action(N) of
@@ -3858,13 +3708,20 @@
@@ -3856,13 +3706,20 @@
end
end, Trans).
@ -816,7 +816,7 @@
{result, Result} -> {result, Result};
{error, Error} -> {error, Error};
{atomic, {result, Result}} -> {result, Result};
@@ -3872,6 +3729,15 @@
@@ -3870,6 +3727,15 @@
{aborted, Reason} ->
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
{error, 'internal-server-error'};
@ -832,7 +832,7 @@
{'EXIT', Reason} ->
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
{error, 'internal-server-error'};
@@ -3880,6 +3746,16 @@
@@ -3878,6 +3744,16 @@
{error, 'internal-server-error'}
end.

View File

@ -39,7 +39,6 @@
write_subscription/4]).
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-define(PUBSUB_DELIVER, "pubsub#deliver").
-define(PUBSUB_DIGEST, "pubsub#digest").

View File

@ -37,7 +37,6 @@
-include_lib("stdlib/include/qlc.hrl").
-include("pubsub.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-define(PUBSUB_DELIVER, "pubsub#deliver").
-define(PUBSUB_DIGEST, "pubsub#digest").