diff --git a/app/Services/Apis/Samsung/DecryptedListResponse.php b/app/Services/Apis/Samsung/DecryptedListResponse.php index f32597727..e7be28d97 100644 --- a/app/Services/Apis/Samsung/DecryptedListResponse.php +++ b/app/Services/Apis/Samsung/DecryptedListResponse.php @@ -52,6 +52,10 @@ public function __construct(string $key, string $content, string $forum){ $list = json_decode($dec->getData(), true); if(!is_array($list)) throw new InvalidResponse(sprintf("invalid data field on response %s", $content)); + + if(count($list) == 0) + throw new EmptyResponse("response not found"); + $this->payload = $list; } diff --git a/app/Services/Apis/Samsung/DecryptedSingleResponse.php b/app/Services/Apis/Samsung/DecryptedSingleResponse.php index 569f2c1ce..94bf34e84 100644 --- a/app/Services/Apis/Samsung/DecryptedSingleResponse.php +++ b/app/Services/Apis/Samsung/DecryptedSingleResponse.php @@ -45,6 +45,9 @@ public function __construct(string $key, string $content, string $forum){ if(!is_array($list)) throw new InvalidResponse(sprintf("invalid data field on response %s", $content)); $this->payload = count($list) == 1 ? $list[0] : $list; + + if(count($this->payload) == 0) + throw new EmptyResponse("response not found"); } diff --git a/app/Services/Apis/Samsung/SamsungRegistrationAPI.php b/app/Services/Apis/Samsung/SamsungRegistrationAPI.php index 522989e80..178f79fe3 100644 --- a/app/Services/Apis/Samsung/SamsungRegistrationAPI.php +++ b/app/Services/Apis/Samsung/SamsungRegistrationAPI.php @@ -11,7 +11,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -use GuzzleHttp\Client; use Exception; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; @@ -91,11 +90,19 @@ public function checkUser(Summit $summit, string $userId, string $region = Regio } catch (RequestException $ex) { Log::warning($ex->getMessage()); - return null; + return []; + } + catch(EmptyResponse $ex){ + Log::warning($ex->getMessage()); + return []; + } + catch (InvalidResponse $ex){ + Log::warning($ex->getMessage()); + return []; } catch (Exception $ex) { Log::error($ex->getMessage()); - return null; + return []; } } @@ -114,7 +121,6 @@ public function checkEmail(Summit $summit,string $email, string $region = Region Log::debug(sprintf("SamsungRegistrationAPI::checkEmail POST %s payload %s", $this->endpoint, $request)); - // http://docs.guzzlephp.org/en/stable/request-options.html $response = $this->client->request('POST', $this->endpoint, @@ -138,11 +144,19 @@ public function checkEmail(Summit $summit,string $email, string $region = Region } catch (RequestException $ex) { Log::warning($ex->getMessage()); - return null; + return []; + } + catch(EmptyResponse $ex){ + Log::warning($ex->getMessage()); + return []; + } + catch (InvalidResponse $ex){ + Log::warning($ex->getMessage()); + return []; } catch (Exception $ex) { Log::error($ex->getMessage()); - return null; + return []; } } @@ -182,6 +196,14 @@ public function userList(Summit $summit, string $region = Regions::US) Log::warning($ex->getMessage()); return null; } + catch(EmptyResponse $ex){ + Log::warning($ex->getMessage()); + return null; + } + catch(InvalidResponse $ex){ + Log::warning($ex->getMessage()); + return null; + } catch (Exception $ex) { Log::error($ex->getMessage()); return null; diff --git a/app/Services/Model/Imp/RegistrationIngestionService.php b/app/Services/Model/Imp/RegistrationIngestionService.php index 9f5dad912..4c014e32b 100644 --- a/app/Services/Model/Imp/RegistrationIngestionService.php +++ b/app/Services/Model/Imp/RegistrationIngestionService.php @@ -171,6 +171,7 @@ public function ingestExternalAttendee($summit_id, $index, $external_attendee, I $cancelled = $external_attendee['cancelled'] ?? false; $ticket_type = $summit->getTicketTypeByExternalId($ticket_class['id']); + if (is_null($ticket_type)) { // create ticket type if it does not exists Log::debug(sprintf("RegistrationIngestionService::ingestSummit: ticket class %s does not exists", $ticket_class['id'])); @@ -640,6 +641,9 @@ public function ingestSummit(Summit $summit): void Log::debug(sprintf("RegistrationIngestionService::ingestSummit getting external attendees page %s", $page)); $response = $feed->getAttendees($page, $summit->getExternalRegistrationFeedLastIngestDate()); + if(is_null($response)) + throw new ValidationException("Response is empty"); + if ($response->hasData()) { $shouldMarkProcess = true; } else { diff --git a/app/Services/Model/Strategies/TicketFinder/Strategies/TicketFinderByExternalFeedStrategy.php b/app/Services/Model/Strategies/TicketFinder/Strategies/TicketFinderByExternalFeedStrategy.php index 3f991fb65..282995d7b 100644 --- a/app/Services/Model/Strategies/TicketFinder/Strategies/TicketFinderByExternalFeedStrategy.php +++ b/app/Services/Model/Strategies/TicketFinder/Strategies/TicketFinderByExternalFeedStrategy.php @@ -76,6 +76,7 @@ public function find(): ?SummitAttendeeTicket Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s", $this->ticket_criteria)); if($this->feed->isValidQRCode($this->ticket_criteria)){ + Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is a valid QRCode", $this->ticket_criteria)); $externalAttendeeId = $this->feed->getExternalUserIdFromQRCode($this->ticket_criteria); // check first if we have it locally $attendee = $this->attendee_repository->getBySummitAndExternalId @@ -83,6 +84,11 @@ public function find(): ?SummitAttendeeTicket $this->summit, $externalAttendeeId ); + if(!is_null($attendee) && !$attendee->hasTickets()){ + Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find attendee %s has no tickets, re fetch it from external feed", $externalAttendeeId)); + $attendee = null; + } + if(is_null($attendee)) { Log::debug @@ -123,8 +129,10 @@ public function find(): ?SummitAttendeeTicket return $attendee->getFirstTicket(); } + if(filter_var($this->ticket_criteria, FILTER_VALIDATE_EMAIL)){ + Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is a valid email", $this->ticket_criteria)); $externalAttendeeEmail = $this->ticket_criteria; // check first if we have it locally $attendee = $this->attendee_repository->getBySummitAndEmail @@ -132,6 +140,11 @@ public function find(): ?SummitAttendeeTicket $this->summit, $externalAttendeeEmail ); + if(!is_null($attendee) && !$attendee->hasTickets()){ + Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find attendee %s has no tickets, re fetch it from external feed", $externalAttendeeEmail)); + $attendee = null; + } + if(is_null($attendee)) { Log::debug @@ -170,6 +183,7 @@ public function find(): ?SummitAttendeeTicket } return $attendee->getFirstTicket(); } + Log::debug(sprintf("TicketFinderByExternalFeedStrategy::find ticket_criteria %s is not a valid QRCode or email", $this->ticket_criteria)); return null; } } \ No newline at end of file