Update proxy #132
|
|
@ -11,7 +11,7 @@ const (
|
|||
|
||||
// Константы для нового API-прокси
|
||||
const (
|
||||
ProxyForwardURL = "https://proxyservice.ddns.net/forward"
|
||||
ProxyForwardURL = "https://proxyservice.ddns.net:9443/forward"
|
||||
ProxySecretHeader = "X-Proxy-Secret"
|
||||
ProxySecretKey = "9cb0a2655bde593de45b2f3fd17f39e5"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -308,6 +308,13 @@ func (dr *DailyReminder) getAbsentEmployeesToday(ctx context.Context, mskLocatio
|
|||
today := time.Now().In(mskLocation)
|
||||
todayY, todayM, todayD := today.Date()
|
||||
|
||||
activeCategories, _, errCat := dr.ipc.Database.ApprovalTopicCategory.GetApprovalTopicCategoryListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.ApprovalTopicCategory{IsActive: utilscore.PointerToBool(true)},
|
||||
})
|
||||
if errCat != nil {
|
||||
logrus.Errorf("DailyReminder: getAbsentEmployeesToday: не удалось получить список категорий: %v", errCat)
|
||||
}
|
||||
|
||||
approvals, _, err := dr.ipc.Database.Approval.GetApprovalsListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.Approval{
|
||||
Status: utilscore.PointerToString("approved"),
|
||||
|
|
@ -400,25 +407,57 @@ func (dr *DailyReminder) getAbsentEmployeesToday(ctx context.Context, mskLocatio
|
|||
}
|
||||
|
||||
contact := name
|
||||
if delegations, _, dErr := dr.ipc.Database.ApprovalDelegation.GetApprovalDelegationsListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.ApprovalDelegation{
|
||||
DelegatorID: approval.InitiatorID,
|
||||
IsActive: utilscore.PointerToBool(true),
|
||||
},
|
||||
}); dErr == nil {
|
||||
now := time.Now()
|
||||
for _, d := range delegations {
|
||||
if d.DelegateID == nil {
|
||||
continue
|
||||
|
||||
if len(activeCategories) > 0 {
|
||||
if delegations, _, dErr := dr.ipc.Database.ApprovalDelegation.GetApprovalDelegationsListDB(ctx, typescore.ListDbOptions{
|
||||
Filtering: &typescore.ApprovalDelegation{
|
||||
DelegatorID: approval.InitiatorID,
|
||||
IsActive: utilscore.PointerToBool(true),
|
||||
},
|
||||
}); dErr == nil {
|
||||
now := time.Now()
|
||||
|
||||
activeDelegationsMap := make(map[uint64]uint64)
|
||||
for _, d := range delegations {
|
||||
if d.DelegateID == nil || d.CategoryID == nil {
|
||||
continue
|
||||
}
|
||||
if d.ValidUntil != nil && d.ValidUntil.Before(now) {
|
||||
continue // срок вышел
|
||||
}
|
||||
activeDelegationsMap[*d.CategoryID] = *d.DelegateID
|
||||
}
|
||||
if d.ValidUntil != nil && d.ValidUntil.Before(now) {
|
||||
continue
|
||||
|
||||
var primaryDelegateID uint64
|
||||
allDelegatedToSamePerson := true
|
||||
isFirstCategory := true
|
||||
|
||||
for _, cat := range activeCategories {
|
||||
if cat.ID == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
delegateID, hasDelegation := activeDelegationsMap[*cat.ID]
|
||||
if !hasDelegation {
|
||||
allDelegatedToSamePerson = false
|
||||
break
|
||||
}
|
||||
|
||||
if isFirstCategory {
|
||||
primaryDelegateID = delegateID
|
||||
isFirstCategory = false
|
||||
} else if primaryDelegateID != delegateID {
|
||||
allDelegatedToSamePerson = false
|
||||
break
|
||||
}
|
||||
}
|
||||
delegate, uErr := dr.ipc.Database.User.GetUserByIDDB(ctx, *d.DelegateID)
|
||||
if uErr == nil && delegate != nil && delegate.FullName != nil {
|
||||
contact = *delegate.FullName
|
||||
|
||||
if allDelegatedToSamePerson && primaryDelegateID != 0 {
|
||||
delegateUser, uErr := dr.ipc.Database.User.GetUserByIDDB(ctx, primaryDelegateID)
|
||||
if uErr == nil && delegateUser != nil && delegateUser.FullName != nil {
|
||||
contact = *delegateUser.FullName
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue