edit events proto en events.go for visualize history

This commit is contained in:
2023-02-15 10:14:06 +01:00
parent 1ce72b2f88
commit 822c053e78
6 changed files with 709 additions and 1215 deletions

View File

@@ -26,6 +26,7 @@ func (e Event) ToStorageType() storage.Event {
Allday: e.Allday,
MaxSubscribers: e.MaxSubscribers,
Subscriptions: []storage.Subscription{},
DeletedSubscription: []storage.Subscription{},
Data: map[string]any{},
}
@@ -33,6 +34,10 @@ func (e Event) ToStorageType() storage.Event {
event.Subscriptions = append(event.Subscriptions, v.ToStorageType())
}
for _, v := range e.DeletedSubscription {
event.DeletedSubscription = append(event.DeletedSubscription, v.ToStorageType())
}
for k, d := range e.Data.GetFields() {
jsondata, err := protojson.Marshal(d)
if err != nil {
@@ -72,12 +77,18 @@ func EventFromStorageType(event *storage.Event) (*Event, error) {
}
subscriptions := []*Subscription{}
deletedsubscription := []*Subscription{}
for _, v := range event.Subscriptions {
sub, _ := SubscriptionFromStorageType(v)
subscriptions = append(subscriptions, sub)
}
for _, v := range event.DeletedSubscription {
sub, _ := SubscriptionFromStorageType(v)
deletedsubscription = append(deletedsubscription, sub)
}
return &Event{
Id: event.ID,
Namespace: event.Namespace,
@@ -93,6 +104,7 @@ func EventFromStorageType(event *storage.Event) (*Event, error) {
Allday: event.Allday,
MaxSubscribers: event.MaxSubscribers,
Subscriptions: subscriptions,
DeletedSubscription: deletedsubscription,
Data: data,
}, nil
}