• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

processone / ejabberd / 1212

18 Nov 2025 12:37PM UTC coverage: 33.784% (+0.003%) from 33.781%
1212

push

github

badlop
mod_conversejs: Improve link to conversejs in WebAdmin (#4495)

Until now, the WebAdmin menu included a link to the first request handler
with mod_conversejs that the admin configured in ejabberd.yml
That link included the authentication credentials hashed as URI arguments
if using HTTPS. Then process/2 extracted those arguments and passed them
as autologin options to Converse.

From now, mod_conversejs automatically adds a request_handler nested in
webadmin subpath. The webadmin menu links to that converse URI; this allows
to access the HTTP auth credentials, no need to explicitly pass them.
process/2 extracts this HTTP auth and passes autologin options to Converse.
Now scram password storage is supported too.

This minimum configuration allows WebAdmin to access Converse:

listen:
  -
    port: 5443
    module: ejabberd_http
    tls: true
    request_handlers:
      /admin: ejabberd_web_admin
      /ws: ejabberd_http_ws
modules:
  mod_conversejs:
    conversejs_resources: "/home/conversejs/12.0.0/dist"

0 of 12 new or added lines in 1 file covered. (0.0%)

11290 existing lines in 174 files now uncovered.

15515 of 45924 relevant lines covered (33.78%)

1277.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.53
/src/node_pep.erl
1
%%%----------------------------------------------------------------------
2
%%% File    : node_pep.erl
3
%%% Author  : Christophe Romain <christophe.romain@process-one.net>
4
%%% Purpose : Standard PubSub PEP plugin
5
%%% Created :  1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
6
%%%
7
%%%
8
%%% ejabberd, Copyright (C) 2002-2025   ProcessOne
9
%%%
10
%%% This program is free software; you can redistribute it and/or
11
%%% modify it under the terms of the GNU General Public License as
12
%%% published by the Free Software Foundation; either version 2 of the
13
%%% License, or (at your option) any later version.
14
%%%
15
%%% This program is distributed in the hope that it will be useful,
16
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
17
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
%%% General Public License for more details.
19
%%%
20
%%% You should have received a copy of the GNU General Public License along
21
%%% with this program; if not, write to the Free Software Foundation, Inc.,
22
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
%%%
24
%%%----------------------------------------------------------------------
25

26
%%% @doc The module <strong>{@module}</strong> is the pep PubSub plugin.
27
%%% <p>PubSub plugin nodes are using the {@link gen_pubsub_node} behaviour.</p>
28

29
-module(node_pep).
30
-behaviour(gen_pubsub_node).
31
-author('christophe.romain@process-one.net').
32

33
-protocol({xep, 384, '0.8.3', '21.12', "complete", ""}).
34

35
-include("pubsub.hrl").
36

37
-export([init/3, terminate/2, options/0, features/0,
38
    create_node_permission/6, create_node/2, delete_node/1,
39
    purge_node/2, subscribe_node/8, unsubscribe_node/4,
40
    publish_item/7, delete_item/4,
41
    remove_extra_items/2, remove_extra_items/3, remove_expired_items/2,
42
    get_entity_affiliations/2, get_node_affiliations/1,
43
    get_affiliation/2, set_affiliation/3,
44
    get_entity_subscriptions/2, get_node_subscriptions/1,
45
    get_subscriptions/2, set_subscriptions/4,
46
    get_pending_nodes/2, get_states/1, get_state/2,
47
    set_state/1, get_items/7, get_items/3, get_item/7,
48
    get_last_items/3, get_only_item/2,
49
    get_item/2, set_item/1, get_item_name/3, node_to_path/1,
50
    path_to_node/1, depends/3]).
51

52
depends(_Host, _ServerHost, _Opts) ->
UNCOV
53
    [{mod_caps, hard}].
2✔
54

55
init(Host, ServerHost, Opts) ->
UNCOV
56
    node_flat:init(Host, ServerHost, Opts),
2✔
UNCOV
57
    ok.
2✔
58

59
terminate(Host, ServerHost) ->
UNCOV
60
    node_flat:terminate(Host, ServerHost),
2✔
UNCOV
61
    ok.
2✔
62

63
options() ->
UNCOV
64
    [{deliver_payloads, true},
172✔
65
        {notify_config, false},
66
        {notify_delete, false},
67
        {notify_retract, false},
68
        {purge_offline, false},
69
        {persist_items, true},
70
        {max_items, 1},
71
        {subscribe, true},
72
        {access_model, presence},
73
        {roster_groups_allowed, []},
74
        {publish_model, publishers},
75
        {notification_type, headline},
76
        {max_payload_size, ?MAX_PAYLOAD_SIZE},
77
        {send_last_published_item, on_sub_and_presence},
78
        {deliver_notifications, true},
79
        {presence_based_delivery, true},
80
        {itemreply, none}].
81

82
features() ->
UNCOV
83
    [<<"create-nodes">>,
6,411✔
84
        <<"auto-create">>,
85
        <<"auto-subscribe">>,
86
        <<"config-node">>,
87
        <<"config-node-max">>,
88
        <<"delete-nodes">>,
89
        <<"delete-items">>,
90
        <<"filtered-notifications">>,
91
        <<"item-ids">>,
92
        <<"modify-affiliations">>,
93
        <<"multi-items">>,
94
        <<"outcast-affiliation">>,
95
        <<"persistent-items">>,
96
        <<"publish">>,
97
        <<"publish-options">>,
98
        <<"purge-nodes">>,
99
        <<"retract-items">>,
100
        <<"retrieve-affiliations">>,
101
        <<"retrieve-items">>,
102
        <<"retrieve-subscriptions">>,
103
        <<"subscribe">>].
104

105
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
UNCOV
106
    LOwner = jid:tolower(Owner),
18✔
UNCOV
107
    {User, Server, _Resource} = LOwner,
18✔
UNCOV
108
    Allowed = case LOwner of
18✔
109
        {<<"">>, Host, <<"">>} ->
110
            true; % pubsub service always allowed
×
111
        _ ->
UNCOV
112
            case acl:match_rule(ServerHost, Access, LOwner) of
18✔
113
                allow ->
UNCOV
114
                    case Host of
18✔
UNCOV
115
                        {User, Server, _} -> true;
18✔
116
                        _ -> false
×
117
                    end;
118
                _ ->
119
                    false
×
120
            end
121
    end,
UNCOV
122
    {result, Allowed}.
18✔
123

124
create_node(Nidx, Owner) ->
UNCOV
125
    node_flat:create_node(Nidx, Owner).
4✔
126

127
delete_node(Nodes) ->
UNCOV
128
    node_flat:delete_node(Nodes).
4✔
129

130
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
131
            SendLast, PresenceSubscription, RosterGroup, Options) ->
132
    node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast,
×
133
        PresenceSubscription, RosterGroup, Options).
134

135
unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
136
    case node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId) of
×
137
        {error, Error} -> {error, Error};
×
138
        {result, _} -> {result, default}
×
139
    end.
140

141
publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) ->
UNCOV
142
    node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId,
6✔
143
        Payload, PubOpts).
144

145
remove_extra_items(Nidx, MaxItems) ->
146
    node_flat:remove_extra_items(Nidx, MaxItems).
×
147

148
remove_extra_items(Nidx, MaxItems, ItemIds) ->
149
    node_flat:remove_extra_items(Nidx, MaxItems, ItemIds).
×
150

151
remove_expired_items(Nidx, Seconds) ->
152
    node_flat:remove_expired_items(Nidx, Seconds).
×
153

154
delete_item(Nidx, Publisher, PublishModel, ItemId) ->
155
    node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId).
×
156

157
purge_node(Nidx, Owner) ->
158
    node_flat:purge_node(Nidx, Owner).
×
159

160
get_entity_affiliations(Host, Owner) ->
UNCOV
161
    {_, D, _} = SubKey = jid:tolower(Owner),
492✔
UNCOV
162
    SubKey = jid:tolower(Owner),
492✔
UNCOV
163
    GenKey = jid:remove_resource(SubKey),
492✔
UNCOV
164
    States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
492✔
UNCOV
165
    NodeTree = mod_pubsub:tree(Host),
492✔
UNCOV
166
    Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) ->
492✔
UNCOV
167
                    case NodeTree:get_node(N) of
18✔
UNCOV
168
                        #pubsub_node{nodeid = {{_, D, _}, _}} = Node -> [{Node, A} | Acc];
4✔
UNCOV
169
                        _ -> Acc
14✔
170
                    end
171
            end,
172
            [], States),
UNCOV
173
    {result, Reply}.
492✔
174

175

176
get_node_affiliations(Nidx) ->
177
    node_flat:get_node_affiliations(Nidx).
×
178

179
get_affiliation(Nidx, Owner) ->
UNCOV
180
    node_flat:get_affiliation(Nidx, Owner).
4✔
181

182
set_affiliation(Nidx, Owner, Affiliation) ->
183
    node_flat:set_affiliation(Nidx, Owner, Affiliation).
×
184

185
get_entity_subscriptions(Host, Owner) ->
UNCOV
186
    {U, D, _} = SubKey = jid:tolower(Owner),
194✔
UNCOV
187
    GenKey = jid:remove_resource(SubKey),
194✔
UNCOV
188
    States = case SubKey of
194✔
189
        GenKey ->
UNCOV
190
            mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});
136✔
191
        _ ->
192
            mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'})
UNCOV
193
            ++
58✔
194
            mnesia:match_object(#pubsub_state{stateid = {SubKey, '_'}, _ = '_'})
195
    end,
UNCOV
196
    NodeTree = mod_pubsub:tree(Host),
194✔
UNCOV
197
    Reply = lists:foldl(fun (#pubsub_state{stateid = {J, N}, subscriptions = Ss}, Acc) ->
194✔
UNCOV
198
                    case NodeTree:get_node(N) of
34✔
199
                        #pubsub_node{nodeid = {{_, D, _}, _}} = Node ->
200
                            lists:foldl(fun
×
201
                                    ({subscribed, SubId}, Acc2) ->
202
                                        [{Node, subscribed, SubId, J} | Acc2];
×
203
                                    ({pending, _SubId}, Acc2) ->
204
                                        [{Node, pending, J} | Acc2];
×
205
                                    (S, Acc2) ->
206
                                        [{Node, S, J} | Acc2]
×
207
                                end,
208
                                Acc, Ss);
209
                        _ ->
UNCOV
210
                            Acc
34✔
211
                    end
212
            end,
213
            [], States),
UNCOV
214
    {result, Reply}.
194✔
215

216
get_node_subscriptions(Nidx) ->
UNCOV
217
    node_flat:get_node_subscriptions(Nidx).
14✔
218

219
get_subscriptions(Nidx, Owner) ->
220
    node_flat:get_subscriptions(Nidx, Owner).
×
221

222
set_subscriptions(Nidx, Owner, Subscription, SubId) ->
223
    node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId).
×
224

225
get_pending_nodes(Host, Owner) ->
226
    node_flat:get_pending_nodes(Host, Owner).
×
227

228
get_states(Nidx) ->
229
    node_flat:get_states(Nidx).
×
230

231
get_state(Nidx, JID) ->
232
    node_flat:get_state(Nidx, JID).
×
233

234
set_state(State) ->
235
    node_flat:set_state(State).
×
236

237
get_items(Nidx, From, RSM) ->
UNCOV
238
    node_flat:get_items(Nidx, From, RSM).
10✔
239

240
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) ->
UNCOV
241
    node_flat:get_items(Nidx, JID, AccessModel,
2✔
242
        PresenceSubscription, RosterGroup, SubId, RSM).
243

244
get_last_items(Nidx, From, Count) ->
245
    node_flat:get_last_items(Nidx, From, Count).
×
246

247
get_only_item(Nidx, From) ->
248
    node_flat:get_only_item(Nidx, From).
×
249

250
get_item(Nidx, ItemId) ->
251
    node_flat:get_item(Nidx, ItemId).
×
252

253
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
254
    node_flat:get_item(Nidx, ItemId, JID, AccessModel,
×
255
        PresenceSubscription, RosterGroup, SubId).
256

257
set_item(Item) ->
258
    node_flat:set_item(Item).
×
259

260
get_item_name(Host, Node, Id) ->
261
    node_flat:get_item_name(Host, Node, Id).
×
262

263
node_to_path(Node) ->
UNCOV
264
    node_flat:node_to_path(Node).
14✔
265

266
path_to_node(Path) ->
267
    node_flat:path_to_node(Path).
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc