2008-12-02 20:23:12 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%%
|
2022-02-10 17:21:43 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2022 ProcessOne
|
2008-12-02 20:23:12 +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.
|
|
|
|
%%%
|
|
|
|
%%% 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.
|
2009-01-12 15:44:42 +01:00
|
|
|
%%%
|
2014-02-22 11:27:40 +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.
|
2008-12-02 20:23:12 +01:00
|
|
|
%%%
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-define(MAX_USERS_DEFAULT, 200).
|
|
|
|
|
|
|
|
-define(SETS, gb_sets).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-record(lqueue,
|
|
|
|
{
|
2019-06-28 21:16:29 +02:00
|
|
|
queue = p1_queue:new() :: p1_queue:queue(lqueue_elem()),
|
2019-06-14 11:33:26 +02:00
|
|
|
max = 0 :: integer()
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
|
|
|
|
|
|
|
-type lqueue() :: #lqueue{}.
|
2019-06-14 11:33:26 +02:00
|
|
|
-type lqueue_elem() :: {binary(), message(), boolean(),
|
|
|
|
erlang:timestamp(), non_neg_integer()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-record(config,
|
|
|
|
{
|
|
|
|
title = <<"">> :: binary(),
|
|
|
|
description = <<"">> :: binary(),
|
|
|
|
allow_change_subj = true :: boolean(),
|
|
|
|
allow_query_users = true :: boolean(),
|
|
|
|
allow_private_messages = true :: boolean(),
|
|
|
|
allow_private_messages_from_visitors = anyone :: anyone | moderators | nobody ,
|
|
|
|
allow_visitor_status = true :: boolean(),
|
|
|
|
allow_visitor_nickchange = true :: boolean(),
|
|
|
|
public = true :: boolean(),
|
|
|
|
public_list = true :: boolean(),
|
|
|
|
persistent = false :: boolean(),
|
|
|
|
moderated = true :: boolean(),
|
|
|
|
captcha_protected = false :: boolean(),
|
|
|
|
members_by_default = true :: boolean(),
|
|
|
|
members_only = false :: boolean(),
|
|
|
|
allow_user_invites = false :: boolean(),
|
2016-06-26 08:08:37 +02:00
|
|
|
allow_subscription = false :: boolean(),
|
2013-03-14 10:33:02 +01:00
|
|
|
password_protected = false :: boolean(),
|
|
|
|
password = <<"">> :: binary(),
|
|
|
|
anonymous = true :: boolean(),
|
2015-11-12 17:51:20 +01:00
|
|
|
presence_broadcast = [moderator, participant, visitor] ::
|
|
|
|
[moderator | participant | visitor],
|
2013-03-14 10:33:02 +01:00
|
|
|
allow_voice_requests = true :: boolean(),
|
|
|
|
voice_request_min_interval = 1800 :: non_neg_integer(),
|
|
|
|
max_users = ?MAX_USERS_DEFAULT :: non_neg_integer() | none,
|
|
|
|
logging = false :: boolean(),
|
2015-02-11 12:08:16 +01:00
|
|
|
vcard = <<"">> :: binary(),
|
2018-02-12 15:37:36 +01:00
|
|
|
vcard_xupdate = undefined :: undefined | external | binary(),
|
2018-06-14 18:19:09 +02:00
|
|
|
captcha_whitelist = (?SETS):empty() :: gb_sets:set(),
|
2017-11-27 11:07:10 +01:00
|
|
|
mam = false :: boolean(),
|
2018-05-30 07:11:58 +02:00
|
|
|
pubsub = <<"">> :: binary(),
|
2021-10-29 04:12:26 +02:00
|
|
|
enable_hats = false :: boolean(),
|
2019-06-14 11:33:26 +02:00
|
|
|
lang = ejabberd_option:language() :: binary()
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
|
|
|
|
|
|
|
-type config() :: #config{}.
|
|
|
|
|
|
|
|
-type role() :: moderator | participant | visitor | none.
|
2016-07-25 12:50:30 +02:00
|
|
|
-type affiliation() :: admin | member | outcast | owner | none.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-record(user,
|
|
|
|
{
|
|
|
|
jid :: jid(),
|
|
|
|
nick :: binary(),
|
|
|
|
role :: role(),
|
2016-09-07 09:33:37 +02:00
|
|
|
%%is_subscriber = false :: boolean(),
|
|
|
|
%%subscriptions = [] :: [binary()],
|
2017-02-18 07:36:27 +01:00
|
|
|
last_presence :: presence() | undefined
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
2008-12-02 20:23:12 +01:00
|
|
|
|
2016-09-07 09:33:37 +02:00
|
|
|
-record(subscriber, {jid :: jid(),
|
|
|
|
nick = <<>> :: binary(),
|
|
|
|
nodes = [] :: [binary()]}).
|
|
|
|
|
2021-09-13 07:15:11 +02:00
|
|
|
-record(muc_subscribers,
|
|
|
|
{subscribers = #{} :: subscribers(),
|
|
|
|
subscriber_nicks = #{} :: subscriber_nicks(),
|
|
|
|
subscriber_nodes = #{} :: subscriber_nodes()
|
|
|
|
}).
|
|
|
|
|
|
|
|
-type subscribers() :: #{ljid() => #subscriber{}}.
|
|
|
|
-type subscriber_nicks() :: #{binary() => [ljid()]}.
|
|
|
|
-type subscriber_nodes() :: #{binary() => subscribers()}.
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-record(activity,
|
|
|
|
{
|
|
|
|
message_time = 0 :: integer(),
|
|
|
|
presence_time = 0 :: integer(),
|
2019-06-14 11:33:26 +02:00
|
|
|
message_shaper = none :: ejabberd_shaper:shaper(),
|
|
|
|
presence_shaper = none :: ejabberd_shaper:shaper(),
|
2017-02-18 07:36:27 +01:00
|
|
|
message :: message() | undefined,
|
|
|
|
presence :: {binary(), presence()} | undefined
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
2008-12-02 20:23:12 +01:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-record(state,
|
|
|
|
{
|
|
|
|
room = <<"">> :: binary(),
|
|
|
|
host = <<"">> :: binary(),
|
|
|
|
server_host = <<"">> :: binary(),
|
2019-01-10 15:07:10 +01:00
|
|
|
access = {none,none,none,none,none} :: {atom(), atom(), atom(), atom(), atom()},
|
2013-03-14 10:33:02 +01:00
|
|
|
jid = #jid{} :: jid(),
|
|
|
|
config = #config{} :: config(),
|
2019-06-27 14:22:27 +02:00
|
|
|
users = #{} :: users(),
|
2021-09-13 07:15:11 +02:00
|
|
|
muc_subscribers = #muc_subscribers{} :: #muc_subscribers{},
|
2013-03-14 10:33:02 +01:00
|
|
|
last_voice_request_time = treap:empty() :: treap:treap(),
|
2019-06-27 14:22:27 +02:00
|
|
|
robots = #{} :: robots(),
|
|
|
|
nicks = #{} :: nicks(),
|
|
|
|
affiliations = #{} :: affiliations(),
|
2021-10-01 12:11:51 +02:00
|
|
|
roles = #{} :: roles(),
|
2019-06-14 11:33:26 +02:00
|
|
|
history = #lqueue{} :: lqueue(),
|
2017-11-13 09:29:03 +01:00
|
|
|
subject = [] :: [text()],
|
2013-03-14 10:33:02 +01:00
|
|
|
subject_author = <<"">> :: binary(),
|
2021-10-31 21:59:00 +01:00
|
|
|
hats_users = #{} :: map(), % FIXME on OTP 21+: #{ljid() => #{binary() => binary()}},
|
2019-02-27 09:56:20 +01:00
|
|
|
just_created = erlang:system_time(microsecond) :: true | integer(),
|
2013-03-14 10:33:02 +01:00
|
|
|
activity = treap:empty() :: treap:treap(),
|
2019-06-14 11:33:26 +02:00
|
|
|
room_shaper = none :: ejabberd_shaper:shaper(),
|
2019-07-16 13:57:48 +02:00
|
|
|
room_queue :: p1_queue:queue({message | presence, jid()}) | undefined,
|
|
|
|
hibernate_timer = none :: reference() | none | hibernating
|
2013-03-14 10:33:02 +01:00
|
|
|
}).
|
2019-06-27 14:22:27 +02:00
|
|
|
|
|
|
|
-type users() :: #{ljid() => #user{}}.
|
|
|
|
-type robots() :: #{jid() => {binary(), stanza()}}.
|
|
|
|
-type nicks() :: #{binary() => [ljid()]}.
|
|
|
|
-type affiliations() :: #{ljid() => affiliation() | {affiliation(), binary()}}.
|
2021-10-01 12:11:51 +02:00
|
|
|
-type roles() :: #{ljid() => role() | {role(), binary()}}.
|