From 7ee018ad23bcc477fd68ce34c6bd1e6aeb8c33a2 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 8 Mar 2021 15:56:42 +0100 Subject: [PATCH] Obtain and provide photo type in vCard LDAP (#3541) --- src/mod_vcard_ldap.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 9f17f3115..c81c058f5 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -268,7 +268,8 @@ ldap_attribute_to_vcard({Attr, Value}, V) -> <<"role">> -> V#vcard_temp{role = Value}; <<"tel">> -> V#vcard_temp{tel = [#vcard_tel{number = Value}|Ts]}; <<"email">> -> V#vcard_temp{email = [#vcard_email{userid = Value}|Es]}; - <<"photo">> -> V#vcard_temp{photo = #vcard_photo{binval = Value}}; + <<"photo">> -> V#vcard_temp{photo = #vcard_photo{binval = Value, + type = photo_type(Value)}}; <<"family">> -> V#vcard_temp{n = N#vcard_name{family = Value}}; <<"given">> -> V#vcard_temp{n = N#vcard_name{given = Value}}; <<"middle">> -> V#vcard_temp{n = N#vcard_name{middle = Value}}; @@ -282,6 +283,11 @@ ldap_attribute_to_vcard({Attr, Value}, V) -> _ -> V end. +-spec photo_type(binary()) -> binary(). +photo_type(Value) -> + Type = eimp:get_type(Value), + <<"image/", (atom_to_binary(Type, latin1))/binary>>. + map_vcard_attr(VCardName, Attributes, Pattern, UD) -> Res = lists:filter( fun({Name, _}) ->