Skip to content

Commit

Permalink
existing kias can register, block new kias minting
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyson-English committed Apr 19, 2024
1 parent b8c23f2 commit d10064f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
17 changes: 7 additions & 10 deletions internal/controllers/user_devices_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,22 +784,13 @@ func (udc *UserDevicesController) RegisterDeviceForUserFromSmartcar(c *fiber.Ctx
if info == nil {
info = &smartcar.Info{}
}
// block kia
if strings.ToLower(info.Make) == "kia" {
localLog.Warn().Msgf("kia blocked, smartcar make")
return fiber.NewError(fiber.StatusFailedDependency, "Kia vehicles are only supported via Hardware connections for now.")
}

// decode VIN with grpc call, including any possible smartcar known info
decodeVIN, err := udc.DeviceDefSvc.DecodeVIN(c.Context(), vin, info.Model, info.Year, reg.CountryCode)
if err != nil {
localLog.Err(err).Msg("unable to decode vin for customer request to create vehicle")
return shared.GrpcErrorToFiber(err, "unable to decode vin: "+vin)
}
// jic kia block by make id
if decodeVIN.DeviceMakeId == "2681cSm2zmTmGHzqK3ldzoTLZIw" {
localLog.Warn().Msgf("kia blocked, by smartcar vin decode to kia meke id")
return fiber.NewError(fiber.StatusFailedDependency, "Kia vehicles are only supported via Hardware connections for now.")
}

// in case err is nil but we don't get a valid decode
if len(decodeVIN.DeviceDefinitionId) == 0 {
Expand Down Expand Up @@ -1278,6 +1269,12 @@ func (udc *UserDevicesController) GetMintDevice(c *fiber.Ctx) error {
}
makeTokenID := big.NewInt(int64(dd.Make.TokenId))

// block new kias from minting
if strings.ToLower(dd.Make.NameSlug) == "kia" || dd.Make.Id == "2681cSm2zmTmGHzqK3ldzoTLZIw" {
udc.log.Warn().Msgf("new kias blocked from minting")
return fiber.NewError(fiber.StatusFailedDependency, "Kia vehicles cannot be manually minted for now.")
}

user, err := udc.usersClient.GetUser(c.Context(), &pb.GetUserRequest{Id: userID})
if err != nil {
udc.log.Err(err).Msg("Couldn't retrieve user record.")
Expand Down
6 changes: 1 addition & 5 deletions internal/controllers/user_integrations_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1456,11 +1456,7 @@ func (udc *UserDevicesController) registerDeviceIntegrationInner(c *fiber.Ctx, u
logger.Err(err).Msg("grpc error searching for device definition")
return shared.GrpcErrorToFiber(err, "failed to get device definition with id: "+ud.DeviceDefinitionID)
}
// block SC kia's
if dd.Make.NameSlug == "kia" && integrationID == "22N2xaPOq2WW2gAHBHd0Ikn4Zob" {
logger.Warn().Msg("kia blocked, smartcar connection")
return fiber.NewError(fiber.StatusConflict, "kia software connection blocked, only hardware connections are allowed for this car")
}

logger.Info().Msgf("get device definition id result during registration %+v", dd)

// filter out the desired integration from the compatible ones
Expand Down

0 comments on commit d10064f

Please sign in to comment.