diff --git a/internal/static/i18n/de.yaml b/internal/static/i18n/de.yaml index 2c6dec4c5f..a32ac9f4e3 100644 --- a/internal/static/i18n/de.yaml +++ b/internal/static/i18n/de.yaml @@ -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: diff --git a/internal/static/i18n/en.yaml b/internal/static/i18n/en.yaml index 7f82bfa7c7..08579d24bf 100644 --- a/internal/static/i18n/en.yaml +++ b/internal/static/i18n/en.yaml @@ -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: diff --git a/internal/user/repository/eventsourcing/model/user_machine.go b/internal/user/repository/eventsourcing/model/user_machine.go index 25de45e373..a73aee5116 100644 --- a/internal/user/repository/eventsourcing/model/user_machine.go +++ b/internal/user/repository/eventsourcing/model/user_machine.go @@ -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 {