File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const (
2828 AuditKeyDeleteApprover = "appeal.deleteApprover"
2929
3030 RevokeReasonForExtension = "Automatically revoked for grant extension"
31+ PermanentDuration = "Permanent"
3132)
3233
3334var TimeNow = time .Now
@@ -785,6 +786,12 @@ func (s *Service) getPoliciesMap(ctx context.Context) (map[string]map[uint]*doma
785786func getApprovalNotifications (appeal * domain.Appeal ) []domain.Notification {
786787 notifications := []domain.Notification {}
787788 approval := appeal .GetNextPendingApproval ()
789+
790+ duration := PermanentDuration
791+ if ! appeal .IsDurationEmpty () {
792+ duration = appeal .Options .Duration
793+ }
794+
788795 if approval != nil {
789796 for _ , approver := range approval .Approvers {
790797 notifications = append (notifications , domain.Notification {
@@ -804,7 +811,7 @@ func getApprovalNotifications(appeal *domain.Appeal) []domain.Notification {
804811 "approval_step" : approval .Name ,
805812 "actor" : approver ,
806813 "details" : appeal .Details ,
807- "duration" : appeal . Options . Duration ,
814+ "duration" : duration ,
808815 },
809816 },
810817 })
Original file line number Diff line number Diff line change @@ -83,11 +83,7 @@ func (a *Appeal) Cancel() {
8383func (a * Appeal ) Approve () error {
8484 a .Status = AppealStatusApproved
8585
86- if a .Options == nil || a .Options .Duration == "" {
87- return nil
88- }
89-
90- duration , err := time .ParseDuration (a .Options .Duration )
86+ duration , err := a .GetDuration ()
9187 if err != nil {
9288 return err
9389 }
@@ -102,6 +98,23 @@ func (a *Appeal) Approve() error {
10298 return nil
10399}
104100
101+ func (a * Appeal ) GetDuration () (time.Duration , error ) {
102+ if a .IsDurationEmpty () {
103+ return 0 * time .Second , nil
104+ }
105+
106+ duration , err := time .ParseDuration (a .Options .Duration )
107+ if err != nil {
108+ return 0 * time .Second , err
109+ }
110+
111+ return duration , nil
112+ }
113+
114+ func (a * Appeal ) IsDurationEmpty () bool {
115+ return a .Options == nil || a .Options .Duration == "" || a .Options .Duration == "0h"
116+ }
117+
105118func (a * Appeal ) Reject () {
106119 a .Status = AppealStatusRejected
107120}
You can’t perform that action at this time.
0 commit comments