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

processone / ejabberd / 1258

12 Dec 2025 03:57PM UTC coverage: 33.638% (-0.006%) from 33.644%
1258

push

github

badlop
Container: Apply commit a22c88a

ejabberdctl.template: Show meaningful error when ERL_DIST_PORT is in use

15554 of 46240 relevant lines covered (33.64%)

1078.28 hits per line

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

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

27
-behaviour(mod_last).
28

29
%% API
30
-export([init/2, import/2, get_last/2, store_last_info/4,
31
         remove_user/2, use_cache/1]).
32
-export([need_transform/1, transform/1]).
33

34
-include("mod_last.hrl").
35
-include("logger.hrl").
36

37
%%%===================================================================
38
%%% API
39
%%%===================================================================
40
init(_Host, _Opts) ->
41
    ejabberd_mnesia:create(?MODULE, last_activity,
92✔
42
                           [{disc_only_copies, [node()]},
43
                            {attributes, record_info(fields, last_activity)}]).
44

45
use_cache(Host) ->
46
    case mnesia:table_info(last_activity, storage_type) of
189✔
47
        disc_only_copies ->
48
            mod_last_opt:use_cache(Host);
189✔
49
        _ ->
50
            false
×
51
    end.
52

53
get_last(LUser, LServer) ->
54
    case mnesia:dirty_read(last_activity, {LUser, LServer}) of
×
55
        [] ->
56
            error;
×
57
        [#last_activity{timestamp = TimeStamp,
58
                        status = Status}] ->
59
            {ok, {TimeStamp, Status}}
×
60
    end.
61

62
store_last_info(LUser, LServer, TimeStamp, Status) ->
63
    mnesia:dirty_write(#last_activity{us = {LUser, LServer},
56✔
64
                                      timestamp = TimeStamp,
65
                                      status = Status}).
66

67
remove_user(LUser, LServer) ->
68
    US = {LUser, LServer},
5✔
69
    mnesia:dirty_delete({last_activity, US}).
5✔
70

71
import(_LServer, #last_activity{} = LA) ->
72
    mnesia:dirty_write(LA).
×
73

74
need_transform({last_activity, {U, S}, _, Status})
75
  when is_list(U) orelse is_list(S) orelse is_list(Status) ->
76
    ?INFO_MSG("Mnesia table 'last_activity' will be converted to binary", []),
×
77
    true;
×
78
need_transform(_) ->
79
    false.
×
80

81
transform(#last_activity{us = {U, S}, status = Status} = R) ->
82
    R#last_activity{us = {iolist_to_binary(U), iolist_to_binary(S)},
×
83
                    status = iolist_to_binary(Status)}.
84

85
%%%===================================================================
86
%%% Internal functions
87
%%%===================================================================
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