Skip to content

Commit dd7e6eb

Browse files
authored
Update phone.go
lower amount to clean
1 parent 76ca330 commit dd7e6eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/logics/phone/phone.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"totoval/app/logics/phone/sms"
1313
)
1414

15+
const SMS_RESERVED_AMOUNT = uint(4)
16+
1517
type phone struct {
1618
chip interfaces.Chipper
1719
notifier interfaces.Notifier
@@ -106,7 +108,11 @@ func (ph *phone) parse(msg []byte) error {
106108
}
107109

108110
log.Info("sms amount", toto.V{"amount": smsAmount, "max": smsMax})
109-
if smsAmount >= smsMax {
111+
amountToClean := smsMax
112+
if smsMax <= SMS_RESERVED_AMOUNT {
113+
amountToClean = 0
114+
}
115+
if smsAmount >= amountToClean {
110116
for i := uint(0); i < smsAmount; i++ {
111117
if err := sms.Delete(ph.chip, i+1); err != nil {
112118
return err

0 commit comments

Comments
 (0)