mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
tweak on receipt check
This commit is contained in:
parent
079cc9a5c5
commit
bbb3001544
1 changed files with 10 additions and 13 deletions
|
@ -36,22 +36,19 @@ func (a *api) checkReceiptHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if iapr.DeleteDevice {
|
if iapr.DeleteDevice {
|
||||||
if dev.GracePeriodExpiresAt.After(time.Now()) {
|
if dev.GracePeriodExpiresAt.Before(time.Now()) {
|
||||||
w.WriteHeader(http.StatusOK)
|
accs, err := a.accountRepo.GetByAPNSToken(ctx, apns)
|
||||||
return
|
if err != nil {
|
||||||
}
|
a.errorResponse(w, r, 500, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
accs, err := a.accountRepo.GetByAPNSToken(ctx, apns)
|
for _, acc := range accs {
|
||||||
if err != nil {
|
_ = a.accountRepo.Disassociate(ctx, &acc, &dev)
|
||||||
a.errorResponse(w, r, 500, err)
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, acc := range accs {
|
_ = a.deviceRepo.Delete(ctx, apns)
|
||||||
_ = a.accountRepo.Disassociate(ctx, &acc, &dev)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = a.deviceRepo.Delete(ctx, apns)
|
|
||||||
} else {
|
} else {
|
||||||
dev.ExpiresAt = time.Now().Add(domain.DeviceActiveAfterReceitCheckDuration)
|
dev.ExpiresAt = time.Now().Add(domain.DeviceActiveAfterReceitCheckDuration)
|
||||||
dev.GracePeriodExpiresAt = dev.ExpiresAt.Add(domain.DeviceGracePeriodAfterReceiptExpiry)
|
dev.GracePeriodExpiresAt = dev.ExpiresAt.Add(domain.DeviceGracePeriodAfterReceiptExpiry)
|
||||||
|
|
Loading…
Reference in a new issue