Don't audit-log 'undefined' when no restrictions (#17)

This commit is contained in:
Andrew Mayorov 2021-02-04 15:47:19 +03:00 committed by GitHub
parent 85c7edeb6e
commit db9721bf71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,12 +214,11 @@ get_beat_metadata({judgement, Event}) ->
event => started event => started
}; };
{completed, {Resolution, Assertions}} -> {completed, {Resolution, Assertions}} ->
#{ encode_restrictions(Resolution, #{
event => completed, event => completed,
resolution => encode_resolution(Resolution), resolution => encode_resolution(Resolution),
assertions => lists:map(fun encode_assertion/1, Assertions), assertions => lists:map(fun encode_assertion/1, Assertions)
restrictions => encode_restrictions(Resolution) });
};
{failed, Error} -> {failed, Error} ->
#{ #{
event => failed, event => failed,
@ -234,10 +233,10 @@ encode_resolution({restricted, _Restrictions}) -> <<"restricted">>.
%% NOTE %% NOTE
%% I judged adding restrictions parsing to be not worth it for audit log %% I judged adding restrictions parsing to be not worth it for audit log
encode_restrictions({restricted, Restrictions}) -> encode_restrictions({restricted, Restrictions}, Acc) ->
Restrictions; Acc#{restrictions => Restrictions};
encode_restrictions(_) -> encode_restrictions(_, Acc) ->
undefined. Acc.
encode_assertion({Code, Details}) -> encode_assertion({Code, Details}) ->
#{code => Code, details => Details}. #{code => Code, details => Details}.