diff options
author | Konstantinos Kallas <konstantinos.kallas@hotmail.com> | 2017-07-17 09:59:38 +0300 |
---|---|---|
committer | Konstantinos Kallas <konstantinos.kallas@hotmail.com> | 2017-07-17 09:59:38 +0300 |
commit | 9cf596c67b83eb690d8776ee500ade221af8e47d (patch) | |
tree | 521420aa57859ef7f4f024d081697cad81ff8a3e /src/ejabberd_acme.erl | |
parent | Separate the persistent data structure functions (diff) |
Change the persistent data structure from a record to a proplist
This is done so that possible future updates to the data structure don't break existing code.
With this change it will be possible to update the data structure and keep the same old persistent data file, which will still have the expected list format but with more properties
Diffstat (limited to 'src/ejabberd_acme.erl')
-rw-r--r-- | src/ejabberd_acme.erl | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ejabberd_acme.erl b/src/ejabberd_acme.erl index 029f13ed..5d0608c9 100644 --- a/src/ejabberd_acme.erl +++ b/src/ejabberd_acme.erl @@ -401,19 +401,19 @@ is_error(_) -> false. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% data_empty() -> - #data{}. + []. -data_get_account(#data{account = Account}) -> - case Account of - #data_acc{id = AccId, key = PrivateKey} -> +data_get_account(Data) -> + case lists:keyfind(account, 1, Data) of + {account, #data_acc{id = AccId, key = PrivateKey}} -> {ok, AccId, PrivateKey}; - none -> + false -> none end. -data_set_account(Data = #data{}, {AccId, PrivateKey}) -> - NewAcc = #data_acc{id = AccId, key = PrivateKey}, - Data#data{account = NewAcc}. +data_set_account(Data, {AccId, PrivateKey}) -> + NewAcc = {account, #data_acc{id = AccId, key = PrivateKey}}, + lists:keystore(account, 1, Data, NewAcc). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |