2024-01-14 16:50:09 +00:00
|
|
|
package redisotp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-01-15 10:33:24 +00:00
|
|
|
|
2024-01-14 16:50:09 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (d DB) DeleteCodeByPhoneNumber(ctx context.Context, phoneNumber string) (bool, error) {
|
|
|
|
const op = "redisotp.GetCodeByPhoneNumber"
|
|
|
|
|
|
|
|
success, err := d.adapter.Client().Del(ctx, phoneNumber).Result()
|
|
|
|
if err != nil {
|
|
|
|
return false, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
if success != 1 {
|
|
|
|
return false, nil
|
|
|
|
}
|
2024-01-15 10:33:24 +00:00
|
|
|
|
2024-01-14 16:50:09 +00:00
|
|
|
return true, nil
|
|
|
|
}
|