fix(machine): set creationdate (#1018)

* fix(machine): set creationdate

* fix(translations): translate `user.human.phone.removed`
This commit is contained in:
Silvan 2020-11-25 07:42:06 +01:00 committed by GitHub
parent 78a1b8f019
commit 42f50de790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -294,6 +294,7 @@ EventTypes:
code:
added: Telefon Code hinzugefügt
sent: Telefon Code versendet
removed: Telefonnummer gelöscht
profile:
changed: Benutzerprofil geändert
address:

View File

@ -282,6 +282,7 @@ EventTypes:
code:
added: Phone number code generated
sent: Phone number code sent
removed: Phone number removed
profile:
changed: User profile changed
address:

View File

@ -86,11 +86,18 @@ func (key *MachineKey) AppendEvents(events ...*es_models.Event) error {
return nil
}
func (key *MachineKey) AppendEvent(event *es_models.Event) error {
func (key *MachineKey) AppendEvent(event *es_models.Event) (err error) {
key.ObjectRoot.AppendEvent(event)
switch event.Type {
case MachineKeyAdded:
err = json.Unmarshal(event.Data, key)
if err != nil {
return errors.ThrowInternal(err, "MODEL-SjI4S", "Errors.Internal")
}
case MachineKeyRemoved:
key.ExpirationDate = event.CreationDate
}
return nil
return err
}
func MachineKeyFromModel(machine *model.MachineKey) *MachineKey {