From 377748b688f2138106cb126ec3decfbb547caa7c Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Fri, 14 Jun 2019 16:42:22 +0300 Subject: [PATCH] Fix validator of mod_avatar --- src/mod_avatar.erl | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mod_avatar.erl b/src/mod_avatar.erl index 047b33e82..6d2c42c95 100644 --- a/src/mod_avatar.erl +++ b/src/mod_avatar.erl @@ -22,7 +22,7 @@ %%%------------------------------------------------------------------- -module(mod_avatar). -behaviour(gen_mod). - +-dialyzer({no_return, mod_opt_type/1}). -protocol({xep, 398, '0.2.0'}). %% gen_mod API @@ -435,17 +435,15 @@ encode_mime_type(Type) -> <<"image/", (atom_to_binary(Type, latin1))/binary>>. mod_opt_type(convert) -> - Formats = eimp:supported_formats(), - econf:and_then( - fun(_) when Formats == [] -> - econf:fail(eimp_error); - (V) -> - V - end, - econf:options( - maps:from_list( - [{Type, econf:enum(Formats)} - || Type <- [default|Formats]]))); + case eimp:supported_formats() of + [] -> + fun(_) -> econf:fail(eimp_error) end; + Formats -> + econf:options( + maps:from_list( + [{Type, econf:enum(Formats)} + || Type <- [default|Formats]])) + end; mod_opt_type(rate_limit) -> econf:pos_int().