parent
554e91d447
commit
662397c320
|
@ -3,9 +3,11 @@
|
|||
namespace OCA\Memories\Controller;
|
||||
|
||||
use OCA\Files\Event\LoadSidebar;
|
||||
use OCA\Memories\Service\BinExt;
|
||||
use OCA\Memories\Util;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IRequest;
|
||||
|
@ -40,9 +42,10 @@ class PageController extends Controller
|
|||
*/
|
||||
public function main()
|
||||
{
|
||||
$user = $this->userSession->getUser();
|
||||
if (null === $user) {
|
||||
return null;
|
||||
// Check native version if available
|
||||
$nativeVer = Util::callerNativeVersion();
|
||||
if (null !== $nativeVer && version_compare($nativeVer, BinExt::NX_VER_MIN, '<')) {
|
||||
return new PublicTemplateResponse($this->appName, 'native-old');
|
||||
}
|
||||
|
||||
// Scripts
|
||||
|
|
|
@ -10,6 +10,7 @@ class BinExt
|
|||
{
|
||||
public const EXIFTOOL_VER = '12.60';
|
||||
public const GOVOD_VER = '0.1.5';
|
||||
public const NX_VER_MIN = '1.0';
|
||||
|
||||
/** Copy a binary to temp dir for execution */
|
||||
public static function getTempBin(string $path, string $name, bool $copy = true): string
|
||||
|
|
18
lib/Util.php
18
lib/Util.php
|
@ -404,12 +404,26 @@ class Util
|
|||
*/
|
||||
public static function callerIsNative(): bool
|
||||
{
|
||||
$request = \OC::$server->get(\OCP\IRequest::class);
|
||||
$userAgent = $request->getHeader('User-Agent');
|
||||
$userAgent = \OC::$server->get(\OCP\IRequest::class)->getHeader('User-Agent');
|
||||
|
||||
return false !== strpos($userAgent, 'MemoriesNative');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of the native caller.
|
||||
*/
|
||||
public static function callerNativeVersion(): ?string
|
||||
{
|
||||
$userAgent = \OC::$server->get(\OCP\IRequest::class)->getHeader('User-Agent');
|
||||
|
||||
$matches = [];
|
||||
if (preg_match('/MemoriesNative\/([0-9.]+)/', $userAgent, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill all instances of a process by name.
|
||||
* Similar to pkill, which may not be available on all systems.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<div id="app-content" style="padding: 20px;">
|
||||
Your native app version is too old! Please update to the latest version.
|
||||
</div>
|
Loading…
Reference in New Issue