euphorik_minichat:update_date_derniere_connexion(User#user.id),
json_reponse_login_ok(User);
loginUser(_) ->
- erreur("Erreur login").
+ % ajoute un délais d'attente (TODO : un autre moyen plus élégant ?)
+ receive after 1000 ->
+ erreur("Erreur login")
+ end.
\r
% Renvoie un string() représentant un cookie en base 36. Il y a 10^32 possibillités.\r
{nick, Pseudo},
{email, Email},
{css, Css},
+ {nick_format, Nick_format_str},
{main_page, Main_page},
{conversations, {array, Conversations_json}}
]
[],
Conversations_json
),
- case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, Main_page, Conversations) of
+ case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, list_to_atom(Nick_format_str), Main_page, Conversations) of
ok ->
json_reponse_ok();
login_deja_pris ->
{value, {_, Message_count}} = lists:keysearch(message_count, 1, Data),
Main_page = case lists:keysearch(main_page, 1, Data) of {value, {_, P}} -> P; _ -> 1 end,
{value, {_, {array, Conversations_json}}} = lists:keysearch(conversations, 1, Data),
- Conversations = lists:map(fun({struct, [{root, Racine}, {page, Page}]}) -> {Racine, Page} end, Conversations_json),
+ Conversations = lists:map(
+ fun({struct, [{root, Racine}, {page, Page} | Reste]}) ->
+ Last_mess_conv = case Reste of [{last_message_id, L}] -> L; _ -> 0 end,
+ {Racine, Page, Last_mess_conv}
+ end,
+ Conversations_json
+ ),
User = case euphorik_minichat:user_by_cookie(Cookie) of\r
{ok, U} -> U;\r
_ -> inconnu\r
{login, User#user.login},
{email, User#user.email},
{css, User#user.css},
+ {nick_format, atom_to_list(User#user.nick_format)},
{main_page, User#user.page_principale},
{conversations,
{array,