diff --git a/internal/v1/user/visitor.go b/internal/v1/user/visitor.go index f1d3d6e..52bd163 100644 --- a/internal/v1/user/visitor.go +++ b/internal/v1/user/visitor.go @@ -316,6 +316,21 @@ func isEligibleVisiting(user *models.User) bool { return false } + // Ignore rating change date if current rating is C3, I1, I3 + if user.RatingID != 7 && user.RatingID != 8 && user.RatingID != 10 { + ratechange, err := vatsim.GetDateOfRatingChange(fmt.Sprint(user.CID)) + if err != nil { + log.Errorf("Error getting date of rating change: %s", err) + return false + } + // Check that ratechange is more than 90 days ago + // VATSIM API apparently returns nil if it was a long time ago... so we can assume this check is true + // VATUSA only knows about controllers whose rating is changed by VATUSA, so we enforce this by also checking VATSIM + if ratechange != nil && ratechange.After(time.Now().AddDate(0, 0, -90)) { + return false + } + } + // Check VATUSA eligibility eligible, _, err := vatusa.IsVisitorEligible(fmt.Sprint(user.CID)) if err != nil {