Version 4.7.6

This commit is contained in:
Neo committed 2025-12-19 16:05:19 -08:00
1 parent 8ba7d43898
commit 7b7404e741
1085 files changed
+30590 -7837

No files matched your search

+26 -2
View File
@@ -56,6 +56,13 @@ class _Api extends \IPS\Dispatcher
* @brief Language
*/
public $language = NULL;
/**
* Can the Response be cached?
*
* @var bool
*/
public bool $cacheResponse = TRUE;
/**
* Init
@@ -94,10 +101,17 @@ class _Api extends \IPS\Dispatcher
/* Set other data */
$this->_setLanguage();
/* We don't want to cache any output for Zapier Requests */
if( \IPS\Request::i()->isZapier() )
{
$this->cacheResponse = FALSE;
}
}
catch ( \IPS\Api\Exception $e )
{
/* Build resonse */
/* Build response */
$response = json_encode( array( 'errorCode' => $e->exceptionCode, 'errorMessage' => $e->getMessage() ), JSON_PRETTY_PRINT );
/* Do we need to log this? */
@@ -408,7 +422,7 @@ class _Api extends \IPS\Dispatcher
*/
protected function _respond( $response, $httpResponseCode, $oauthError=NULL, $log=FALSE )
{
$headers = ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' AND !$this->rawAccessToken ) ? \IPS\Output::getCacheHeaders( time(), 60 ) : \IPS\Output::getNoCacheHeaders();
$headers = $this->canBeCached() ? \IPS\Output::getCacheHeaders( time(), 60 ) : \IPS\Output::getNoCacheHeaders();
if ( $this->rawAccessToken and $oauthError )
{
@@ -422,6 +436,16 @@ class _Api extends \IPS\Dispatcher
\IPS\Output::i()->sendOutput( $response, $httpResponseCode, 'application/json', $headers );
}
/**
* Can this response be cached?
*
* @return bool
*/
protected function canBeCached() : bool
{
return $this->cacheResponse AND mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' AND !$this->rawAccessToken;
}
/**
* Destructor