@@ -291,7 +291,8 @@ mod_opt_type(access_create_account) ->
291291mod_opt_type (db_type ) ->
292292 econf :db_type (? MODULE );
293293mod_opt_type (landing_page ) ->
294- econf :either (econf :enum ([none , auto ]), econf :binary ());
294+ econf :either (
295+ econf :enum ([none , auto ]), econf :binary ());
295296mod_opt_type (max_invites ) ->
296297 econf :pos_int (infinity );
297298mod_opt_type (site_name ) ->
@@ -398,8 +399,7 @@ cleanup_expired() ->
398399expire_tokens (User0 , Server0 ) ->
399400 User = jid :nodeprep (User0 ),
400401 Server = jid :nameprep (Server0 ),
401- pretty_format_command_result (
402- try_db_call (Server , expire_tokens , [User , Server ])).
402+ pretty_format_command_result (try_db_call (Server , expire_tokens , [User , Server ])).
403403
404404-spec generate_invite (binary ()) -> binary () | {error , any ()}.
405405generate_invite (Host ) ->
@@ -410,9 +410,11 @@ generate_invite(AccountName, Host) ->
410410 pretty_format_command_result (gen_invite (AccountName , Host )).
411411
412412-ifdef (TEST ).
413+
413414-spec gen_invite (binary ()) -> binary () | {error , any ()}.
414415gen_invite (Host ) ->
415416 gen_invite (<<>>, Host ).
417+
416418-endif .
417419
418420-spec gen_invite (binary (), binary ()) -> binary () | {error , any ()}.
@@ -428,27 +430,28 @@ gen_invite(AccountName, Host0) ->
428430 end .
429431
430432list_invites (Host ) ->
431- Res =
432- maybe
433- {ok , Invites } ?= try_db_call (Host , list_invites , [Host ]),
434- [format_invite (Host , Invite ) || Invite <- Invites ]
435- end ,
433+ Res = maybe
434+ {ok , Invites } ?= try_db_call (Host , list_invites , [Host ]),
435+ [format_invite (Host , Invite ) || Invite <- Invites ]
436+ end ,
436437 pretty_format_command_result (Res ).
437438
438- format_invite (Host , # invite_token {token = TO ,
439+ format_invite (Host ,
440+ # invite_token {token = TO ,
439441 inviter = {IU , IS },
440442 invitee = IE ,
441443 created_at = CA ,
442444 expires = Exp ,
443445 type = TY ,
444- account_name = AN } = Invite ) ->
446+ account_name = AN } =
447+ Invite ) ->
445448 {TO ,
446449 is_token_valid (Host , TO ),
447450 encode_datetime (CA ),
448451 encode_datetime (Exp ),
449452 TY ,
450453 jid :encode (
451- jid :make (IU , IS )),
454+ jid :make (IU , IS )),
452455 IE ,
453456 AN ,
454457 token_uri (Invite ),
@@ -916,21 +919,26 @@ maybe_add_ibr_allowed(User, Host) ->
916919landing_page (Host , Invite ) ->
917920 mod_invites_http :landing_page (Host , Invite ).
918921
919- -spec db_call (binary (), atom (), list ( any ()) ) -> any ().
922+ -spec db_call (binary (), atom (), [ any ()] ) -> any ().
920923db_call (Host , Fun , Args ) ->
921924 Mod = gen_mod :db_mod (Host , ? MODULE ),
922925 apply (Mod , Fun , Args ).
923926
924927% % father forgive me
925- lift ({error , _R } = E ) -> E ;
926- lift ({ok , _V } = R ) -> R ;
927- lift (Res ) -> {ok , Res }.
928-
929- -spec try_db_call (Host :: binary (), Fun :: atom (), Args :: list (any ())) -> {ok , any ()} | {error , any ()}.
928+ lift ({error , _R } = E ) ->
929+ E ;
930+ lift ({ok , _V } = R ) ->
931+ R ;
932+ lift (Res ) ->
933+ {ok , Res }.
934+
935+ -spec try_db_call (Host :: binary (), Fun :: atom (), Args :: [any ()]) ->
936+ {ok , any ()} | {error , any ()}.
930937try_db_call (Host , Fun , Args ) ->
931- try lift (db_call (Host , Fun , Args ))
938+ try
939+ lift (db_call (Host , Fun , Args ))
932940 catch
933- error :{error , _Reason } = Error ->
941+ error :( {error , _Reason } = Error ) ->
934942 Error ;
935943 error :Error ->
936944 {error , Error }
@@ -1039,7 +1047,9 @@ send_presence(From, To, Type) ->
10391047 ejabberd_router :route (Presence ).
10401048
10411049pretty_format_command_result ({error , {module_not_loaded , ? MODULE , Host }}) ->
1042- {error , lists :flatten (io_lib :format (" Virtual host not known: ~s " , [binary_to_list (Host )]))};
1050+ {error ,
1051+ lists :flatten (
1052+ io_lib :format (" Virtual host not known: ~s " , [binary_to_list (Host )]))};
10431053pretty_format_command_result ({error , host_unknown }) ->
10441054 {error , " Virtual host not known" };
10451055pretty_format_command_result ({error , user_exists }) ->
0 commit comments