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