X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_protocole.erl;h=c2cb9846b537865c4faec2cd79644060b46a5af4;hp=548f4af205492e44e2b79e5af5d7321ae0cb8099;hb=2faefc542de20cfcc0220b5c7fd7982dd0fbbfd4;hpb=46b6cab14594802cdb4db9e3d77082815182073b diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 548f4af..c2cb984 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -45,7 +45,10 @@ loginUser({ok, User}) -> 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. % Renvoie un string() représentant un cookie en base 36. Il y a 10^32 possibillités. @@ -69,13 +72,14 @@ profile( {nick, Pseudo}, {email, Email}, {css, Css}, + {nick_format, Nick_format_str}, {main_page, Main_page}, - {conversations, Conversations_json} + {conversations, {array, Conversations_json}} ] ) -> % est-ce que les messages auquel on répond existent ? Conversations = lists:foldr( - fun([struct, {root, Root}, {page, Page}], Acc) -> + fun({struct, [{root, Root}, {page, Page}]}, Acc) -> Message_existe = euphorik_minichat:message_existe(Root), if Message_existe -> [{Root, Page} | Acc]; @@ -86,7 +90,7 @@ profile( [], 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 -> @@ -105,7 +109,7 @@ wait_event(Data) -> {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, [{racine, Racine}, {page, Page}]}) -> {Racine, Page} end, Conversations_json), + Conversations = lists:map(fun({struct, [{root, Racine}, {page, Page}]}) -> {Racine, Page} end, Conversations_json), User = case euphorik_minichat:user_by_cookie(Cookie) of {ok, U} -> U; _ -> inconnu @@ -245,14 +249,17 @@ json_reponse_login_ok(User) -> {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, lists:map( fun(C) -> {struct, - {root, element(1, C)}, - {page, element(2, C)} + [ + {root, element(1, C)}, + {page, element(2, C)} + ] } end, User#user.conversations