Skip to content

Commit

Permalink
fix(controllers.account.create): remove unnecessary code
Browse files Browse the repository at this point in the history
Signed-off-by: Hanif Dwy Putra S <hanifdwyputrasembiring@gmail.com>
  • Loading branch information
hansputera committed Oct 9, 2022
1 parent 5cf48c7 commit 7b73e05
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions controllers/account/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@ func AccountCreate(w http.ResponseWriter, r *http.Request) {
account.Slug = strings.ReplaceAll(account.InstagramUID, " ", "")

err = global.RedisClient.Get(global.ContextConsume, account.Slug).Err()
if err != nil {
if err != nil && err != redis.Nil{
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
return
} else if err != redis.Nil {
rid := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(500)

if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("Couldn't generate random id!"))
return
}
account.Slug = strings.Join([]string{
account.Slug,
fmt.Sprint(rid),
Expand Down

0 comments on commit 7b73e05

Please sign in to comment.