Update deploy script #131
|
|
@ -648,21 +648,45 @@ func (h *Handler) HandleDelegationExtendInput(bot *tgbotapi.BotAPI, msg *tgbotap
|
|||
}
|
||||
|
||||
func (h *Handler) getApproverCategories(ctx context.Context, userID uint64) ([]*typescore.ApprovalTopicCategory, error) {
|
||||
categoryIDs := make(map[uint64]bool)
|
||||
|
||||
hierarchies, _, err := h.ipc.Database.UserHierarchy.GetUserHierarchyListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.UserHierarchy{
|
||||
ApproverID: &userID,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err == nil {
|
||||
for _, hier := range hierarchies {
|
||||
if hier.TopicID != nil {
|
||||
topic, _ := h.ipc.Database.ApprovalTopic.GetApprovalTopicByIDDB(ctx, *hier.TopicID)
|
||||
if topic != nil && topic.CategoryID != nil {
|
||||
categoryIDs[*topic.CategoryID] = true
|
||||
}
|
||||
}
|
||||
// Если в UserHierarchy права могут выдаваться сразу на категорию (при наличии такого поля):
|
||||
if hier.TopicCategoryID != nil {
|
||||
categoryIDs[*hier.TopicCategoryID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
categoryIDs := make(map[uint64]bool)
|
||||
for _, hier := range hierarchies {
|
||||
if hier.TopicID != nil {
|
||||
topic, _ := h.ipc.Database.ApprovalTopic.GetApprovalTopicByIDDB(ctx, *hier.TopicID)
|
||||
if topic != nil && topic.CategoryID != nil {
|
||||
categoryIDs[*topic.CategoryID] = true
|
||||
isActive := true
|
||||
delegations, _, err := h.ipc.Database.ApprovalDelegation.GetApprovalDelegationsListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.ApprovalDelegation{
|
||||
DelegateID: &userID,
|
||||
IsActive: &isActive,
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
for _, del := range delegations {
|
||||
if del.TopicID != nil {
|
||||
topic, _ := h.ipc.Database.ApprovalTopic.GetApprovalTopicByIDDB(ctx, *del.TopicID)
|
||||
if topic != nil && topic.CategoryID != nil {
|
||||
categoryIDs[*topic.CategoryID] = true
|
||||
}
|
||||
}
|
||||
if del.CategoryID != nil {
|
||||
categoryIDs[*del.CategoryID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue