From b41f95e04204a0ed5a15686304a9531453683977 Mon Sep 17 00:00:00 2001 From: Alexander Trost Date: Sat, 30 Nov 2024 17:08:15 +0100 Subject: [PATCH] feat: send update event on role perm updates on job + grade subject Signed-off-by: Alexander Trost --- app/store/auth.ts | 4 +- app/store/internet.ts | 4 +- app/store/notificator.ts | 4 + .../resources/notifications/events.pb.go | 93 +++++++++++-- .../notifications/events.pb.validate.go | 117 ++++++++++++++++ .../services/notificator/notificator.pb.go | 130 ++++++++++-------- .../notificator/notificator.pb.validate.go | 41 ++++++ gen/go/proto/services/notificator/stream.go | 32 ++++- gen/go/proto/services/rector/perms.go | 14 ++ gen/grpc-api.md | 17 +++ gen/ts/resources/notifications/events.ts | 69 ++++++++++ gen/ts/services/notificator/notificator.ts | 17 +++ pkg/notifi/events.go | 2 + proto/resources/notifications/events.proto | 8 ++ proto/services/notificator/notificator.proto | 1 + 15 files changed, 485 insertions(+), 68 deletions(-) diff --git a/app/store/auth.ts b/app/store/auth.ts index dc463c1c6..118cfd62e 100644 --- a/app/store/auth.ts +++ b/app/store/auth.ts @@ -181,7 +181,9 @@ export const useAuthStore = defineStore('auth', { } try { - const call = getGRPCAuthClient().chooseCharacter({ charId: charId }); + const call = getGRPCAuthClient().chooseCharacter({ + charId: charId, + }); const { response } = await call; if (!response.char) { throw new Error('Server Error! No character in choose character response.'); diff --git a/app/store/internet.ts b/app/store/internet.ts index d8b04d1b6..9c823b622 100644 --- a/app/store/internet.ts +++ b/app/store/internet.ts @@ -20,7 +20,7 @@ export interface InternetState { export const useInternetStore = defineStore('internet', { state: () => ({ - selectedTab: 0, + selectedTab: undefined, tabs: [], history: [], }) as InternetState, @@ -42,7 +42,7 @@ export const useInternetStore = defineStore('internet', { } }, async addTab(tab: Partial): Promise { - const id = this.tabs.length; + const id = this.tabs.length === 0 ? 1 : this.tabs.length; this.tabs.push({ id: id, label: tab.label ?? '', diff --git a/app/store/notificator.ts b/app/store/notificator.ts index 84f6da5e6..c729c49f4 100644 --- a/app/store/notificator.ts +++ b/app/store/notificator.ts @@ -148,6 +148,10 @@ export const useNotificatorStore = defineStore('notifications', { } else { logger.warn('Unknown job event data received - Kind: ', resp.data.oneofKind, resp.data); } + } else if (resp.data.oneofKind === 'jobGradeEvent') { + if (resp.data.jobGradeEvent.data.oneofKind === 'refreshToken') { + await authStore.chooseCharacter(undefined); + } } else if (resp.data.oneofKind === 'systemEvent') { logger.warn('No systemEvent handlers available.', resp.data); } else if (resp.data.oneofKind === 'mailerEvent') { diff --git a/gen/go/proto/resources/notifications/events.pb.go b/gen/go/proto/resources/notifications/events.pb.go index 6128e4b62..ffa38c6a4 100644 --- a/gen/go/proto/resources/notifications/events.pb.go +++ b/gen/go/proto/resources/notifications/events.pb.go @@ -166,6 +166,71 @@ type JobEvent_JobProps struct { func (*JobEvent_JobProps) isJobEvent_Data() {} +type JobGradeEvent struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Data: + // + // *JobGradeEvent_RefreshToken + Data isJobGradeEvent_Data `protobuf_oneof:"data"` +} + +func (x *JobGradeEvent) Reset() { + *x = JobGradeEvent{} + mi := &file_resources_notifications_events_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *JobGradeEvent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*JobGradeEvent) ProtoMessage() {} + +func (x *JobGradeEvent) ProtoReflect() protoreflect.Message { + mi := &file_resources_notifications_events_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use JobGradeEvent.ProtoReflect.Descriptor instead. +func (*JobGradeEvent) Descriptor() ([]byte, []int) { + return file_resources_notifications_events_proto_rawDescGZIP(), []int{2} +} + +func (m *JobGradeEvent) GetData() isJobGradeEvent_Data { + if m != nil { + return m.Data + } + return nil +} + +func (x *JobGradeEvent) GetRefreshToken() bool { + if x, ok := x.GetData().(*JobGradeEvent_RefreshToken); ok { + return x.RefreshToken + } + return false +} + +type isJobGradeEvent_Data interface { + isJobGradeEvent_Data() +} + +type JobGradeEvent_RefreshToken struct { + RefreshToken bool `protobuf:"varint,1,opt,name=refresh_token,json=refreshToken,proto3,oneof"` +} + +func (*JobGradeEvent_RefreshToken) isJobGradeEvent_Data() {} + type SystemEvent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -174,7 +239,7 @@ type SystemEvent struct { func (x *SystemEvent) Reset() { *x = SystemEvent{} - mi := &file_resources_notifications_events_proto_msgTypes[2] + mi := &file_resources_notifications_events_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -186,7 +251,7 @@ func (x *SystemEvent) String() string { func (*SystemEvent) ProtoMessage() {} func (x *SystemEvent) ProtoReflect() protoreflect.Message { - mi := &file_resources_notifications_events_proto_msgTypes[2] + mi := &file_resources_notifications_events_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -199,7 +264,7 @@ func (x *SystemEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemEvent.ProtoReflect.Descriptor instead. func (*SystemEvent) Descriptor() ([]byte, []int) { - return file_resources_notifications_events_proto_rawDescGZIP(), []int{2} + return file_resources_notifications_events_proto_rawDescGZIP(), []int{3} } var File_resources_notifications_events_proto protoreflect.FileDescriptor @@ -227,6 +292,10 @@ var file_resources_notifications_events_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2e, 0x4a, 0x6f, 0x62, 0x50, 0x72, 0x6f, 0x70, 0x73, 0x48, 0x00, 0x52, 0x08, 0x6a, 0x6f, 0x62, 0x50, 0x72, 0x6f, 0x70, 0x73, 0x42, 0x06, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3e, 0x0a, 0x0d, 0x4a, 0x6f, 0x62, 0x47, 0x72, 0x61, 0x64, + 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, + 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, + 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x0d, 0x0a, 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x53, 0x5a, 0x51, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x66, @@ -249,17 +318,18 @@ func file_resources_notifications_events_proto_rawDescGZIP() []byte { return file_resources_notifications_events_proto_rawDescData } -var file_resources_notifications_events_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_resources_notifications_events_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_resources_notifications_events_proto_goTypes = []any{ (*UserEvent)(nil), // 0: resources.notifications.UserEvent (*JobEvent)(nil), // 1: resources.notifications.JobEvent - (*SystemEvent)(nil), // 2: resources.notifications.SystemEvent - (*Notification)(nil), // 3: resources.notifications.Notification - (*users.JobProps)(nil), // 4: resources.users.JobProps + (*JobGradeEvent)(nil), // 2: resources.notifications.JobGradeEvent + (*SystemEvent)(nil), // 3: resources.notifications.SystemEvent + (*Notification)(nil), // 4: resources.notifications.Notification + (*users.JobProps)(nil), // 5: resources.users.JobProps } var file_resources_notifications_events_proto_depIdxs = []int32{ - 3, // 0: resources.notifications.UserEvent.notification:type_name -> resources.notifications.Notification - 4, // 1: resources.notifications.JobEvent.job_props:type_name -> resources.users.JobProps + 4, // 0: resources.notifications.UserEvent.notification:type_name -> resources.notifications.Notification + 5, // 1: resources.notifications.JobEvent.job_props:type_name -> resources.users.JobProps 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -280,13 +350,16 @@ func file_resources_notifications_events_proto_init() { file_resources_notifications_events_proto_msgTypes[1].OneofWrappers = []any{ (*JobEvent_JobProps)(nil), } + file_resources_notifications_events_proto_msgTypes[2].OneofWrappers = []any{ + (*JobGradeEvent_RefreshToken)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_resources_notifications_events_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/gen/go/proto/resources/notifications/events.pb.validate.go b/gen/go/proto/resources/notifications/events.pb.validate.go index 085a99674..4636a6649 100644 --- a/gen/go/proto/resources/notifications/events.pb.validate.go +++ b/gen/go/proto/resources/notifications/events.pb.validate.go @@ -337,6 +337,123 @@ var _ interface { ErrorName() string } = JobEventValidationError{} +// Validate checks the field values on JobGradeEvent with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *JobGradeEvent) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on JobGradeEvent with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in JobGradeEventMultiError, or +// nil if none found. +func (m *JobGradeEvent) ValidateAll() error { + return m.validate(true) +} + +func (m *JobGradeEvent) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.Data.(type) { + case *JobGradeEvent_RefreshToken: + if v == nil { + err := JobGradeEventValidationError{ + field: "Data", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for RefreshToken + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return JobGradeEventMultiError(errors) + } + + return nil +} + +// JobGradeEventMultiError is an error wrapping multiple validation errors +// returned by JobGradeEvent.ValidateAll() if the designated constraints +// aren't met. +type JobGradeEventMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m JobGradeEventMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m JobGradeEventMultiError) AllErrors() []error { return m } + +// JobGradeEventValidationError is the validation error returned by +// JobGradeEvent.Validate if the designated constraints aren't met. +type JobGradeEventValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e JobGradeEventValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e JobGradeEventValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e JobGradeEventValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e JobGradeEventValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e JobGradeEventValidationError) ErrorName() string { return "JobGradeEventValidationError" } + +// Error satisfies the builtin error interface +func (e JobGradeEventValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sJobGradeEvent.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = JobGradeEventValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = JobGradeEventValidationError{} + // Validate checks the field values on SystemEvent with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/gen/go/proto/services/notificator/notificator.pb.go b/gen/go/proto/services/notificator/notificator.pb.go index 7c0b92877..8fcd774b9 100644 --- a/gen/go/proto/services/notificator/notificator.pb.go +++ b/gen/go/proto/services/notificator/notificator.pb.go @@ -283,6 +283,7 @@ type StreamResponse struct { // // *StreamResponse_UserEvent // *StreamResponse_JobEvent + // *StreamResponse_JobGradeEvent // *StreamResponse_SystemEvent // *StreamResponse_MailerEvent Data isStreamResponse_Data `protobuf_oneof:"data"` @@ -353,6 +354,13 @@ func (x *StreamResponse) GetJobEvent() *notifications.JobEvent { return nil } +func (x *StreamResponse) GetJobGradeEvent() *notifications.JobGradeEvent { + if x, ok := x.GetData().(*StreamResponse_JobGradeEvent); ok { + return x.JobGradeEvent + } + return nil +} + func (x *StreamResponse) GetSystemEvent() *notifications.SystemEvent { if x, ok := x.GetData().(*StreamResponse_SystemEvent); ok { return x.SystemEvent @@ -379,6 +387,10 @@ type StreamResponse_JobEvent struct { JobEvent *notifications.JobEvent `protobuf:"bytes,4,opt,name=job_event,json=jobEvent,proto3,oneof"` } +type StreamResponse_JobGradeEvent struct { + JobGradeEvent *notifications.JobGradeEvent `protobuf:"bytes,7,opt,name=job_grade_event,json=jobGradeEvent,proto3,oneof"` +} + type StreamResponse_SystemEvent struct { SystemEvent *notifications.SystemEvent `protobuf:"bytes,5,opt,name=system_event,json=systemEvent,proto3,oneof"` } @@ -391,6 +403,8 @@ func (*StreamResponse_UserEvent) isStreamResponse_Data() {} func (*StreamResponse_JobEvent) isStreamResponse_Data() {} +func (*StreamResponse_JobGradeEvent) isStreamResponse_Data() {} + func (*StreamResponse_SystemEvent) isStreamResponse_Data() {} func (*StreamResponse_MailerEvent) isStreamResponse_Data() {} @@ -452,7 +466,7 @@ var file_services_notificator_notificator_proto_rawDesc = []byte{ 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x02, 0x30, 0x01, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x22, 0x88, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, + 0x73, 0x74, 0x22, 0xda, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, @@ -466,44 +480,49 @@ var file_services_notificator_notificator_proto_rawDesc = []byte{ 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x6f, 0x62, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, - 0x52, 0x08, 0x6a, 0x6f, 0x62, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x49, 0x0a, 0x0c, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x24, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x6d, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x5f, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x6d, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x2e, 0x4d, - 0x61, 0x69, 0x6c, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x6d, 0x61, - 0x69, 0x6c, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x32, 0xd4, 0x02, - 0x0a, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, - 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x47, - 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x11, 0x4d, 0x61, 0x72, 0x6b, 0x4e, - 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x6f, 0x72, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x6f, 0x72, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, - 0x06, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x30, 0x01, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x66, - 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6e, 0x6f, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x3b, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x08, 0x6a, 0x6f, 0x62, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x50, 0x0a, 0x0f, 0x6a, 0x6f, + 0x62, 0x5f, 0x67, 0x72, 0x61, 0x64, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, + 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x6f, + 0x62, 0x47, 0x72, 0x61, 0x64, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x6a, + 0x6f, 0x62, 0x47, 0x72, 0x61, 0x64, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x49, 0x0a, 0x0c, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x6e, + 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x6d, 0x61, 0x69, 0x6c, 0x65, + 0x72, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x6d, 0x61, 0x69, 0x6c, 0x65, 0x72, + 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, + 0x6d, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x32, + 0xd4, 0x02, 0x0a, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2d, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, + 0x72, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, + 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x11, 0x4d, 0x61, 0x72, + 0x6b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x55, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, + 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, + 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6e, + 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x3b, 0x6e, 0x6f, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -532,8 +551,9 @@ var file_services_notificator_notificator_proto_goTypes = []any{ (*notifications.Notification)(nil), // 9: resources.notifications.Notification (*notifications.UserEvent)(nil), // 10: resources.notifications.UserEvent (*notifications.JobEvent)(nil), // 11: resources.notifications.JobEvent - (*notifications.SystemEvent)(nil), // 12: resources.notifications.SystemEvent - (*mailer.MailerEvent)(nil), // 13: resources.mailer.MailerEvent + (*notifications.JobGradeEvent)(nil), // 12: resources.notifications.JobGradeEvent + (*notifications.SystemEvent)(nil), // 13: resources.notifications.SystemEvent + (*mailer.MailerEvent)(nil), // 14: resources.mailer.MailerEvent } var file_services_notificator_notificator_proto_depIdxs = []int32{ 6, // 0: services.notificator.GetNotificationsRequest.pagination:type_name -> resources.common.database.PaginationRequest @@ -542,19 +562,20 @@ var file_services_notificator_notificator_proto_depIdxs = []int32{ 9, // 3: services.notificator.GetNotificationsResponse.notifications:type_name -> resources.notifications.Notification 10, // 4: services.notificator.StreamResponse.user_event:type_name -> resources.notifications.UserEvent 11, // 5: services.notificator.StreamResponse.job_event:type_name -> resources.notifications.JobEvent - 12, // 6: services.notificator.StreamResponse.system_event:type_name -> resources.notifications.SystemEvent - 13, // 7: services.notificator.StreamResponse.mailer_event:type_name -> resources.mailer.MailerEvent - 0, // 8: services.notificator.NotificatorService.GetNotifications:input_type -> services.notificator.GetNotificationsRequest - 2, // 9: services.notificator.NotificatorService.MarkNotifications:input_type -> services.notificator.MarkNotificationsRequest - 4, // 10: services.notificator.NotificatorService.Stream:input_type -> services.notificator.StreamRequest - 1, // 11: services.notificator.NotificatorService.GetNotifications:output_type -> services.notificator.GetNotificationsResponse - 3, // 12: services.notificator.NotificatorService.MarkNotifications:output_type -> services.notificator.MarkNotificationsResponse - 5, // 13: services.notificator.NotificatorService.Stream:output_type -> services.notificator.StreamResponse - 11, // [11:14] is the sub-list for method output_type - 8, // [8:11] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 12, // 6: services.notificator.StreamResponse.job_grade_event:type_name -> resources.notifications.JobGradeEvent + 13, // 7: services.notificator.StreamResponse.system_event:type_name -> resources.notifications.SystemEvent + 14, // 8: services.notificator.StreamResponse.mailer_event:type_name -> resources.mailer.MailerEvent + 0, // 9: services.notificator.NotificatorService.GetNotifications:input_type -> services.notificator.GetNotificationsRequest + 2, // 10: services.notificator.NotificatorService.MarkNotifications:input_type -> services.notificator.MarkNotificationsRequest + 4, // 11: services.notificator.NotificatorService.Stream:input_type -> services.notificator.StreamRequest + 1, // 12: services.notificator.NotificatorService.GetNotifications:output_type -> services.notificator.GetNotificationsResponse + 3, // 13: services.notificator.NotificatorService.MarkNotifications:output_type -> services.notificator.MarkNotificationsResponse + 5, // 14: services.notificator.NotificatorService.Stream:output_type -> services.notificator.StreamResponse + 12, // [12:15] is the sub-list for method output_type + 9, // [9:12] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_services_notificator_notificator_proto_init() } @@ -567,6 +588,7 @@ func file_services_notificator_notificator_proto_init() { file_services_notificator_notificator_proto_msgTypes[5].OneofWrappers = []any{ (*StreamResponse_UserEvent)(nil), (*StreamResponse_JobEvent)(nil), + (*StreamResponse_JobGradeEvent)(nil), (*StreamResponse_SystemEvent)(nil), (*StreamResponse_MailerEvent)(nil), } diff --git a/gen/go/proto/services/notificator/notificator.pb.validate.go b/gen/go/proto/services/notificator/notificator.pb.validate.go index 312a00fed..9ce6b2b01 100644 --- a/gen/go/proto/services/notificator/notificator.pb.validate.go +++ b/gen/go/proto/services/notificator/notificator.pb.validate.go @@ -809,6 +809,47 @@ func (m *StreamResponse) validate(all bool) error { } } + case *StreamResponse_JobGradeEvent: + if v == nil { + err := StreamResponseValidationError{ + field: "Data", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetJobGradeEvent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StreamResponseValidationError{ + field: "JobGradeEvent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StreamResponseValidationError{ + field: "JobGradeEvent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetJobGradeEvent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StreamResponseValidationError{ + field: "JobGradeEvent", + reason: "embedded message failed validation", + cause: err, + } + } + } + case *StreamResponse_SystemEvent: if v == nil { err := StreamResponseValidationError{ diff --git a/gen/go/proto/services/notificator/stream.go b/gen/go/proto/services/notificator/stream.go index be2cc450f..b3adfac25 100644 --- a/gen/go/proto/services/notificator/stream.go +++ b/gen/go/proto/services/notificator/stream.go @@ -3,6 +3,7 @@ package notificator import ( "context" "fmt" + "strconv" "time" "github.com/fivenet-app/fivenet/gen/go/proto/resources/mailer" @@ -29,6 +30,7 @@ func (s *Server) Stream(req *StreamRequest, srv NotificatorService_StreamServer) subjects := []string{ fmt.Sprintf("%s.%s.%d", notifi.BaseSubject, notifi.UserTopic, currentUserInfo.UserId), fmt.Sprintf("%s.%s.%s", notifi.BaseSubject, notifi.JobTopic, currentUserInfo.Job), + fmt.Sprintf("%s.%s.%s.>", notifi.BaseSubject, notifi.JobGradeTopic, currentUserInfo.Job), fmt.Sprintf("%s.%s", notifi.BaseSubject, notifi.SystemTopic), } @@ -137,7 +139,7 @@ func (s *Server) Stream(req *StreamRequest, srv NotificatorService_StreamServer) s.logger.Error("failed to ack notification message", zap.Error(err)) } - _, topic, _ := notifi.SplitSubject(msg.Subject()) + _, topic, parts := notifi.SplitSubject(msg.Subject()) switch topic { case notifi.UserTopic: var dest notifications.UserEvent @@ -178,6 +180,34 @@ func (s *Server) Stream(req *StreamRequest, srv NotificatorService_StreamServer) return errswrap.NewError(err, ErrFailedStream) } + case notifi.JobGradeTopic: + // Make sure the job grade is included + if len(parts) < 2 { + continue + } + grade, err := strconv.Atoi(parts[1]) + if err != nil { + continue + } + if currentUserInfo.JobGrade < int32(grade) { + continue + } + var dest notifications.JobGradeEvent + if err := protojson.Unmarshal(msg.Data(), &dest); err != nil { + return errswrap.NewError(err, ErrFailedStream) + } + + resp := &StreamResponse{ + NotificationCount: notsCount, + Data: &StreamResponse_JobGradeEvent{ + JobGradeEvent: &dest, + }, + } + + if err := srv.Send(resp); err != nil { + return errswrap.NewError(err, ErrFailedStream) + } + case notifi.SystemTopic: // No events yet... diff --git a/gen/go/proto/services/rector/perms.go b/gen/go/proto/services/rector/perms.go index 286151e90..be781dbed 100644 --- a/gen/go/proto/services/rector/perms.go +++ b/gen/go/proto/services/rector/perms.go @@ -3,7 +3,9 @@ package rector import ( "context" "errors" + "fmt" + "github.com/fivenet-app/fivenet/gen/go/proto/resources/notifications" "github.com/fivenet-app/fivenet/gen/go/proto/resources/permissions" rector "github.com/fivenet-app/fivenet/gen/go/proto/resources/rector" "github.com/fivenet-app/fivenet/gen/go/proto/resources/timestamp" @@ -11,6 +13,7 @@ import ( "github.com/fivenet-app/fivenet/pkg/grpc/auth" "github.com/fivenet-app/fivenet/pkg/grpc/auth/userinfo" "github.com/fivenet-app/fivenet/pkg/grpc/errswrap" + "github.com/fivenet-app/fivenet/pkg/notifi" "github.com/fivenet-app/fivenet/pkg/perms" "github.com/fivenet-app/fivenet/pkg/perms/collections" "github.com/fivenet-app/fivenet/query/fivenet/model" @@ -339,6 +342,17 @@ func (s *Server) UpdateRolePerms(ctx context.Context, req *UpdateRolePermsReques } } + // Send event to every employee + if _, err := s.js.PublishAsyncProto(ctx, + fmt.Sprintf("%s.%s.%s.%d", notifi.BaseSubject, notifi.JobGradeTopic, role.Job, role.Grade), + ¬ifications.JobGradeEvent{ + Data: ¬ifications.JobGradeEvent_RefreshToken{ + RefreshToken: true, + }, + }); err != nil { + return nil, errswrap.NewError(err, errorsrector.ErrFailedQuery) + } + auditEntry.State = int16(rector.EventType_EVENT_TYPE_UPDATED) return &UpdateRolePermsResponse{}, nil diff --git a/gen/grpc-api.md b/gen/grpc-api.md index a46c54c24..7418b615a 100644 --- a/gen/grpc-api.md +++ b/gen/grpc-api.md @@ -198,6 +198,7 @@ - [resources/notifications/events.proto](#resources_notifications_events-proto) - [JobEvent](#resources-notifications-JobEvent) + - [JobGradeEvent](#resources-notifications-JobGradeEvent) - [SystemEvent](#resources-notifications-SystemEvent) - [UserEvent](#resources-notifications-UserEvent) @@ -3568,6 +3569,21 @@ Dummy - DO NOT USE! + + +### JobGradeEvent + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| refresh_token | [bool](#bool) | | | + + + + + + ### SystemEvent @@ -9778,6 +9794,7 @@ TODO add way to link to, e.g., internal "objects" (citizens, documents, calendar | restart | [bool](#bool) | optional | | | user_event | [resources.notifications.UserEvent](#resources-notifications-UserEvent) | | | | job_event | [resources.notifications.JobEvent](#resources-notifications-JobEvent) | | | +| job_grade_event | [resources.notifications.JobGradeEvent](#resources-notifications-JobGradeEvent) | | | | system_event | [resources.notifications.SystemEvent](#resources-notifications-SystemEvent) | | | | mailer_event | [resources.mailer.MailerEvent](#resources-mailer-MailerEvent) | | | diff --git a/gen/ts/resources/notifications/events.ts b/gen/ts/resources/notifications/events.ts index 00a9b212e..5df42b5cf 100644 --- a/gen/ts/resources/notifications/events.ts +++ b/gen/ts/resources/notifications/events.ts @@ -58,6 +58,25 @@ export interface JobEvent { oneofKind: undefined; }; } +// Job Grade Events + +/** + * @generated from protobuf message resources.notifications.JobGradeEvent + */ +export interface JobGradeEvent { + /** + * @generated from protobuf oneof: data + */ + data: { + oneofKind: "refreshToken"; + /** + * @generated from protobuf field: bool refresh_token = 1; + */ + refreshToken: boolean; + } | { + oneofKind: undefined; + }; +} // System Events /** @@ -176,6 +195,56 @@ class JobEvent$Type extends MessageType { */ export const JobEvent = new JobEvent$Type(); // @generated message type with reflection information, may provide speed optimized methods +class JobGradeEvent$Type extends MessageType { + constructor() { + super("resources.notifications.JobGradeEvent", [ + { no: 1, name: "refresh_token", kind: "scalar", oneof: "data", T: 8 /*ScalarType.BOOL*/ } + ]); + } + create(value?: PartialMessage): JobGradeEvent { + const message = globalThis.Object.create((this.messagePrototype!)); + message.data = { oneofKind: undefined }; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: JobGradeEvent): JobGradeEvent { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* bool refresh_token */ 1: + message.data = { + oneofKind: "refreshToken", + refreshToken: reader.bool() + }; + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: JobGradeEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* bool refresh_token = 1; */ + if (message.data.oneofKind === "refreshToken") + writer.tag(1, WireType.Varint).bool(message.data.refreshToken); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message resources.notifications.JobGradeEvent + */ +export const JobGradeEvent = new JobGradeEvent$Type(); +// @generated message type with reflection information, may provide speed optimized methods class SystemEvent$Type extends MessageType { constructor() { super("resources.notifications.SystemEvent", []); diff --git a/gen/ts/services/notificator/notificator.ts b/gen/ts/services/notificator/notificator.ts index d3c897d4c..96d547173 100644 --- a/gen/ts/services/notificator/notificator.ts +++ b/gen/ts/services/notificator/notificator.ts @@ -13,6 +13,7 @@ import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; import { MailerEvent } from "../../resources/mailer/events"; import { SystemEvent } from "../../resources/notifications/events"; +import { JobGradeEvent } from "../../resources/notifications/events"; import { JobEvent } from "../../resources/notifications/events"; import { UserEvent } from "../../resources/notifications/events"; import { Notification } from "../../resources/notifications/notifications"; @@ -103,6 +104,12 @@ export interface StreamResponse { * @generated from protobuf field: resources.notifications.JobEvent job_event = 4; */ jobEvent: JobEvent; + } | { + oneofKind: "jobGradeEvent"; + /** + * @generated from protobuf field: resources.notifications.JobGradeEvent job_grade_event = 7; + */ + jobGradeEvent: JobGradeEvent; } | { oneofKind: "systemEvent"; /** @@ -384,6 +391,7 @@ class StreamResponse$Type extends MessageType { { no: 2, name: "restart", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ }, { no: 3, name: "user_event", kind: "message", oneof: "data", T: () => UserEvent }, { no: 4, name: "job_event", kind: "message", oneof: "data", T: () => JobEvent }, + { no: 7, name: "job_grade_event", kind: "message", oneof: "data", T: () => JobGradeEvent }, { no: 5, name: "system_event", kind: "message", oneof: "data", T: () => SystemEvent }, { no: 6, name: "mailer_event", kind: "message", oneof: "data", T: () => MailerEvent } ]); @@ -419,6 +427,12 @@ class StreamResponse$Type extends MessageType { jobEvent: JobEvent.internalBinaryRead(reader, reader.uint32(), options, (message.data as any).jobEvent) }; break; + case /* resources.notifications.JobGradeEvent job_grade_event */ 7: + message.data = { + oneofKind: "jobGradeEvent", + jobGradeEvent: JobGradeEvent.internalBinaryRead(reader, reader.uint32(), options, (message.data as any).jobGradeEvent) + }; + break; case /* resources.notifications.SystemEvent system_event */ 5: message.data = { oneofKind: "systemEvent", @@ -455,6 +469,9 @@ class StreamResponse$Type extends MessageType { /* resources.notifications.JobEvent job_event = 4; */ if (message.data.oneofKind === "jobEvent") JobEvent.internalBinaryWrite(message.data.jobEvent, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* resources.notifications.JobGradeEvent job_grade_event = 7; */ + if (message.data.oneofKind === "jobGradeEvent") + JobGradeEvent.internalBinaryWrite(message.data.jobGradeEvent, writer.tag(7, WireType.LengthDelimited).fork(), options).join(); /* resources.notifications.SystemEvent system_event = 5; */ if (message.data.oneofKind === "systemEvent") SystemEvent.internalBinaryWrite(message.data.systemEvent, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); diff --git a/pkg/notifi/events.go b/pkg/notifi/events.go index bb003229e..f39880d6f 100644 --- a/pkg/notifi/events.go +++ b/pkg/notifi/events.go @@ -19,6 +19,8 @@ const ( UserTopic events.Topic = "user" // Job event topic JobTopic events.Topic = "job" + // Job Grade event topic + JobGradeTopic events.Topic = "job_grade" // System event topic SystemTopic events.Topic = "sys" // Mailer event topic diff --git a/proto/resources/notifications/events.proto b/proto/resources/notifications/events.proto index 90f3f4b5c..b8c9aa6f9 100644 --- a/proto/resources/notifications/events.proto +++ b/proto/resources/notifications/events.proto @@ -25,6 +25,14 @@ message JobEvent { } } +// Job Grade Events + +message JobGradeEvent { + oneof data { + bool refresh_token = 1; + } +} + // System Events message SystemEvent {} diff --git a/proto/services/notificator/notificator.proto b/proto/services/notificator/notificator.proto index ccea9c03c..e82ddb5eb 100644 --- a/proto/services/notificator/notificator.proto +++ b/proto/services/notificator/notificator.proto @@ -50,6 +50,7 @@ message StreamResponse { oneof data { resources.notifications.UserEvent user_event = 3; resources.notifications.JobEvent job_event = 4; + resources.notifications.JobGradeEvent job_grade_event = 7; resources.notifications.SystemEvent system_event = 5; resources.mailer.MailerEvent mailer_event = 6; }