• 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

40.0
/src/mod_last_sql.erl
1
%%%-------------------------------------------------------------------
2
%%% File    : mod_last_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_last_sql).
26

27
-behaviour(mod_last).
28

29

30
%% API
31
-export([init/2, get_last/2, store_last_info/4, remove_user/2,
32
         import/2, export/1]).
33
-export([sql_schemas/0]).
34

35
-include("mod_last.hrl").
36
-include("logger.hrl").
37
-include("ejabberd_sql_pt.hrl").
38

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

46
sql_schemas() ->
UNCOV
47
    [#sql_schema{
7✔
48
        version = 1,
49
        tables =
50
            [#sql_table{
51
                name = <<"last">>,
52
                columns =
53
                    [#sql_column{name = <<"username">>, type = text},
54
                     #sql_column{name = <<"server_host">>, type = text},
55
                     #sql_column{name = <<"seconds">>, type = text},
56
                     #sql_column{name = <<"state">>, type = text}],
57
                indices = [#sql_index{
58
                              columns = [<<"server_host">>, <<"username">>],
59
                              unique = true}]}]}].
60

61
get_last(LUser, LServer) ->
62
    case ejabberd_sql:sql_query(
×
63
           LServer,
64
           ?SQL("select @(seconds)d, @(state)s from last"
×
65
                " where username=%(LUser)s and %(LServer)H")) of
66
        {selected, []} ->
67
            error;
×
68
        {selected, [{TimeStamp, Status}]} ->
69
            {ok, {TimeStamp, Status}};
×
70
        _Reason ->
71
            {error, db_failure}
×
72
    end.
73

74
store_last_info(LUser, LServer, TimeStamp, Status) ->
UNCOV
75
    TS = integer_to_binary(TimeStamp),
182✔
UNCOV
76
    case ?SQL_UPSERT(LServer, "last",
182✔
77
                     ["!username=%(LUser)s",
78
                      "!server_host=%(LServer)s",
79
                      "seconds=%(TS)s",
80
                      "state=%(Status)s"]) of
81
        ok ->
UNCOV
82
            ok;
182✔
83
        _Err ->
84
            {error, db_failure}
×
85
    end.
86

87
remove_user(LUser, LServer) ->
UNCOV
88
    ejabberd_sql:sql_query(
14✔
89
      LServer,
UNCOV
90
      ?SQL("delete from last where username=%(LUser)s and %(LServer)H")).
14✔
91

92
export(_Server) ->
93
    [{last_activity,
×
94
      fun(Host, #last_activity{us = {LUser, LServer},
95
                               timestamp = TimeStamp, status = Status})
96
            when LServer == Host ->
97
              TS = integer_to_binary(TimeStamp),
×
98
              [?SQL("delete from last where username=%(LUser)s and %(LServer)H;"),
×
99
               ?SQL_INSERT("last",
×
100
                           ["username=%(LUser)s",
101
                            "server_host=%(LServer)s",
102
                            "seconds=%(TS)s",
103
                            "state=%(Status)s"])];
104
         (_Host, _R) ->
105
              []
×
106
      end}].
107

108
import(_LServer, _LA) ->
109
    pass.
×
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