agenda/storage/events.go

39 lines
1.4 KiB
Go
Raw Normal View History

2022-09-05 05:27:52 +00:00
package storage
import "time"
type Event struct {
2023-02-22 13:56:51 +00:00
ID string `json:"id" bson:"_id"`
Namespace string `json:"namespace"`
Owners []string `json:"owners"`
RestrictedTo []string `json:"restricted_to"`
Type string `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Startdate time.Time `json:"startdate"`
Enddate time.Time `json:"enddate"`
Starttime string `json:"starttime"`
Endtime string `json:"endtime"`
Allday bool `json:"allday"`
MaxSubscribers int64 `json:"max_subscribers"`
Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"`
DeletedSubscription []Subscription `json:"deletedsubscriptions" bson:"deletedsubscriptions,omitempty"`
Data map[string]any `json:"data"`
Deleted bool `json:"deleted"`
2022-10-17 03:00:35 +00:00
}
type Subscription struct {
2022-12-05 16:21:12 +00:00
ID string `json:"id" bson:"_id"`
2022-10-17 03:00:35 +00:00
Subscriber string `json:"subscriber"`
Tags []string `json:"tags"`
2022-12-05 16:21:12 +00:00
CreatedAt time.Time `json:"created_at,omitempty"`
2022-10-17 03:00:35 +00:00
Data map[string]any `json:"data"`
2022-09-05 05:27:52 +00:00
}
func (e Event) RemainingSubscriptions() int {
if e.MaxSubscribers == 0 {
return 999
}
2022-10-17 03:00:35 +00:00
return int(e.MaxSubscribers) - len(e.Subscriptions)
2022-09-05 05:27:52 +00:00
}