public function validate_amazon_polly_access()

in admin/AmazonAI-Common.php [653:702]


	public function validate_amazon_polly_access()
	{
		try {
			$this->check_aws_access();

			// Checks if S3 should be used for storing files.

			$is_s3_enabled = $this->is_s3_enabled();
			if ($is_s3_enabled) {
				try {

					// Checks if S3 bucket can be access.

					$accessible = $this->s3_handler->check_if_s3_bucket_accessible();
					if (!$accessible) {
						$this->s3_handler->create_s3_bucket();
						$this->show_error_notice("notice-info", "The S3 bucket was successfully created.");
					}
				}

				catch(S3BucketNotAccException $e) {
					$this->show_error_notice("notice-info", "The S3 bucket doesn't exist or can't be accessed. Creating a new S3 bucket.");

					// If S3 bucket is not accessible, we will try to create new one.

					$this->s3_handler->create_s3_bucket();
					$this->show_error_notice("notice-info", "The S3 bucket was successfully created.");
				}
			}
		}

		catch(CredsException $e) {
			$this->deactivate_all();
			$this->show_error_notice("notice-error", "Can't connect to AWS. Check your AWS credentials.");
			return false;
		}

		catch(S3BucketNotCreException $e) {
			$this->show_error_notice("notice-error", "Could not create S3 bucket.");
			return false;
		}

		catch(Exception $e) {
			$this->deactivate_all();
			$this->show_error_notice("notice-error", "Unknown error.");
			return false;
		}

		return true;
	}