11 Commits

Author SHA1 Message Date
97828d895a run go mod tidy 2023-08-21 14:57:47 +02:00
soukainna
e55cf41e20 add return nil to compile 2023-02-22 14:57:22 +01:00
soukainna
74fe5f57e3 add deleteSub in event struct 2023-02-22 14:56:51 +01:00
soukainna
72c292bd47 fix conflie 2023-02-22 14:56:06 +01:00
soukainna
868e1321b7 add new event proto to fix conflie 2023-02-22 14:55:43 +01:00
soukainna
bd480e875a add new proto 2023-02-22 14:54:23 +01:00
soukainna
3bf6876365 Merge branch 'modifyAnEvent' into dev 2023-02-22 14:17:53 +01:00
81b27976f9 delete consol log 2023-02-15 14:25:27 +01:00
822c053e78 edit events proto en events.go for visualize history 2023-02-15 10:14:06 +01:00
soukainna
1ce72b2f88 add logic to delete and srore sub 2023-02-01 16:04:10 +01:00
ffa341b13d init 2023-02-01 10:09:43 +01:00
12 changed files with 443 additions and 160 deletions

4
go.mod
View File

@@ -3,16 +3,17 @@ module git.coopgo.io/coopgo-platform/agenda
go 1.18 go 1.18
require ( require (
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/spf13/viper v1.12.0 github.com/spf13/viper v1.12.0
go.mongodb.org/mongo-driver v1.10.1 go.mongodb.org/mongo-driver v1.10.1
google.golang.org/grpc v1.46.2 google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0 google.golang.org/protobuf v1.28.0
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
) )
require ( require (
github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.1 // indirect github.com/golang/snappy v0.0.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect github.com/klauspost/compress v1.13.6 // indirect
@@ -38,7 +39,6 @@ require (
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

View File

@@ -628,18 +628,128 @@ func (x *UnsubscribeEventResponse) GetOk() bool {
return false return false
} }
type DeleteSubscriptionRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Subscriber string `protobuf:"bytes,32,opt,name=subscriber,proto3" json:"subscriber,omitempty"`
Eventid string `protobuf:"bytes,33,opt,name=eventid,proto3" json:"eventid,omitempty"`
Data *_struct.Struct `protobuf:"bytes,34,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *DeleteSubscriptionRequest) Reset() {
*x = DeleteSubscriptionRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteSubscriptionRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteSubscriptionRequest) ProtoMessage() {}
func (x *DeleteSubscriptionRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteSubscriptionRequest.ProtoReflect.Descriptor instead.
func (*DeleteSubscriptionRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{12}
}
func (x *DeleteSubscriptionRequest) GetSubscriber() string {
if x != nil {
return x.Subscriber
}
return ""
}
func (x *DeleteSubscriptionRequest) GetEventid() string {
if x != nil {
return x.Eventid
}
return ""
}
func (x *DeleteSubscriptionRequest) GetData() *_struct.Struct {
if x != nil {
return x.Data
}
return nil
}
type DeleteSubscriptionResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ok bool `protobuf:"varint,41,opt,name=ok,proto3" json:"ok,omitempty"`
}
func (x *DeleteSubscriptionResponse) Reset() {
*x = DeleteSubscriptionResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteSubscriptionResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteSubscriptionResponse) ProtoMessage() {}
func (x *DeleteSubscriptionResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteSubscriptionResponse.ProtoReflect.Descriptor instead.
func (*DeleteSubscriptionResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{13}
}
func (x *DeleteSubscriptionResponse) GetOk() bool {
if x != nil {
return x.Ok
}
return false
}
type UpdateEventRequest struct { type UpdateEventRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,32,opt,name=event,proto3" json:"event,omitempty"` Event *Event `protobuf:"bytes,52,opt,name=event,proto3" json:"event,omitempty"`
} }
func (x *UpdateEventRequest) Reset() { func (x *UpdateEventRequest) Reset() {
*x = UpdateEventRequest{} *x = UpdateEventRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[12] mi := &file_agenda_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -652,7 +762,7 @@ func (x *UpdateEventRequest) String() string {
func (*UpdateEventRequest) ProtoMessage() {} func (*UpdateEventRequest) ProtoMessage() {}
func (x *UpdateEventRequest) ProtoReflect() protoreflect.Message { func (x *UpdateEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[12] mi := &file_agenda_proto_msgTypes[14]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -665,7 +775,7 @@ func (x *UpdateEventRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateEventRequest.ProtoReflect.Descriptor instead. // Deprecated: Use UpdateEventRequest.ProtoReflect.Descriptor instead.
func (*UpdateEventRequest) Descriptor() ([]byte, []int) { func (*UpdateEventRequest) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{12} return file_agenda_proto_rawDescGZIP(), []int{14}
} }
func (x *UpdateEventRequest) GetEvent() *Event { func (x *UpdateEventRequest) GetEvent() *Event {
@@ -680,13 +790,13 @@ type UpdateEventResponse struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Event *Event `protobuf:"bytes,33,opt,name=event,proto3" json:"event,omitempty"` Event *Event `protobuf:"bytes,53,opt,name=event,proto3" json:"event,omitempty"`
} }
func (x *UpdateEventResponse) Reset() { func (x *UpdateEventResponse) Reset() {
*x = UpdateEventResponse{} *x = UpdateEventResponse{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_agenda_proto_msgTypes[13] mi := &file_agenda_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -699,7 +809,7 @@ func (x *UpdateEventResponse) String() string {
func (*UpdateEventResponse) ProtoMessage() {} func (*UpdateEventResponse) ProtoMessage() {}
func (x *UpdateEventResponse) ProtoReflect() protoreflect.Message { func (x *UpdateEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_agenda_proto_msgTypes[13] mi := &file_agenda_proto_msgTypes[15]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -712,7 +822,7 @@ func (x *UpdateEventResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateEventResponse.ProtoReflect.Descriptor instead. // Deprecated: Use UpdateEventResponse.ProtoReflect.Descriptor instead.
func (*UpdateEventResponse) Descriptor() ([]byte, []int) { func (*UpdateEventResponse) Descriptor() ([]byte, []int) {
return file_agenda_proto_rawDescGZIP(), []int{13} return file_agenda_proto_rawDescGZIP(), []int{15}
} }
func (x *UpdateEventResponse) GetEvent() *Event { func (x *UpdateEventResponse) GetEvent() *Event {
@@ -779,44 +889,61 @@ var file_agenda_proto_rawDesc = []byte{
0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x22, 0x2a, 0x0a, 0x18, 0x55, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x22, 0x2a, 0x0a, 0x18, 0x55,
0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x27, 0x20, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x27, 0x20,
0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x32, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x82, 0x01, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65,
0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x13, 0x55, 0x62, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63,
0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64,
0x73, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x21, 0x20, 0x01, 0x28, 0x18, 0x21, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12,
0x0b, 0x32, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e,
0x32, 0xb5, 0x03, 0x0a, 0x06, 0x41, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x12, 0x3a, 0x0a, 0x0b, 0x43, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x43, 0x72, 0x65, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0x0a, 0x1a,
0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x14, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x45, 0x76, 0x18, 0x29, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x32, 0x0a, 0x12, 0x55, 0x70,
0x65, 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x47, 0x65,
0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x47, 0x65, 0x74,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x3a, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12,
0x13, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0b,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x14, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x34, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x73, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x33,
0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x53, 0x75, 0x62, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x35,
0x73, 0x74, 0x1a, 0x17, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x65, 0x6e, 0x74, 0x32, 0x86, 0x04, 0x0a, 0x06, 0x41, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x12, 0x3a,
0x10, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e,
0x74, 0x12, 0x18, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x55, 0x6e, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x08, 0x47, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e,
0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76,
0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a,
0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x09, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x11, 0x2e, 0x47, 0x65, 0x74,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x12, 0x13, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x3a, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x13,
0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x53,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e,
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x49, 0x0a, 0x10, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x62, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19,
0x2e, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x12, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x1a, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c,
0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f,
0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x61, 0x67,
0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -831,55 +958,60 @@ func file_agenda_proto_rawDescGZIP() []byte {
return file_agenda_proto_rawDescData return file_agenda_proto_rawDescData
} }
var file_agenda_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_agenda_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
var file_agenda_proto_goTypes = []interface{}{ var file_agenda_proto_goTypes = []interface{}{
(*CreateEventRequest)(nil), // 0: CreateEventRequest (*CreateEventRequest)(nil), // 0: CreateEventRequest
(*CreateEventResponse)(nil), // 1: CreateEventResponse (*CreateEventResponse)(nil), // 1: CreateEventResponse
(*GetEventRequest)(nil), // 2: GetEventRequest (*GetEventRequest)(nil), // 2: GetEventRequest
(*GetEventResponse)(nil), // 3: GetEventResponse (*GetEventResponse)(nil), // 3: GetEventResponse
(*DeleteEventRequest)(nil), // 4: DeleteEventRequest (*DeleteEventRequest)(nil), // 4: DeleteEventRequest
(*DeleteEventResponse)(nil), // 5: DeleteEventResponse (*DeleteEventResponse)(nil), // 5: DeleteEventResponse
(*GetEventsRequest)(nil), // 6: GetEventsRequest (*GetEventsRequest)(nil), // 6: GetEventsRequest
(*GetEventsResponse)(nil), // 7: GetEventsResponse (*GetEventsResponse)(nil), // 7: GetEventsResponse
(*SubscribeEventRequest)(nil), // 8: SubscribeEventRequest (*SubscribeEventRequest)(nil), // 8: SubscribeEventRequest
(*SubscribeEventResponse)(nil), // 9: SubscribeEventResponse (*SubscribeEventResponse)(nil), // 9: SubscribeEventResponse
(*UnsubscribeEventRequest)(nil), // 10: UnsubscribeEventRequest (*UnsubscribeEventRequest)(nil), // 10: UnsubscribeEventRequest
(*UnsubscribeEventResponse)(nil), // 11: UnsubscribeEventResponse (*UnsubscribeEventResponse)(nil), // 11: UnsubscribeEventResponse
(*UpdateEventRequest)(nil), // 12: UpdateEventRequest (*DeleteSubscriptionRequest)(nil), // 12: DeleteSubscriptionRequest
(*UpdateEventResponse)(nil), // 13: UpdateEventResponse (*DeleteSubscriptionResponse)(nil), // 13: DeleteSubscriptionResponse
(*Event)(nil), // 14: Event (*UpdateEventRequest)(nil), // 14: UpdateEventRequest
(*timestamp.Timestamp)(nil), // 15: google.protobuf.Timestamp (*UpdateEventResponse)(nil), // 15: UpdateEventResponse
(*_struct.Struct)(nil), // 16: google.protobuf.Struct (*Event)(nil), // 16: Event
(*timestamp.Timestamp)(nil), // 17: google.protobuf.Timestamp
(*_struct.Struct)(nil), // 18: google.protobuf.Struct
} }
var file_agenda_proto_depIdxs = []int32{ var file_agenda_proto_depIdxs = []int32{
14, // 0: CreateEventRequest.event:type_name -> Event 16, // 0: CreateEventRequest.event:type_name -> Event
14, // 1: CreateEventResponse.event:type_name -> Event 16, // 1: CreateEventResponse.event:type_name -> Event
14, // 2: GetEventResponse.event:type_name -> Event 16, // 2: GetEventResponse.event:type_name -> Event
15, // 3: GetEventsRequest.mindate:type_name -> google.protobuf.Timestamp 17, // 3: GetEventsRequest.mindate:type_name -> google.protobuf.Timestamp
15, // 4: GetEventsRequest.maxdate:type_name -> google.protobuf.Timestamp 17, // 4: GetEventsRequest.maxdate:type_name -> google.protobuf.Timestamp
14, // 5: GetEventsResponse.events:type_name -> Event 16, // 5: GetEventsResponse.events:type_name -> Event
16, // 6: SubscribeEventRequest.data:type_name -> google.protobuf.Struct 18, // 6: SubscribeEventRequest.data:type_name -> google.protobuf.Struct
14, // 7: UpdateEventRequest.event:type_name -> Event 18, // 7: DeleteSubscriptionRequest.data:type_name -> google.protobuf.Struct
14, // 8: UpdateEventResponse.event:type_name -> Event 16, // 8: UpdateEventRequest.event:type_name -> Event
0, // 9: Agenda.CreateEvent:input_type -> CreateEventRequest 16, // 9: UpdateEventResponse.event:type_name -> Event
2, // 10: Agenda.GetEvent:input_type -> GetEventRequest 0, // 10: Agenda.CreateEvent:input_type -> CreateEventRequest
6, // 11: Agenda.GetEvents:input_type -> GetEventsRequest 2, // 11: Agenda.GetEvent:input_type -> GetEventRequest
4, // 12: Agenda.DeleteEvent:input_type -> DeleteEventRequest 6, // 12: Agenda.GetEvents:input_type -> GetEventsRequest
12, // 13: Agenda.UpdateEvent:input_type -> UpdateEventRequest 4, // 13: Agenda.DeleteEvent:input_type -> DeleteEventRequest
8, // 14: Agenda.SubscribeEvent:input_type -> SubscribeEventRequest 14, // 14: Agenda.UpdateEvent:input_type -> UpdateEventRequest
10, // 15: Agenda.UnsubscribeEvent:input_type -> UnsubscribeEventRequest 8, // 15: Agenda.SubscribeEvent:input_type -> SubscribeEventRequest
1, // 16: Agenda.CreateEvent:output_type -> CreateEventResponse 10, // 16: Agenda.UnsubscribeEvent:input_type -> UnsubscribeEventRequest
3, // 17: Agenda.GetEvent:output_type -> GetEventResponse 12, // 17: Agenda.DeleteSubscription:input_type -> DeleteSubscriptionRequest
7, // 18: Agenda.GetEvents:output_type -> GetEventsResponse 1, // 18: Agenda.CreateEvent:output_type -> CreateEventResponse
5, // 19: Agenda.DeleteEvent:output_type -> DeleteEventResponse 3, // 19: Agenda.GetEvent:output_type -> GetEventResponse
13, // 20: Agenda.UpdateEvent:output_type -> UpdateEventResponse 7, // 20: Agenda.GetEvents:output_type -> GetEventsResponse
9, // 21: Agenda.SubscribeEvent:output_type -> SubscribeEventResponse 5, // 21: Agenda.DeleteEvent:output_type -> DeleteEventResponse
11, // 22: Agenda.UnsubscribeEvent:output_type -> UnsubscribeEventResponse 15, // 22: Agenda.UpdateEvent:output_type -> UpdateEventResponse
16, // [16:23] is the sub-list for method output_type 9, // 23: Agenda.SubscribeEvent:output_type -> SubscribeEventResponse
9, // [9:16] is the sub-list for method input_type 11, // 24: Agenda.UnsubscribeEvent:output_type -> UnsubscribeEventResponse
9, // [9:9] is the sub-list for extension type_name 13, // 25: Agenda.DeleteSubscription:output_type -> DeleteSubscriptionResponse
9, // [9:9] is the sub-list for extension extendee 18, // [18:26] is the sub-list for method output_type
0, // [0:9] is the sub-list for field type_name 10, // [10:18] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
} }
func init() { file_agenda_proto_init() } func init() { file_agenda_proto_init() }
@@ -1034,7 +1166,7 @@ func file_agenda_proto_init() {
} }
} }
file_agenda_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { file_agenda_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateEventRequest); i { switch v := v.(*DeleteSubscriptionRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -1046,6 +1178,30 @@ func file_agenda_proto_init() {
} }
} }
file_agenda_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { file_agenda_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteSubscriptionResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_agenda_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateEventResponse); i { switch v := v.(*UpdateEventResponse); i {
case 0: case 0:
return &v.state return &v.state
@@ -1064,7 +1220,7 @@ func file_agenda_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_agenda_proto_rawDesc, RawDescriptor: file_agenda_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 14, NumMessages: 16,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@@ -16,6 +16,7 @@ service Agenda {
rpc UpdateEvent(UpdateEventRequest) returns (UpdateEventResponse) {} rpc UpdateEvent(UpdateEventRequest) returns (UpdateEventResponse) {}
rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {} rpc SubscribeEvent(SubscribeEventRequest) returns (SubscribeEventResponse) {}
rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {} rpc UnsubscribeEvent(UnsubscribeEventRequest) returns (UnsubscribeEventResponse) {}
rpc DeleteSubscription(DeleteSubscriptionRequest) returns (DeleteSubscriptionResponse) {}
} }
message CreateEventRequest { message CreateEventRequest {
@@ -72,10 +73,19 @@ message UnsubscribeEventResponse {
bool ok = 39; bool ok = 39;
} }
message DeleteSubscriptionRequest {
string subscriber = 32;
string eventid = 33;
google.protobuf.Struct data = 34;
}
message DeleteSubscriptionResponse {
bool ok = 41;
}
message UpdateEventRequest { message UpdateEventRequest {
Event event = 32; Event event = 52;
} }
message UpdateEventResponse { message UpdateEventResponse {
Event event = 33; Event event = 53;
} }

View File

@@ -29,6 +29,7 @@ type AgendaClient interface {
UpdateEvent(ctx context.Context, in *UpdateEventRequest, opts ...grpc.CallOption) (*UpdateEventResponse, error) UpdateEvent(ctx context.Context, in *UpdateEventRequest, opts ...grpc.CallOption) (*UpdateEventResponse, error)
SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error) SubscribeEvent(ctx context.Context, in *SubscribeEventRequest, opts ...grpc.CallOption) (*SubscribeEventResponse, error)
UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error) UnsubscribeEvent(ctx context.Context, in *UnsubscribeEventRequest, opts ...grpc.CallOption) (*UnsubscribeEventResponse, error)
DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*DeleteSubscriptionResponse, error)
} }
type agendaClient struct { type agendaClient struct {
@@ -102,6 +103,15 @@ func (c *agendaClient) UnsubscribeEvent(ctx context.Context, in *UnsubscribeEven
return out, nil return out, nil
} }
func (c *agendaClient) DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*DeleteSubscriptionResponse, error) {
out := new(DeleteSubscriptionResponse)
err := c.cc.Invoke(ctx, "/Agenda/DeleteSubscription", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AgendaServer is the server API for Agenda service. // AgendaServer is the server API for Agenda service.
// All implementations must embed UnimplementedAgendaServer // All implementations must embed UnimplementedAgendaServer
// for forward compatibility // for forward compatibility
@@ -113,6 +123,7 @@ type AgendaServer interface {
UpdateEvent(context.Context, *UpdateEventRequest) (*UpdateEventResponse, error) UpdateEvent(context.Context, *UpdateEventRequest) (*UpdateEventResponse, error)
SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error) SubscribeEvent(context.Context, *SubscribeEventRequest) (*SubscribeEventResponse, error)
UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error)
DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*DeleteSubscriptionResponse, error)
mustEmbedUnimplementedAgendaServer() mustEmbedUnimplementedAgendaServer()
} }
@@ -141,6 +152,9 @@ func (UnimplementedAgendaServer) SubscribeEvent(context.Context, *SubscribeEvent
func (UnimplementedAgendaServer) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) { func (UnimplementedAgendaServer) UnsubscribeEvent(context.Context, *UnsubscribeEventRequest) (*UnsubscribeEventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnsubscribeEvent not implemented") return nil, status.Errorf(codes.Unimplemented, "method UnsubscribeEvent not implemented")
} }
func (UnimplementedAgendaServer) DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*DeleteSubscriptionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteSubscription not implemented")
}
func (UnimplementedAgendaServer) mustEmbedUnimplementedAgendaServer() {} func (UnimplementedAgendaServer) mustEmbedUnimplementedAgendaServer() {}
// UnsafeAgendaServer may be embedded to opt out of forward compatibility for this service. // UnsafeAgendaServer may be embedded to opt out of forward compatibility for this service.
@@ -280,6 +294,24 @@ func _Agenda_UnsubscribeEvent_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Agenda_DeleteSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteSubscriptionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AgendaServer).DeleteSubscription(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Agenda/DeleteSubscription",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AgendaServer).DeleteSubscription(ctx, req.(*DeleteSubscriptionRequest))
}
return interceptor(ctx, in, info, handler)
}
// Agenda_ServiceDesc is the grpc.ServiceDesc for Agenda service. // Agenda_ServiceDesc is the grpc.ServiceDesc for Agenda service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@@ -315,6 +347,10 @@ var Agenda_ServiceDesc = grpc.ServiceDesc{
MethodName: "UnsubscribeEvent", MethodName: "UnsubscribeEvent",
Handler: _Agenda_UnsubscribeEvent_Handler, Handler: _Agenda_UnsubscribeEvent_Handler,
}, },
{
MethodName: "DeleteSubscription",
Handler: _Agenda_DeleteSubscription_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "agenda.proto", Metadata: "agenda.proto",

View File

@@ -26,6 +26,7 @@ func (e Event) ToStorageType() storage.Event {
Allday: e.Allday, Allday: e.Allday,
MaxSubscribers: e.MaxSubscribers, MaxSubscribers: e.MaxSubscribers,
Subscriptions: []storage.Subscription{}, Subscriptions: []storage.Subscription{},
DeletedSubscription: []storage.Subscription{},
Data: map[string]any{}, Data: map[string]any{},
Deleted: e.Deleted, Deleted: e.Deleted,
} }
@@ -34,6 +35,10 @@ func (e Event) ToStorageType() storage.Event {
event.Subscriptions = append(event.Subscriptions, v.ToStorageType()) 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() { for k, d := range e.Data.GetFields() {
jsondata, err := protojson.Marshal(d) jsondata, err := protojson.Marshal(d)
if err != nil { if err != nil {
@@ -73,12 +78,18 @@ func EventFromStorageType(event *storage.Event) (*Event, error) {
} }
subscriptions := []*Subscription{} subscriptions := []*Subscription{}
deletedsubscription := []*Subscription{}
for _, v := range event.Subscriptions { for _, v := range event.Subscriptions {
sub, _ := SubscriptionFromStorageType(v) sub, _ := SubscriptionFromStorageType(v)
subscriptions = append(subscriptions, sub) subscriptions = append(subscriptions, sub)
} }
for _, v := range event.DeletedSubscription {
sub, _ := SubscriptionFromStorageType(v)
deletedsubscription = append(deletedsubscription, sub)
}
return &Event{ return &Event{
Id: event.ID, Id: event.ID,
Namespace: event.Namespace, Namespace: event.Namespace,
@@ -94,6 +105,7 @@ func EventFromStorageType(event *storage.Event) (*Event, error) {
Allday: event.Allday, Allday: event.Allday,
MaxSubscribers: event.MaxSubscribers, MaxSubscribers: event.MaxSubscribers,
Subscriptions: subscriptions, Subscriptions: subscriptions,
DeletedSubscription: deletedsubscription,
Data: data, Data: data,
Deleted: event.Deleted, Deleted: event.Deleted,
}, nil }, nil

View File

@@ -27,22 +27,23 @@ type Event struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
Owners []string `protobuf:"bytes,4,rep,name=owners,proto3" json:"owners,omitempty"` Owners []string `protobuf:"bytes,4,rep,name=owners,proto3" json:"owners,omitempty"`
RestrictedTo []string `protobuf:"bytes,5,rep,name=restricted_to,json=restrictedTo,proto3" json:"restricted_to,omitempty"` RestrictedTo []string `protobuf:"bytes,5,rep,name=restricted_to,json=restrictedTo,proto3" json:"restricted_to,omitempty"`
Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"`
Startdate *timestamp.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"` Startdate *timestamp.Timestamp `protobuf:"bytes,8,opt,name=startdate,proto3" json:"startdate,omitempty"`
Enddate *timestamp.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"` Enddate *timestamp.Timestamp `protobuf:"bytes,9,opt,name=enddate,proto3" json:"enddate,omitempty"`
Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"` Allday bool `protobuf:"varint,10,opt,name=allday,proto3" json:"allday,omitempty"`
Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"` Starttime string `protobuf:"bytes,11,opt,name=starttime,proto3" json:"starttime,omitempty"`
Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"` Endtime string `protobuf:"bytes,12,opt,name=endtime,proto3" json:"endtime,omitempty"`
MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"` MaxSubscribers int64 `protobuf:"varint,13,opt,name=max_subscribers,json=maxSubscribers,proto3" json:"max_subscribers,omitempty"`
Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"` Subscriptions []*Subscription `protobuf:"bytes,14,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
Data *_struct.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"` DeletedSubscription []*Subscription `protobuf:"bytes,16,rep,name=deleted_subscription,json=deletedSubscription,proto3" json:"deleted_subscription,omitempty"`
Deleted bool `protobuf:"varint,16,opt,name=deleted,proto3" json:"deleted,omitempty"` Data *_struct.Struct `protobuf:"bytes,15,opt,name=data,proto3" json:"data,omitempty"`
Deleted bool `protobuf:"varint,17,opt,name=deleted,proto3" json:"deleted,omitempty"`
} }
func (x *Event) Reset() { func (x *Event) Reset() {
@@ -175,6 +176,13 @@ func (x *Event) GetSubscriptions() []*Subscription {
return nil return nil
} }
func (x *Event) GetDeletedSubscription() []*Subscription {
if x != nil {
return x.DeletedSubscription
}
return nil
}
func (x *Event) GetData() *_struct.Struct { func (x *Event) GetData() *_struct.Struct {
if x != nil { if x != nil {
return x.Data return x.Data
@@ -275,7 +283,7 @@ var file_events_proto_rawDesc = []byte{
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x04, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe3, 0x04,
0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73,
0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65,
@@ -305,27 +313,31 @@ var file_events_proto_rawDesc = []byte{
0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x33, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x33, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53,
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x75, 0x62, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x75, 0x62,
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x40, 0x0a, 0x14, 0x64, 0x65,
0x74, 0x61, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63,
0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64,
0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x04,
0x64, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f,
0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72,
0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c,
0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x74, 0x65, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65,
0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x09, 0x74, 0x65, 0x64, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70,
0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x17, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x65, 0x72, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
0x61, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x69, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x16, 0x20, 0x03,
0x74, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52,
0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x5f, 0x61, 0x74, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74,
0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69,
0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72,
0x6d, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -351,14 +363,15 @@ var file_events_proto_depIdxs = []int32{
2, // 0: Event.startdate:type_name -> google.protobuf.Timestamp 2, // 0: Event.startdate:type_name -> google.protobuf.Timestamp
2, // 1: Event.enddate:type_name -> google.protobuf.Timestamp 2, // 1: Event.enddate:type_name -> google.protobuf.Timestamp
1, // 2: Event.subscriptions:type_name -> Subscription 1, // 2: Event.subscriptions:type_name -> Subscription
3, // 3: Event.data:type_name -> google.protobuf.Struct 1, // 3: Event.deleted_subscription:type_name -> Subscription
3, // 4: Subscription.data:type_name -> google.protobuf.Struct 3, // 4: Event.data:type_name -> google.protobuf.Struct
2, // 5: Subscription.created_at:type_name -> google.protobuf.Timestamp 3, // 5: Subscription.data:type_name -> google.protobuf.Struct
6, // [6:6] is the sub-list for method output_type 2, // 6: Subscription.created_at:type_name -> google.protobuf.Timestamp
6, // [6:6] is the sub-list for method input_type 7, // [7:7] is the sub-list for method output_type
6, // [6:6] is the sub-list for extension type_name 7, // [7:7] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension extendee 7, // [7:7] is the sub-list for extension type_name
0, // [0:6] is the sub-list for field type_name 7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
} }
func init() { file_events_proto_init() } func init() { file_events_proto_init() }

View File

@@ -20,8 +20,9 @@ message Event {
string endtime = 12; string endtime = 12;
int64 max_subscribers = 13; int64 max_subscribers = 13;
repeated Subscription subscriptions = 14; repeated Subscription subscriptions = 14;
repeated Subscription deleted_subscription = 16;
google.protobuf.Struct data = 15; google.protobuf.Struct data = 15;
bool deleted = 16; bool deleted = 17;
} }
message Subscription { message Subscription {

View File

@@ -95,6 +95,16 @@ func (s AgendaServerImpl) UnsubscribeEvent(context.Context, *UnsubscribeEventReq
return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented") return nil, status.Errorf(codes.Unimplemented, "method Unsubscribe not implemented")
} }
////////////////////////////////////////////////////////////
func (s AgendaServerImpl) DeleteSubscription(ctx context.Context, req *DeleteSubscriptionRequest) (*DeleteSubscriptionResponse, error) {
err := s.handler.DeleteSubscription(req.Eventid, req.Subscriber, req.Data.AsMap())
return &DeleteSubscriptionResponse{
Ok: err != nil,
}, err
}
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
func (s AgendaServerImpl) UpdateEvent(ctx context.Context, req *UpdateEventRequest) (*UpdateEventResponse, error) { func (s AgendaServerImpl) UpdateEvent(ctx context.Context, req *UpdateEventRequest) (*UpdateEventResponse, error) {
b := req.Event.ToStorageType() b := req.Event.ToStorageType()

View File

@@ -71,6 +71,26 @@ func (h AgendaHandler) SubscribeEvent(eventid string, subscriber string, data ma
return return
} }
func (h AgendaHandler) DeleteSubscription(eventid string, subscriber string, data map[string]any) (err error) {
if eventid == "" || subscriber == "" {
return errors.New("missing eventid or subscriber")
}
now := time.Now()
id := uuid.NewString()
deletesubscription := storage.Subscription{
ID: id,
Subscriber: subscriber,
Tags: []string{},
CreatedAt: now,
Data: map[string]any{},
}
// Initiate data map
for k, v := range data {
deletesubscription.Data[k] = v
}
err = h.storage.UpdateSubscription(eventid, subscriber, deletesubscription)
return
}
func (h AgendaHandler) UpdateEvent(event storage.Event) (*storage.Event, error) { func (h AgendaHandler) UpdateEvent(event storage.Event) (*storage.Event, error) {
// Store the account // Store the account

View File

@@ -3,22 +3,23 @@ package storage
import "time" import "time"
type Event struct { type Event struct {
ID string `json:"id" bson:"_id"` ID string `json:"id" bson:"_id"`
Namespace string `json:"namespace"` Namespace string `json:"namespace"`
Owners []string `json:"owners"` Owners []string `json:"owners"`
RestrictedTo []string `json:"restricted_to"` RestrictedTo []string `json:"restricted_to"`
Type string `json:"type"` Type string `json:"type"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
Startdate time.Time `json:"startdate"` Startdate time.Time `json:"startdate"`
Enddate time.Time `json:"enddate"` Enddate time.Time `json:"enddate"`
Starttime string `json:"starttime"` Starttime string `json:"starttime"`
Endtime string `json:"endtime"` Endtime string `json:"endtime"`
Allday bool `json:"allday"` Allday bool `json:"allday"`
MaxSubscribers int64 `json:"max_subscribers"` MaxSubscribers int64 `json:"max_subscribers"`
Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"` Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"`
Data map[string]any `json:"data"` DeletedSubscription []Subscription `json:"deletedsubscriptions" bson:"deletedsubscriptions,omitempty"`
Deleted bool `json:"deleted"` Data map[string]any `json:"data"`
Deleted bool `json:"deleted"`
} }
type Subscription struct { type Subscription struct {

View File

@@ -121,6 +121,29 @@ func (s MongoDBStorage) AddSubscription(eventid string, subscription Subscriptio
return err return err
} }
func (s MongoDBStorage) UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error {
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
event := &Event{}
if errr := collection.FindOne(context.TODO(), bson.M{"_id": eventid}).Decode(event); errr != nil {
return errr
}
for i := range event.Subscriptions {
if event.Subscriptions[i].Subscriber == subscriber {
filter := bson.M{"_id": eventid}
push := bson.M{"$push": bson.M{"deletedsubscriptions": deletesubscription}}
pull := bson.M{"$pull": bson.M{"subscriptions": bson.M{"subscriber": subscriber}}}
_, er := collection.UpdateOne(context.TODO(), filter, push)
if _, err := collection.UpdateOne(context.TODO(), filter, pull); err != nil {
return err
}
return er
}
}
return nil
}
func (s MongoDBStorage) UpdateEvent(event Event) error { func (s MongoDBStorage) UpdateEvent(event Event) error {
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"]) collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
if _, err := collection.ReplaceOne(context.TODO(), bson.M{"_id": event.ID}, event); err != nil { if _, err := collection.ReplaceOne(context.TODO(), bson.M{"_id": event.ID}, event); err != nil {

View File

@@ -11,6 +11,7 @@ type Storage interface {
GetEvent(string) (*Event, error) GetEvent(string) (*Event, error)
GetEvents(namespaces []string) ([]Event, error) GetEvents(namespaces []string) ([]Event, error)
AddSubscription(eventid string, subscription Subscription) error AddSubscription(eventid string, subscription Subscription) error
UpdateSubscription(eventid string, subscriber string, deletesubscription Subscription) error
UpdateEvent(Event) error UpdateEvent(Event) error
} }
type StorageImpl struct { type StorageImpl struct {