Skip to content

Commit

Permalink
feat: add qualification access logic
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Nov 18, 2024
1 parent 746ecbe commit ea3af48
Show file tree
Hide file tree
Showing 31 changed files with 1,072 additions and 377 deletions.
10 changes: 3 additions & 7 deletions app/components/mailer/ThreadCreateOrUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ async function createThread(values: Schema): Promise<void> {
await mailerStore.createThread({
thread: {
id: '0',
recipients: [
{
id: '0',
emailId: '1',
targetId: '2',
},
],
recipients: [],
creatorEmailId: '1',
creatorId: activeChar.value!.userId,
title: values.title,
Expand All @@ -54,6 +48,8 @@ async function createThread(values: Schema): Promise<void> {
creatorId: activeChar.value!.userId,
creatorJob: activeChar.value!.job,
},
recipients: [],
});
isOpen.value = false;
Expand Down
8 changes: 8 additions & 0 deletions gen/go/proto/resources/mailer/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ func (x *UserAccess) SetUserId(id int32) {
func (x *UserAccess) SetAccess(access AccessLevel) {
x.Access = access
}

func (x *QualificationAccess) SetQualificationId(id uint64) {
x.QualificationId = id
}

func (x *QualificationAccess) SetAccess(access AccessLevel) {
x.Access = access
}
105 changes: 53 additions & 52 deletions gen/go/proto/resources/mailer/thread.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions gen/go/proto/resources/mailer/thread.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions gen/go/proto/services/calendar/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Server struct {
notif notifi.INotifi
js *events.JSWrapper

access *access.Grouped[calendar.CalendarJobAccess, *calendar.CalendarJobAccess, calendar.CalendarUserAccess, *calendar.CalendarUserAccess, calendar.AccessLevel]
access *access.Grouped[calendar.CalendarJobAccess, *calendar.CalendarJobAccess, calendar.CalendarUserAccess, *calendar.CalendarUserAccess, access.DummyQualificationAccess[calendar.AccessLevel], *access.DummyQualificationAccess[calendar.AccessLevel], calendar.AccessLevel]
}

type Params struct {
Expand All @@ -71,7 +71,7 @@ func NewServer(p Params) *Server {
appCfg: p.AppConfig,
notif: p.Notif,
js: p.JS,
access: access.NewGrouped(
access: access.NewGrouped[calendar.CalendarJobAccess, *calendar.CalendarJobAccess, calendar.CalendarUserAccess, *calendar.CalendarUserAccess, access.DummyQualificationAccess[calendar.AccessLevel], *access.DummyQualificationAccess[calendar.AccessLevel], calendar.AccessLevel](
p.DB,
table.FivenetDocuments,
&access.TargetTableColumns{
Expand Down Expand Up @@ -126,6 +126,7 @@ func NewServer(p Params) *Server {
UserId: table.FivenetCalendarUserAccess.AS("calendar_user_access").UserID,
},
),
nil,
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion gen/go/proto/services/calendar/calendars.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (s *Server) CreateOrUpdateCalendar(ctx context.Context, req *CreateOrUpdate
auditEntry.State = int16(rector.EventType_EVENT_TYPE_CREATED)
}

if _, err := s.access.HandleAccessChanges(ctx, tx, req.Calendar.Id, req.Calendar.Access.Jobs, req.Calendar.Access.Users); err != nil {
if _, err := s.access.HandleAccessChanges(ctx, tx, req.Calendar.Id, req.Calendar.Access.Jobs, req.Calendar.Access.Users, nil); err != nil {
return nil, errswrap.NewError(err, errorscalendar.ErrFailedQuery)
}

Expand Down
12 changes: 7 additions & 5 deletions gen/go/proto/services/docstore/docstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type Server struct {
notif notifi.INotifi
htmlDiff *htmldiffer.Differ

access *access.Grouped[documents.DocumentJobAccess, *documents.DocumentJobAccess, documents.DocumentUserAccess, *documents.DocumentUserAccess, documents.AccessLevel]
templateAccess *access.Grouped[documents.TemplateJobAccess, *documents.TemplateJobAccess, documents.TemplateUserAccess, *documents.TemplateUserAccess, documents.AccessLevel]
access *access.Grouped[documents.DocumentJobAccess, *documents.DocumentJobAccess, documents.DocumentUserAccess, *documents.DocumentUserAccess, access.DummyQualificationAccess[documents.AccessLevel], *access.DummyQualificationAccess[documents.AccessLevel], documents.AccessLevel]
templateAccess *access.Grouped[documents.TemplateJobAccess, *documents.TemplateJobAccess, documents.TemplateUserAccess, *documents.TemplateUserAccess, access.DummyQualificationAccess[documents.AccessLevel], *access.DummyQualificationAccess[documents.AccessLevel], documents.AccessLevel]
}

type Params struct {
Expand All @@ -91,7 +91,7 @@ func NewServer(p Params) *Server {
notif: p.Notif,
htmlDiff: p.HTMLDiffer,

access: access.NewGrouped(
access: access.NewGrouped[documents.DocumentJobAccess, *documents.DocumentJobAccess, documents.DocumentUserAccess, *documents.DocumentUserAccess, access.DummyQualificationAccess[documents.AccessLevel], *access.DummyQualificationAccess[documents.AccessLevel], documents.AccessLevel](
p.DB,
table.FivenetDocuments,
&access.TargetTableColumns{
Expand Down Expand Up @@ -146,9 +146,10 @@ func NewServer(p Params) *Server {
UserId: table.FivenetDocumentsUserAccess.AS("document_user_access").UserID,
},
),
nil,
),

templateAccess: access.NewGrouped[documents.TemplateJobAccess, *documents.TemplateJobAccess, documents.TemplateUserAccess, *documents.TemplateUserAccess, documents.AccessLevel](
templateAccess: access.NewGrouped[documents.TemplateJobAccess, *documents.TemplateJobAccess, documents.TemplateUserAccess, *documents.TemplateUserAccess, access.DummyQualificationAccess[documents.AccessLevel], *access.DummyQualificationAccess[documents.AccessLevel], documents.AccessLevel](
p.DB,
table.FivenetDocumentsTemplates,
&access.TargetTableColumns{
Expand Down Expand Up @@ -182,6 +183,7 @@ func NewServer(p Params) *Server {
},
),
nil,
nil,
),
}
}
Expand Down Expand Up @@ -496,7 +498,7 @@ func (s *Server) CreateDocument(ctx context.Context, req *CreateDocumentRequest)
return nil, errswrap.NewError(err, errorsdocstore.ErrFailedQuery)
}

if _, err := s.access.HandleAccessChanges(ctx, tx, uint64(lastId), req.Access.Jobs, req.Access.Users); err != nil {
if _, err := s.access.HandleAccessChanges(ctx, tx, uint64(lastId), req.Access.Jobs, req.Access.Users, nil); err != nil {
if dbutils.IsDuplicateError(err) {
return nil, errswrap.NewError(err, errorsdocstore.ErrDocAccessDuplicate)
}
Expand Down
2 changes: 1 addition & 1 deletion gen/go/proto/services/docstore/documents_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *Server) getDocumentAccess(ctx context.Context, documentId uint64) (*doc
}

func (s *Server) handleDocumentAccessChange(ctx context.Context, tx qrm.DB, documentId uint64, userInfo *userinfo.UserInfo, access *documents.DocumentAccess, addActivity bool) error {
changes, err := s.access.HandleAccessChanges(ctx, tx, documentId, access.Jobs, access.Users)
changes, err := s.access.HandleAccessChanges(ctx, tx, documentId, access.Jobs, access.Users, nil)
if err != nil {
if dbutils.IsDuplicateError(err) {
return errswrap.NewError(err, errorsdocstore.ErrDocAccessDuplicate)
Expand Down
4 changes: 2 additions & 2 deletions gen/go/proto/services/docstore/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (s *Server) CreateTemplate(ctx context.Context, req *CreateTemplateRequest)
return nil, errswrap.NewError(err, errorsdocstore.ErrFailedQuery)
}

if _, err := s.templateAccess.HandleAccessChanges(ctx, tx, uint64(lastId), req.Template.JobAccess, nil); err != nil {
if _, err := s.templateAccess.HandleAccessChanges(ctx, tx, uint64(lastId), req.Template.JobAccess, nil, nil); err != nil {
if dbutils.IsDuplicateError(err) {
return nil, errswrap.NewError(err, errorsdocstore.ErrTemplateAccessDuplicate)
}
Expand Down Expand Up @@ -382,7 +382,7 @@ func (s *Server) UpdateTemplate(ctx context.Context, req *UpdateTemplateRequest)
return nil, errswrap.NewError(err, errorsdocstore.ErrFailedQuery)
}

if _, err := s.templateAccess.HandleAccessChanges(ctx, tx, req.Template.Id, req.Template.JobAccess, nil); err != nil {
if _, err := s.templateAccess.HandleAccessChanges(ctx, tx, req.Template.Id, req.Template.JobAccess, nil, nil); err != nil {
if dbutils.IsDuplicateError(err) {
return nil, errswrap.NewError(err, errorsdocstore.ErrTemplateAccessDuplicate)
}
Expand Down
Loading

0 comments on commit ea3af48

Please sign in to comment.