Email = case xmerl_xpath:string("email", Action) of [#xmlElement{content = [#xmlText{value = E}]}] -> E; _ -> undefined end,
Css = case xmerl_xpath:string("css", Action) of [#xmlElement{content = [#xmlText{value = C}]}] -> C; _ -> undefined end,
Page_principale = case xmerl_xpath:string("pagePrincipale", Action) of [#xmlElement{content = [#xmlText{value = P3}]}] -> list_to_integer(P3); _ -> undefined end,
- Conversations = lists:map(
- fun(Conv) ->
+ Conversations = lists:foldl(
+ fun(Conv, Acc) ->
[#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv),
[#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv),
- {erlang:list_to_integer(Id_racine_str, 36), list_to_integer(Page_conv_str)}
+ Message_id = erlang:list_to_integer(Id_racine_str, 36),
+ % vérification de la validité de l'id
+ Message_existe = euphorik_minichat:message_existe(Message_id),
+ if Message_existe ->
+ [{Message_id, list_to_integer(Page_conv_str)} | Acc];
+ true ->
+ Acc
+ end
end,
+ [],
xmerl_xpath:string("conversation", Action)
),
case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, Page_principale, Conversations) of