mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 09:20:15 -06:00
Add function to fetch events containing userID.
This PR adds a function to fetch events containing a userID. This is to be able to offer this functionality for the GDPR requirement.
This commit is contained in:
@@ -71,6 +71,55 @@ func (x *GetEventsRequest) GetIds() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A request to retrieve events belonging to a userID
|
||||
type GetEventsForUserRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// the userID of the events we want to get
|
||||
UserID string `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetEventsForUserRequest) Reset() {
|
||||
*x = GetEventsForUserRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetEventsForUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetEventsForUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetEventsForUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[1]
|
||||
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 GetEventsForUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetEventsForUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_ocis_services_eventhistory_v0_eventhistory_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetEventsForUserRequest) GetUserID() string {
|
||||
if x != nil {
|
||||
return x.UserID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The service response
|
||||
type GetEventsResponse struct {
|
||||
state protoimpl.MessageState
|
||||
@@ -83,7 +132,7 @@ type GetEventsResponse struct {
|
||||
func (x *GetEventsResponse) Reset() {
|
||||
*x = GetEventsResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[1]
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -96,7 +145,7 @@ func (x *GetEventsResponse) String() string {
|
||||
func (*GetEventsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetEventsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[1]
|
||||
mi := &file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -109,7 +158,7 @@ func (x *GetEventsResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use GetEventsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetEventsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_ocis_services_eventhistory_v0_eventhistory_proto_rawDescGZIP(), []int{1}
|
||||
return file_ocis_services_eventhistory_v0_eventhistory_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *GetEventsResponse) GetEvents() []*v0.Event {
|
||||
@@ -135,44 +184,55 @@ var file_ocis_services_eventhistory_v0_eventhistory_proto_rawDesc = []byte{
|
||||
0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x51, 0x0a, 0x11, 0x47, 0x65, 0x74,
|
||||
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c,
|
||||
0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24,
|
||||
0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x65,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x30, 0x2e, 0x45,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x32, 0x85, 0x01, 0x0a,
|
||||
0x13, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x12, 0x6e, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74,
|
||||
0x73, 0x12, 0x2f, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x31, 0x0a, 0x17, 0x47, 0x65, 0x74,
|
||||
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x51, 0x0a, 0x11,
|
||||
0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x3c, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76,
|
||||
0x30, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e,
|
||||
0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x42, 0xeb, 0x02, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x30, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x32,
|
||||
0x83, 0x02, 0x0a, 0x13, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79,
|
||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6e, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x45, 0x76,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x79, 0x2e, 0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f,
|
||||
0x72, 0x79, 0x2e, 0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7c, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x45, 0x76,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x36, 0x2e, 0x6f, 0x63,
|
||||
0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e,
|
||||
0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x45,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||
0x63, 0x65, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79,
|
||||
0x2e, 0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xeb, 0x02, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63,
|
||||
0x69, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
|
||||
0x6f, 0x63, 0x69, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x65, 0x76,
|
||||
0x65, 0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x30, 0x92, 0x41, 0xa2,
|
||||
0x02, 0x12, 0xb8, 0x01, 0x0a, 0x22, 0x6f, 0x77, 0x6e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x20, 0x49,
|
||||
0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x74, 0x68,
|
||||
0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x47, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x43,
|
||||
0x6c, 0x6f, 0x75, 0x64, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x12, 0x20, 0x68, 0x74, 0x74, 0x70, 0x73,
|
||||
0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77,
|
||||
0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x1a, 0x14, 0x73, 0x75, 0x70,
|
||||
0x70, 0x6f, 0x72, 0x74, 0x40, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2a, 0x42, 0x0a, 0x0a, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2d, 0x32, 0x2e, 0x30, 0x12,
|
||||
0x34, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69,
|
||||
0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x6f,
|
||||
0x63, 0x69, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x65, 0x76, 0x65,
|
||||
0x6e, 0x74, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x30, 0x92, 0x41, 0xa2, 0x02,
|
||||
0x12, 0xb8, 0x01, 0x0a, 0x22, 0x6f, 0x77, 0x6e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x20, 0x49, 0x6e,
|
||||
0x66, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x74, 0x68, 0x75,
|
||||
0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x47, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x43, 0x6c,
|
||||
0x6f, 0x75, 0x64, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x12, 0x20, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a,
|
||||
0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e,
|
||||
0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x1a, 0x14, 0x73, 0x75, 0x70, 0x70,
|
||||
0x6f, 0x72, 0x74, 0x40, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2a, 0x42, 0x0a, 0x0a, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2d, 0x32, 0x2e, 0x30, 0x12, 0x34,
|
||||
0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73,
|
||||
0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2f, 0x4c, 0x49, 0x43,
|
||||
0x45, 0x4e, 0x53, 0x45, 0x32, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x2a, 0x02, 0x01, 0x02, 0x32,
|
||||
0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f,
|
||||
0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a,
|
||||
0x73, 0x6f, 0x6e, 0x72, 0x3d, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72,
|
||||
0x20, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x12, 0x29, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f,
|
||||
0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x64, 0x65, 0x76, 0x2f, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c,
|
||||
0x73, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2f, 0x4c, 0x49,
|
||||
0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x2a, 0x02, 0x01, 0x02,
|
||||
0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73,
|
||||
0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f,
|
||||
0x6a, 0x73, 0x6f, 0x6e, 0x72, 0x3d, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65,
|
||||
0x72, 0x20, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x12, 0x29, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a,
|
||||
0x2f, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x64, 0x65, 0x76, 0x2f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69,
|
||||
0x6c, 0x73, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -187,18 +247,21 @@ func file_ocis_services_eventhistory_v0_eventhistory_proto_rawDescGZIP() []byte
|
||||
return file_ocis_services_eventhistory_v0_eventhistory_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_ocis_services_eventhistory_v0_eventhistory_proto_goTypes = []interface{}{
|
||||
(*GetEventsRequest)(nil), // 0: ocis.services.eventhistory.v0.GetEventsRequest
|
||||
(*GetEventsResponse)(nil), // 1: ocis.services.eventhistory.v0.GetEventsResponse
|
||||
(*v0.Event)(nil), // 2: ocis.messages.eventhistory.v0.Event
|
||||
(*GetEventsRequest)(nil), // 0: ocis.services.eventhistory.v0.GetEventsRequest
|
||||
(*GetEventsForUserRequest)(nil), // 1: ocis.services.eventhistory.v0.GetEventsForUserRequest
|
||||
(*GetEventsResponse)(nil), // 2: ocis.services.eventhistory.v0.GetEventsResponse
|
||||
(*v0.Event)(nil), // 3: ocis.messages.eventhistory.v0.Event
|
||||
}
|
||||
var file_ocis_services_eventhistory_v0_eventhistory_proto_depIdxs = []int32{
|
||||
2, // 0: ocis.services.eventhistory.v0.GetEventsResponse.events:type_name -> ocis.messages.eventhistory.v0.Event
|
||||
3, // 0: ocis.services.eventhistory.v0.GetEventsResponse.events:type_name -> ocis.messages.eventhistory.v0.Event
|
||||
0, // 1: ocis.services.eventhistory.v0.EventHistoryService.GetEvents:input_type -> ocis.services.eventhistory.v0.GetEventsRequest
|
||||
1, // 2: ocis.services.eventhistory.v0.EventHistoryService.GetEvents:output_type -> ocis.services.eventhistory.v0.GetEventsResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // 2: ocis.services.eventhistory.v0.EventHistoryService.GetEventsForUser:input_type -> ocis.services.eventhistory.v0.GetEventsForUserRequest
|
||||
2, // 3: ocis.services.eventhistory.v0.EventHistoryService.GetEvents:output_type -> ocis.services.eventhistory.v0.GetEventsResponse
|
||||
2, // 4: ocis.services.eventhistory.v0.EventHistoryService.GetEventsForUser:output_type -> ocis.services.eventhistory.v0.GetEventsResponse
|
||||
3, // [3:5] is the sub-list for method output_type
|
||||
1, // [1:3] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
@@ -223,6 +286,18 @@ func file_ocis_services_eventhistory_v0_eventhistory_proto_init() {
|
||||
}
|
||||
}
|
||||
file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetEventsForUserRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_ocis_services_eventhistory_v0_eventhistory_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetEventsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -241,7 +316,7 @@ func file_ocis_services_eventhistory_v0_eventhistory_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_ocis_services_eventhistory_v0_eventhistory_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@@ -40,6 +40,8 @@ func NewEventHistoryServiceEndpoints() []*api.Endpoint {
|
||||
type EventHistoryService interface {
|
||||
// returns the specified events
|
||||
GetEvents(ctx context.Context, in *GetEventsRequest, opts ...client.CallOption) (*GetEventsResponse, error)
|
||||
// returns all events for the specified userID
|
||||
GetEventsForUser(ctx context.Context, in *GetEventsForUserRequest, opts ...client.CallOption) (*GetEventsResponse, error)
|
||||
}
|
||||
|
||||
type eventHistoryService struct {
|
||||
@@ -64,16 +66,29 @@ func (c *eventHistoryService) GetEvents(ctx context.Context, in *GetEventsReques
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *eventHistoryService) GetEventsForUser(ctx context.Context, in *GetEventsForUserRequest, opts ...client.CallOption) (*GetEventsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "EventHistoryService.GetEventsForUser", in)
|
||||
out := new(GetEventsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for EventHistoryService service
|
||||
|
||||
type EventHistoryServiceHandler interface {
|
||||
// returns the specified events
|
||||
GetEvents(context.Context, *GetEventsRequest, *GetEventsResponse) error
|
||||
// returns all events for the specified userID
|
||||
GetEventsForUser(context.Context, *GetEventsForUserRequest, *GetEventsResponse) error
|
||||
}
|
||||
|
||||
func RegisterEventHistoryServiceHandler(s server.Server, hdlr EventHistoryServiceHandler, opts ...server.HandlerOption) error {
|
||||
type eventHistoryService interface {
|
||||
GetEvents(ctx context.Context, in *GetEventsRequest, out *GetEventsResponse) error
|
||||
GetEventsForUser(ctx context.Context, in *GetEventsForUserRequest, out *GetEventsResponse) error
|
||||
}
|
||||
type EventHistoryService struct {
|
||||
eventHistoryService
|
||||
@@ -89,3 +104,7 @@ type eventHistoryServiceHandler struct {
|
||||
func (h *eventHistoryServiceHandler) GetEvents(ctx context.Context, in *GetEventsRequest, out *GetEventsResponse) error {
|
||||
return h.EventHistoryServiceHandler.GetEvents(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *eventHistoryServiceHandler) GetEventsForUser(ctx context.Context, in *GetEventsForUserRequest, out *GetEventsResponse) error {
|
||||
return h.EventHistoryServiceHandler.GetEventsForUser(ctx, in, out)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
service EventHistoryService {
|
||||
// returns the specified events
|
||||
rpc GetEvents(GetEventsRequest) returns (GetEventsResponse);
|
||||
// returns all events for the specified userID
|
||||
rpc GetEventsForUser(GetEventsForUserRequest) returns (GetEventsResponse);
|
||||
}
|
||||
|
||||
// A request to retrieve events
|
||||
@@ -44,6 +46,12 @@ message GetEventsRequest {
|
||||
repeated string ids = 1;
|
||||
}
|
||||
|
||||
// A request to retrieve events belonging to a userID
|
||||
message GetEventsForUserRequest {
|
||||
// the userID of the events we want to get
|
||||
string userID = 1;
|
||||
}
|
||||
|
||||
// The service response
|
||||
message GetEventsResponse {
|
||||
repeated ocis.messages.eventhistory.v0.Event events = 1;
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
@@ -75,3 +76,39 @@ func (eh *EventHistoryService) GetEvents(ctx context.Context, req *ehsvc.GetEven
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetEventsForUser allows to retrieve events from the eventstore by userID
|
||||
// This function will match all events that contains the user ID between two non-word characters.
|
||||
// The reasoning behind this is that events put the userID in many different fields, which can differ
|
||||
// per event type. This function will match all events that contain the userID by using a regex.
|
||||
// This should also cover future events that might contain the userID in a different field.
|
||||
func (eh *EventHistoryService) GetEventsForUser(ctx context.Context, req *ehsvc.GetEventsForUserRequest, resp *ehsvc.GetEventsResponse) error {
|
||||
idx, err := eh.store.List(store.ListPrefix(""))
|
||||
if err != nil {
|
||||
eh.log.Error().Err(err).Msg("could not list events")
|
||||
return err
|
||||
}
|
||||
|
||||
// Match all events that contains the user ID between two non-word characters.
|
||||
userID := regexp.MustCompile(fmt.Sprintf(`\W%s\W`, req.UserID))
|
||||
|
||||
for _, i := range idx {
|
||||
e, err := eh.store.Read(i)
|
||||
if err != nil {
|
||||
if err != store.ErrNotFound {
|
||||
eh.log.Error().Err(err).Str("eventid", i).Msg("could not read event")
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if userID.Match(e[0].Value) {
|
||||
resp.Events = append(resp.Events, &ehmsg.Event{
|
||||
Id: i,
|
||||
Event: e[0].Value,
|
||||
Type: e[0].Metadata["type"].(string),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/google/uuid"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
@@ -34,7 +36,6 @@ var _ = Describe("EventHistoryService", func() {
|
||||
bus = testBus(make(chan events.Event))
|
||||
eh, err = service.NewEventHistoryService(cfg, bus, sto, log.Logger{})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
@@ -54,7 +55,49 @@ var _ = Describe("EventHistoryService", func() {
|
||||
|
||||
Expect(len(resp.Events)).To(Equal(1))
|
||||
Expect(resp.Events[0].Id).To(Equal(id))
|
||||
})
|
||||
|
||||
It("Gets all events", func() {
|
||||
ids := make([]string, 3)
|
||||
ids[0] = bus.Publish(events.UploadReady{
|
||||
ExecutingUser: &userv1beta1.User{
|
||||
Id: &userv1beta1.UserId{
|
||||
OpaqueId: "test-id",
|
||||
},
|
||||
},
|
||||
Failed: false,
|
||||
Timestamp: time.Time{},
|
||||
})
|
||||
ids[1] = bus.Publish(events.UserCreated{
|
||||
UserID: "another-id",
|
||||
})
|
||||
ids[2] = bus.Publish(events.UserDeleted{
|
||||
Executant: &userv1beta1.UserId{
|
||||
OpaqueId: "another-id",
|
||||
},
|
||||
UserID: "test-id",
|
||||
})
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
resp := &ehsvc.GetEventsResponse{}
|
||||
err := eh.GetEventsForUser(context.Background(), &ehsvc.GetEventsForUserRequest{UserID: "test-id"}, resp)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(resp).ToNot(BeNil())
|
||||
|
||||
// Events don't always come back in the same order as they were sent, so we need to sort them and
|
||||
// do the same for the expcted IDs as well.
|
||||
expectedIDs := []string{ids[0], ids[2]}
|
||||
sort.Strings(expectedIDs)
|
||||
var gotIDs []string
|
||||
for _, ev := range resp.Events {
|
||||
gotIDs = append(gotIDs, ev.Id)
|
||||
}
|
||||
sort.Strings(gotIDs)
|
||||
|
||||
Expect(len(gotIDs)).To(Equal(len(expectedIDs)))
|
||||
Expect(gotIDs[0]).To(Equal(expectedIDs[0]))
|
||||
Expect(gotIDs[1]).To(Equal(expectedIDs[1]))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Code generated by mockery v2.14.1. DO NOT EDIT.
|
||||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
@@ -29,6 +29,10 @@ func (_m *EventHistoryService) GetEvents(ctx context.Context, in *v0.GetEventsRe
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *v0.GetEventsResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *v0.GetEventsRequest, ...client.CallOption) (*v0.GetEventsResponse, error)); ok {
|
||||
return rf(ctx, in, opts...)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *v0.GetEventsRequest, ...client.CallOption) *v0.GetEventsResponse); ok {
|
||||
r0 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
@@ -37,7 +41,6 @@ func (_m *EventHistoryService) GetEvents(ctx context.Context, in *v0.GetEventsRe
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *v0.GetEventsRequest, ...client.CallOption) error); ok {
|
||||
r1 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
@@ -47,6 +50,39 @@ func (_m *EventHistoryService) GetEvents(ctx context.Context, in *v0.GetEventsRe
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetEventsForUser provides a mock function with given fields: ctx, in, opts
|
||||
func (_m *EventHistoryService) GetEventsForUser(ctx context.Context, in *v0.GetEventsForUserRequest, opts ...client.CallOption) (*v0.GetEventsResponse, error) {
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, in)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *v0.GetEventsResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *v0.GetEventsForUserRequest, ...client.CallOption) (*v0.GetEventsResponse, error)); ok {
|
||||
return rf(ctx, in, opts...)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *v0.GetEventsForUserRequest, ...client.CallOption) *v0.GetEventsResponse); ok {
|
||||
r0 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*v0.GetEventsResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *v0.GetEventsForUserRequest, ...client.CallOption) error); ok {
|
||||
r1 = rf(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewEventHistoryService interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
|
||||
Reference in New Issue
Block a user