• 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

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

25
-module(mod_caps_sql).
26

27
-behaviour(mod_caps).
28

29

30
%% API
31
-export([init/2, caps_read/2, caps_write/3, export/1, import/3]).
32
-export([sql_schemas/0]).
33

34
-include("mod_caps.hrl").
35
-include("ejabberd_sql_pt.hrl").
36
-include("logger.hrl").
37

38
%%%===================================================================
39
%%% API
40
%%%===================================================================
41
init(Host, _Opts) ->
UNCOV
42
    ejabberd_sql_schema:update_schema(Host, ?MODULE, sql_schemas()),
7✔
UNCOV
43
    ok.
7✔
44

45
sql_schemas() ->
UNCOV
46
    [#sql_schema{
7✔
47
        version = 1,
48
        tables =
49
            [#sql_table{
50
                name = <<"caps_features">>,
51
                columns =
52
                    [#sql_column{name = <<"node">>, type = text},
53
                     #sql_column{name = <<"subnode">>, type = text},
54
                     #sql_column{name = <<"feature">>, type = text},
55
                     #sql_column{name = <<"created_at">>, type = timestamp,
56
                                 default = true}],
57
                indices = [#sql_index{
58
                              columns = [<<"node">>, <<"subnode">>]}]}]}].
59

60
caps_read(LServer, {Node, SubNode}) ->
UNCOV
61
    case ejabberd_sql:sql_query(
14✔
62
           LServer,
UNCOV
63
           ?SQL("select @(feature)s from caps_features where"
22✔
64
                " node=%(Node)s and subnode=%(SubNode)s")) of
65
        {selected, [{H}|_] = Fs} ->
UNCOV
66
            case catch binary_to_integer(H) of
7✔
67
                Int when is_integer(Int), Int>=0 ->
68
                    {ok, Int};
×
69
                _ ->
UNCOV
70
                    {ok, [F || {F} <- Fs]}
7✔
71
            end;
72
        _ ->
UNCOV
73
            error
7✔
74
    end.
75

76
caps_write(LServer, NodePair, Features) ->
UNCOV
77
    case ejabberd_sql:sql_transaction(
7✔
78
           LServer,
79
           sql_write_features_t(NodePair, Features)) of
80
        {atomic, _} ->
UNCOV
81
            ok;
7✔
82
        {aborted, _Reason} ->
83
            {error, db_failure}
×
84
    end.
85

86
export(_Server) ->
87
    [{caps_features,
×
88
      fun(_Host, #caps_features{node_pair = NodePair,
89
                                features = Features}) ->
90
              sql_write_features_t(NodePair, Features);
×
91
         (_Host, _R) ->
92
              []
×
93
      end}].
94

95
import(_, _, _) ->
96
    ok.
×
97

98
%%%===================================================================
99
%%% Internal functions
100
%%%===================================================================
101
sql_write_features_t({Node, SubNode}, Features) ->
UNCOV
102
    NewFeatures = if is_integer(Features) ->
7✔
103
                          [integer_to_binary(Features)];
×
104
                     true ->
UNCOV
105
                          Features
7✔
106
                  end,
UNCOV
107
    [?SQL("delete from caps_features where node=%(Node)s"
7✔
108
          " and subnode=%(SubNode)s;") |
UNCOV
109
     [?SQL("insert into caps_features(node, subnode, feature)"
7✔
UNCOV
110
           " values (%(Node)s, %(SubNode)s, %(F)s);") || F <- NewFeatures]].
7✔
111

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

© 2025 Coveralls, Inc