Skip to content

Commit

Permalink
Fixing issues in mod_inbox_backend.erl
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Jakubiec authored and Janusz Jakubiec committed Oct 22, 2021
1 parent ad71add commit 2d74e87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
43 changes: 21 additions & 22 deletions src/inbox/mod_inbox_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
get_inbox_unread/2,
get_entry_properties/2,
set_entry_properties/3,
reset_unread/3
]).
reset_unread/3]).

-define(MAIN_MODULE, mod_inbox).

-callback init(Host, Opts) -> ok when
Host :: mongooseim:host_type(),
-callback init(HostType, Opts) -> ok when
HostType :: mongooseim:host_type(),
Opts :: list().

-callback get_inbox(HostType, LUser, LServer, Params) -> mod_index:get_inbox_res() when
-callback get_inbox(HostType, LUser, LServer, Params) -> mod_inbox:get_inbox_res() when
HostType :: mongooseim:host_type(),
LUser :: jid:luser(),
LServer :: jid:lserver(),
Params :: mod_inbox:get_inbox_params().

-callback clear_inbox(HostType, LUser, LServer) -> mod_index:inbox_write_res() when
-callback clear_inbox(HostType, LUser, LServer) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
LUser :: jid:luser(),
LServer :: jid:lserver().
Expand All @@ -37,15 +36,15 @@
LServer :: jid:lserver().

-callback set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
mod_index:inbox_write_res() when
mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Content :: binary(),
Count :: integer(),
MsgId :: binary(),
Timestamp :: integer().

-callback remove_inbox_row(HostType, InboxEntryKey) -> mod_index:inbox_write_res() when
-callback remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key().

Expand All @@ -57,7 +56,7 @@
MsgId :: binary(),
Timestamp :: integer().

-callback reset_unread(HostType, InboxEntryKey, MsgId) -> mod_index:inbox_write_res() when
-callback reset_unread(HostType, InboxEntryKey, MsgId) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
MsgId :: binary().
Expand All @@ -69,23 +68,23 @@
-callback get_entry_properties(HostType, InboxEntryKey) -> Ret when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Ret :: mod_index:entry_properties().
Ret :: mod_inbox:entry_properties() | nil().

-callback set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Params :: mod_index:entry_properties(),
Ret :: mod_index:entry_properties() | {error, binary()}.
Params :: mod_inbox:entry_properties(),
Ret :: mod_inbox:entry_properties() | {error, binary()}.

-spec init(Host, Opts) -> ok when
Host :: mongooseim:host_type(),
-spec init(HostType, Opts) -> ok when
HostType :: mongooseim:host_type(),
Opts :: list().
init(HostType, Opts) ->
mongoose_backend:init_per_host_type(HostType, ?MAIN_MODULE, callback_funs(), Opts),
Args = [HostType, Opts],
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec get_inbox(HostType, LUser, LServer, Params) -> mod_index:get_inbox_res() when
-spec get_inbox(HostType, LUser, LServer, Params) -> mod_inbox:get_inbox_res() when
HostType :: mongooseim:host_type(),
LUser :: jid:luser(),
LServer :: jid:lserver(),
Expand All @@ -94,7 +93,7 @@ get_inbox(HostType, LUser, LServer, Params) ->
Args = [HostType, LUser, LServer, Params],
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec clear_inbox(HostType, LUser, LServer) -> mod_index:inbox_write_res() when
-spec clear_inbox(HostType, LUser, LServer) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
LUser :: jid:luser(),
LServer :: jid:lserver().
Expand All @@ -110,7 +109,7 @@ remove_domain(HostType, LServer) ->
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
mod_index:inbox_write_res() when
mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Content :: binary(),
Expand All @@ -121,7 +120,7 @@ set_inbox(HostType, InboxEntryKey, Content, Count, MsgId, Timestamp) ->
Args = [HostType, InboxEntryKey, Content, Count, MsgId, Timestamp],
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec remove_inbox_row(HostType, InboxEntryKey) -> mod_index:inbox_write_res() when
-spec remove_inbox_row(HostType, InboxEntryKey) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key().
remove_inbox_row(HostType, InboxEntryKey) ->
Expand All @@ -139,7 +138,7 @@ set_inbox_incr_unread(HostType, InboxEntryKey, Content, MsgId, Timestamp) ->
Args = [HostType, InboxEntryKey, Content, MsgId, Timestamp],
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec reset_unread(HostType, InboxEntryKey, MsgId) -> mod_index:inbox_write_res() when
-spec reset_unread(HostType, InboxEntryKey, MsgId) -> mod_inbox:inbox_write_res() when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
MsgId :: binary() | undefined.
Expand All @@ -157,16 +156,16 @@ get_inbox_unread(HostType, InboxEntryKey) ->
-spec get_entry_properties(HostType, InboxEntryKey) -> Ret when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Ret :: mod_index:entry_properties().
Ret :: mod_inbox:entry_properties() | nil().
get_entry_properties(HostType, InboxEntryKey) ->
Args = [HostType, InboxEntryKey],
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).

-spec set_entry_properties(HostType, InboxEntryKey, Params) -> Ret when
HostType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key(),
Params :: mod_index:entry_properties(),
Ret :: mod_index:entry_properties() | {error, binary()}.
Params :: mod_inbox:entry_properties(),
Ret :: mod_inbox:entry_properties() | {error, binary()}.
set_entry_properties(HostType, InboxEntryKey, Params) ->
Args = [HostType, InboxEntryKey, Params],
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args).
Expand Down
2 changes: 1 addition & 1 deletion src/inbox/mod_inbox_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ clear_inbox(HostType, LUser, LServer) ->

-spec get_entry_properties(HosType :: mongooseim:host_type(),
InboxEntryKey :: mod_inbox:entry_key()) ->
entry_properties().
entry_properties() | nil().
get_entry_properties(HostType, {LUser, LServer, RemBareJID}) ->
case execute_select_properties(HostType, LUser, LServer, RemBareJID) of
{selected, []} ->
Expand Down

0 comments on commit 2d74e87

Please sign in to comment.