summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-01-23 19:12:52 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-01-23 19:12:52 +0100 |
commit | 41f0db023cb6c1a609762b9679b3677143b3840f (patch) | |
tree | ae2297181648ab838e7abded8530a7ff17a49af3 | |
parent | 14e79da8b8d45ef242aee34cf4376d220846f690 (diff) |
Isolates Yaws from the code base.
-rw-r--r-- | src/battle/mechanic/btl_turn_actions.erl | 2 | ||||
-rw-r--r-- | src/battle/query/btl_character_turn.erl | 16 | ||||
-rw-r--r-- | src/battle/query/btl_join.erl | 16 | ||||
-rw-r--r-- | src/battle/query/btl_load.erl | 16 | ||||
-rw-r--r-- | src/login/query/lgn_sign_in.erl | 16 | ||||
-rw-r--r-- | src/login/query/lgn_sign_up.erl | 16 | ||||
-rw-r--r-- | src/map/query/map_load.erl | 16 | ||||
-rw-r--r-- | src/map/query/map_update.erl | 16 | ||||
-rw-r--r-- | src/player/query/plr_load.erl | 16 | ||||
-rw-r--r-- | src/roster/query/rst_load.erl | 16 | ||||
-rw-r--r-- | src/roster/query/rst_update.erl | 16 |
11 files changed, 70 insertions, 92 deletions
diff --git a/src/battle/mechanic/btl_turn_actions.erl b/src/battle/mechanic/btl_turn_actions.erl index d4a81fc..489d9ac 100644 --- a/src/battle/mechanic/btl_turn_actions.erl +++ b/src/battle/mechanic/btl_turn_actions.erl @@ -16,8 +16,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Move elsewhere - %%%% TODO: move this elsewhere -spec finalize_character ( diff --git a/src/battle/query/btl_character_turn.erl b/src/battle/query/btl_character_turn.erl index 90afba8..b30f02f 100644 --- a/src/battle/query/btl_character_turn.erl +++ b/src/battle/query/btl_character_turn.erl @@ -18,11 +18,9 @@ %%%% REQUEST DECODING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec decode_request (binary()) -> btl_character_turn_request:type(). -decode_request (BinaryRequest) -> - JSONMap = jiffy:decode(BinaryRequest, [return_maps]), - - btl_character_turn_request:decode(JSONMap). +-spec decode_request (shr_query:type()) -> btl_character_turn_request:type(). +decode_request (Query) -> + btl_character_turn_request:decode(shr_query:get_params(Query)). %%%% USER AUTHENTICATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -spec authenticate_user (btl_character_turn_request:type()) -> ('ok' | 'error'). @@ -240,9 +238,9 @@ generate_reply (Update) -> jiffy:encode([TurnResultReply]). %%%% MAIN LOGIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec handle (binary()) -> binary(). -handle (EncodedRequest) -> - Request = decode_request(EncodedRequest), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Request = decode_request(Query), case authenticate_user(Request) of ok -> PlayerID = btl_character_turn_request:get_player_id(Request), @@ -268,5 +266,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/battle/query/btl_join.erl b/src/battle/query/btl_join.erl index 29d273f..aabea27 100644 --- a/src/battle/query/btl_join.erl +++ b/src/battle/query/btl_join.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -33,9 +31,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), SummaryIX = maps:get(<<"six">>, JSONReqMap), @@ -205,9 +203,9 @@ authorize_attack (_QueryState, _Input) -> ok. % TODO -spec authorize_defend (defend_query_state(), input()) -> 'ok'. authorize_defend (_QueryState, _Input) -> ok. % TODO --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of ok -> case Input#input.mode of @@ -233,5 +231,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/battle/query/btl_load.erl b/src/battle/query/btl_load.erl index 7c7d4ab..e2d1fe4 100644 --- a/src/battle/query/btl_load.erl +++ b/src/battle/query/btl_load.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -34,9 +32,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), BattleID = maps:get(<<"bid">>, JSONReqMap), @@ -162,9 +160,9 @@ generate_reply (QueryState, Input) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of ok -> shr_security:lock_queries(Input#input.player_id), @@ -182,5 +180,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/login/query/lgn_sign_in.erl b/src/login/query/lgn_sign_in.erl index c1db8f6..83d2e5f 100644 --- a/src/login/query/lgn_sign_in.erl +++ b/src/login/query/lgn_sign_in.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -34,9 +32,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), Username = maps:get(<<"usr">>, JSONReqMap), Password = maps:get(<<"pwd">>, JSONReqMap), @@ -129,9 +127,9 @@ generate_reply (QueryState) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), QueryState = fetch_data(Input), Update = update_data(QueryState, Input), commit_update(Update), @@ -144,5 +142,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/login/query/lgn_sign_up.erl b/src/login/query/lgn_sign_up.erl index 2ab8ef3..5fdb27f 100644 --- a/src/login/query/lgn_sign_up.erl +++ b/src/login/query/lgn_sign_up.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -35,9 +33,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), Username = maps:get(<<"usr">>, JSONReqMap), Password = maps:get(<<"pwd">>, JSONReqMap), Email = maps:get(<<"eml">>, JSONReqMap), @@ -74,9 +72,9 @@ generate_reply (QueryState) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), %% TODO [SECURITY][LOW]: validate input size. QueryState = register_user(Input), generate_reply(QueryState). @@ -88,5 +86,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/map/query/map_load.erl b/src/map/query/map_load.erl index 2df9ca1..dde2fab 100644 --- a/src/map/query/map_load.erl +++ b/src/map/query/map_load.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -34,9 +32,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), MapID = maps:get(<<"mid">>, JSONReqMap), @@ -87,9 +85,9 @@ generate_reply (QueryState) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of ok -> shr_security:lock_queries(Input#input.player_id), @@ -107,5 +105,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/map/query/map_update.erl b/src/map/query/map_update.erl index 0989933..b6e36c2 100644 --- a/src/map/query/map_update.erl +++ b/src/map/query/map_update.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -37,9 +35,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), MapID = maps:get(<<"mid">>, JSONReqMap), @@ -166,9 +164,9 @@ commit_update (QueryState, Input) -> generate_reply () -> jiffy:encode([shr_okay:generate()]). --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of ok -> shr_security:lock_queries(Input#input.player_id), @@ -188,5 +186,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/player/query/plr_load.erl b/src/player/query/plr_load.erl index 278f568..993ba6b 100644 --- a/src/player/query/plr_load.erl +++ b/src/player/query/plr_load.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -34,9 +32,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), TargetID = maps:get(<<"id">>, JSONReqMap), @@ -81,9 +79,9 @@ generate_reply (QueryState, Input) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of ok -> shr_security:lock_queries(Input#input.player_id), @@ -101,5 +99,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/roster/query/rst_load.erl b/src/roster/query/rst_load.erl index 077f193..4f7cf64 100644 --- a/src/roster/query/rst_load.erl +++ b/src/roster/query/rst_load.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -record ( input, @@ -35,9 +33,9 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), @@ -106,9 +104,9 @@ generate_reply (QueryState) -> Output. --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of {ok, Player} -> shr_security:lock_queries(Input#input.player_id), @@ -126,5 +124,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. diff --git a/src/roster/query/rst_update.erl b/src/roster/query/rst_update.erl index b1e0a7c..bbae76e 100644 --- a/src/roster/query/rst_update.erl +++ b/src/roster/query/rst_update.erl @@ -3,8 +3,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - -type decoded_character() :: {non_neg_integer(), rst_character:type()}. -record @@ -48,9 +46,9 @@ decode_character_list (EncodedCharactersList) -> EncodedCharactersList ). --spec parse_input (binary()) -> input(). -parse_input (Req) -> - JSONReqMap = jiffy:decode(Req, [return_maps]), +-spec parse_input (shr_query:type()) -> input(). +parse_input (Query) -> + JSONReqMap = shr_query:get_params(Query), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), EncodedCharacterList = maps:get(<<"rst">>, JSONReqMap), @@ -174,9 +172,9 @@ commit_update (QueryState, Input) -> generate_reply () -> jiffy:encode([shr_okay:generate()]). --spec handle (binary()) -> binary(). -handle (Req) -> - Input = parse_input(Req), +-spec handle (shr_query:type()) -> binary(). +handle (Query) -> + Input = parse_input(Query), case authenticate_user(Input) of {ok, Player} -> shr_security:lock_queries(Input#input.player_id), @@ -196,5 +194,5 @@ out(A) -> { content, "application/json; charset=UTF-8", - handle(A#arg.clidata) + handle(shr_query:new(A)) }. |