diff --git a/pkg/api/types/approver.go b/pkg/api/types/approver.go index 9c00a8a..dfbd123 100644 --- a/pkg/api/types/approver.go +++ b/pkg/api/types/approver.go @@ -4,6 +4,7 @@ package types import ( "sync" + "time" "git.giftfish.de/ston1th/keyctl/pkg/key" "golang.org/x/exp/maps" @@ -77,6 +78,7 @@ func (a *Approver) Update(aid string, s Status) (err error) { if app, ok := a.m[aid]; ok { app.Status = s a.m[aid] = app + go a.cleanup(aid) } else { err = ErrReqNotFound } @@ -84,6 +86,13 @@ func (a *Approver) Update(aid string, s Status) (err error) { return } +func (a *Approver) cleanup(aid string) { + time.Sleep(time.Second * 10) + a.mu.Lock() + delete(a.m, aid) + a.mu.Unlock() +} + type Approval struct { ID string Name string