2016-12-27 10:44:07 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
2013-03-14 10:33:02 +01:00
|
|
|
%%%
|
2020-01-28 13:34:02 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2020 ProcessOne
|
2013-03-14 10:33:02 +01:00
|
|
|
%%%
|
2016-12-27 10:44:07 +01:00
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
2016-12-27 10:44:07 +01:00
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
2016-12-27 10:44:07 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License along
|
|
|
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%%
|
2016-12-27 10:44:07 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
%% -------------------------------
|
|
|
|
%% Pubsub constants
|
2015-04-08 17:12:05 +02:00
|
|
|
-define(ERR_EXTENDED(E, C), mod_pubsub:extended_error(E, C)).
|
2007-12-01 06:16:30 +01:00
|
|
|
|
2009-09-23 17:56:06 +02:00
|
|
|
%% The actual limit can be configured with mod_pubsub's option max_items_node
|
|
|
|
-define(MAXITEMS, 10).
|
|
|
|
|
2007-12-01 06:16:30 +01:00
|
|
|
%% this is currently a hard limit.
|
2019-07-29 16:13:16 +02:00
|
|
|
%% Would be nice to have it configurable.
|
2018-12-10 22:54:18 +01:00
|
|
|
-define(MAX_PAYLOAD_SIZE, 250000).
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
%% -------------------------------
|
|
|
|
%% Pubsub types
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(hostPubsub() :: binary()).
|
2010-10-21 11:14:24 +02:00
|
|
|
%% <p><tt>hostPubsub</tt> is the name of the PubSub service. For example, it can be
|
|
|
|
%% <tt>"pubsub.localhost"</tt>.</p>
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(hostPEP() :: {binary(), binary(), <<>>}).
|
2010-10-21 11:14:24 +02:00
|
|
|
%% @type hostPEP() = {User, Server, Resource}
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Resource = [].
|
|
|
|
%% <p>For example, it can be :
|
|
|
|
%% ```{"bob", "example.org", []}'''.</p>
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(host() :: hostPubsub() | hostPEP()).
|
2010-10-21 11:14:24 +02:00
|
|
|
%% @type host() = hostPubsub() | hostPEP().
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(nodeId() :: binary()).
|
2010-10-18 16:53:21 +02:00
|
|
|
%% @type nodeId() = binary().
|
|
|
|
%% <p>A node is defined by a list of its ancestors. The last element is the name
|
2013-03-14 10:33:02 +01:00
|
|
|
%% of the current node. For example:
|
2010-10-18 16:53:21 +02:00
|
|
|
%% ```<<"/home/localhost/user">>'''</p>
|
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
-type(nodeIdx() :: pos_integer() | binary()).
|
|
|
|
%% @type nodeIdx() = integer() | binary().
|
|
|
|
%% note: pos_integer() should always be used, but we allow anything else coded
|
|
|
|
%% as binary, so one can have a custom implementation of nodetree with custom
|
|
|
|
%% indexing (see nodetree_virtual). this also allows to use any kind of key for
|
2019-07-16 21:07:39 +02:00
|
|
|
%% indexing nodes, as this can be useful with external backends such as sql.
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(itemId() :: binary()).
|
2010-10-18 16:53:21 +02:00
|
|
|
%% @type itemId() = string().
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(subId() :: binary()).
|
2010-10-18 16:53:21 +02:00
|
|
|
%% @type subId() = string().
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(nodeOption() ::
|
|
|
|
{Option::atom(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Value::atom() | [binary()] | boolean() | non_neg_integer()
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
-type(nodeOptions() :: [mod_pubsub:nodeOption(),...]).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2010-10-21 11:14:24 +02:00
|
|
|
%% @type nodeOption() = {Option, Value}
|
|
|
|
%% Option = atom()
|
2010-10-18 16:53:21 +02:00
|
|
|
%% Value = term().
|
|
|
|
%% Example:
|
|
|
|
%% ```{deliver_payloads, true}'''
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(subOption() ::
|
|
|
|
{Option::atom(),
|
|
|
|
Value::binary() | [binary()] | boolean()
|
|
|
|
}).
|
|
|
|
|
2019-07-29 16:13:16 +02:00
|
|
|
-type(subOptions() :: [mod_pubsub:subOption()]).
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2015-07-01 17:18:32 +02:00
|
|
|
-type(pubOption() ::
|
|
|
|
{Option::binary(),
|
|
|
|
Values::[binary()]
|
|
|
|
}).
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2015-07-01 17:18:32 +02:00
|
|
|
-type(pubOptions() :: [mod_pubsub:pubOption()]).
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(affiliation() :: 'none'
|
|
|
|
| 'owner'
|
|
|
|
| 'publisher'
|
2015-04-22 18:10:35 +02:00
|
|
|
| 'publish_only'
|
2013-03-14 10:33:02 +01:00
|
|
|
| 'member'
|
|
|
|
| 'outcast'
|
|
|
|
).
|
2010-10-18 16:53:21 +02:00
|
|
|
%% @type affiliation() = 'none' | 'owner' | 'publisher' | 'publish-only' | 'member' | 'outcast'.
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(accessModel() :: 'open'
|
|
|
|
| 'presence'
|
|
|
|
| 'roster'
|
|
|
|
| 'authorize'
|
|
|
|
| 'whitelist'
|
|
|
|
).
|
2010-10-21 11:14:24 +02:00
|
|
|
%% @type accessModel() = 'open' | 'presence' | 'roster' | 'authorize' | 'whitelist'.
|
2010-10-18 16:53:21 +02:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-type(publishModel() :: 'publishers'
|
|
|
|
| 'subscribers'
|
|
|
|
| 'open'
|
|
|
|
).
|
2015-04-08 17:12:05 +02:00
|
|
|
%% @type publishModel() = 'publishers' | 'subscribers' | 'open'
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2010-10-18 16:53:21 +02:00
|
|
|
-record(pubsub_index,
|
|
|
|
{
|
2013-03-14 10:33:02 +01:00
|
|
|
index :: atom(),
|
|
|
|
last :: mod_pubsub:nodeIdx(),
|
|
|
|
free :: [mod_pubsub:nodeIdx()]
|
2007-12-01 06:16:30 +01:00
|
|
|
}).
|
|
|
|
|
2010-10-18 16:53:21 +02:00
|
|
|
-record(pubsub_node,
|
|
|
|
{
|
2015-04-08 17:12:05 +02:00
|
|
|
nodeid ,% :: {mod_pubsub:host(), mod_pubsub:nodeId()},
|
|
|
|
id ,% :: mod_pubsub:nodeIdx(),
|
|
|
|
parents = [] ,% :: [mod_pubsub:nodeId(),...],
|
|
|
|
type = <<"flat">>,% :: binary(),
|
2018-06-29 11:10:35 +02:00
|
|
|
owners = [] ,% :: [jid:ljid(),...],
|
2015-04-08 17:12:05 +02:00
|
|
|
options = [] % :: mod_pubsub:nodeOptions()
|
2010-10-18 16:53:21 +02:00
|
|
|
}).
|
|
|
|
|
|
|
|
-record(pubsub_state,
|
|
|
|
{
|
2018-06-29 11:10:35 +02:00
|
|
|
stateid ,% :: {jid:ljid(), mod_pubsub:nodeIdx()},
|
2017-03-30 14:26:30 +02:00
|
|
|
nodeidx ,% :: mod_pubsub:nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
items = [] ,% :: [mod_pubsub:itemId(),...],
|
|
|
|
affiliation = 'none',% :: mod_pubsub:affiliation(),
|
|
|
|
subscriptions = [] % :: [{mod_pubsub:subscription(), mod_pubsub:subId()}]
|
2010-10-18 16:53:21 +02:00
|
|
|
}).
|
|
|
|
|
|
|
|
-record(pubsub_item,
|
|
|
|
{
|
2015-04-08 17:12:05 +02:00
|
|
|
itemid ,% :: {mod_pubsub:itemId(), mod_pubsub:nodeIdx()},
|
2017-03-30 14:26:30 +02:00
|
|
|
nodeidx ,% :: mod_pubsub:nodeIdx(),
|
2018-06-29 11:10:35 +02:00
|
|
|
creation = {unknown, unknown},% :: {erlang:timestamp(), jid:ljid()},
|
|
|
|
modification = {unknown, unknown},% :: {erlang:timestamp(), jid:ljid()},
|
2015-04-08 17:12:05 +02:00
|
|
|
payload = [] % :: mod_pubsub:payload()
|
2010-10-18 16:53:21 +02:00
|
|
|
}).
|
|
|
|
|
|
|
|
-record(pubsub_subscription,
|
|
|
|
{
|
2015-04-08 17:12:05 +02:00
|
|
|
subid ,% :: mod_pubsub:subId(),
|
|
|
|
options = [] % :: mod_pubsub:subOptions()
|
2010-10-18 16:53:21 +02:00
|
|
|
}).
|
2010-05-28 11:56:09 +02:00
|
|
|
|
2010-10-18 16:53:21 +02:00
|
|
|
-record(pubsub_last_item,
|
|
|
|
{
|
2017-01-21 00:14:56 +01:00
|
|
|
nodeid ,% :: {binary(), mod_pubsub:nodeIdx()},
|
2015-04-08 17:12:05 +02:00
|
|
|
itemid ,% :: mod_pubsub:itemId(),
|
2018-06-29 11:10:35 +02:00
|
|
|
creation ,% :: {erlang:timestamp(), jid:ljid()},
|
2015-04-08 17:12:05 +02:00
|
|
|
payload % :: mod_pubsub:payload()
|
2010-10-18 16:53:21 +02:00
|
|
|
}).
|
2016-12-09 12:01:42 +01:00
|
|
|
|
|
|
|
-record(pubsub_orphan,
|
|
|
|
{
|
|
|
|
nodeid ,% :: mod_pubsub:nodeIdx(),
|
|
|
|
items = [] % :: list()
|
|
|
|
}).
|