tweak on receipt check

This commit is contained in:
Andre Medeiros 2022-05-23 19:05:31 -04:00
parent 079cc9a5c5
commit bbb3001544

View file

@ -36,11 +36,7 @@ func (a *api) checkReceiptHandler(w http.ResponseWriter, r *http.Request) {
}
if iapr.DeleteDevice {
if dev.GracePeriodExpiresAt.After(time.Now()) {
w.WriteHeader(http.StatusOK)
return
}
if dev.GracePeriodExpiresAt.Before(time.Now()) {
accs, err := a.accountRepo.GetByAPNSToken(ctx, apns)
if err != nil {
a.errorResponse(w, r, 500, err)
@ -52,6 +48,7 @@ func (a *api) checkReceiptHandler(w http.ResponseWriter, r *http.Request) {
}
_ = a.deviceRepo.Delete(ctx, apns)
}
} else {
dev.ExpiresAt = time.Now().Add(domain.DeviceActiveAfterReceitCheckDuration)
dev.GracePeriodExpiresAt = dev.ExpiresAt.Add(domain.DeviceGracePeriodAfterReceiptExpiry)