Änderung für File Events

This commit is contained in:
Holger Trampe 2021-09-01 16:43:03 +02:00
parent f4490f2dbe
commit f7c509650f
2 changed files with 42 additions and 1 deletions

View File

@ -19,4 +19,7 @@
<icon>app.svg</icon>
</navigation>-->
</navigations>
<types>
<filesystem/>
</types>
</info>

View File

@ -14,10 +14,11 @@ use OCP\User\Events\PostLoginEvent;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
class Application extends App {
protected $AppName = 'Agency';
# TEST
public function __construct() {
parent::__construct($this->AppName);
@ -31,6 +32,43 @@ class Application extends App {
# Checking, if a user logged in in Django and which user is logged in in Django.
$dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LoginByNC::class);
# Event before a File is deletet
$dispatcher->addServiceListener(BeforeNodeDeletedEvent::class, DeleteNCFileDjango::class);
}
}
/*
A File is ready to be deleted in NC, before that happens delete the File in Django and remove it from addedfiles_nc in standards
*/
class DeleteNCFileDjango extends Controller {
protected $session;
//private $nclink = 'https://test.app.digitale-agentur.com';
private $nclink = 'http://host.docker.internal:8000';
public function __construct(string $AppName, IRequest $request, IUserSession $session) {
parent::__construct($AppName, $request);
$this->session = $session;
}
public function handle(BeforeNodeDeletedEvent $event): void {
$opts = [
"http" => array(
"method" => "GET",
"header" => ""
),
"ssl"=> array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
];
$context = stream_context_create($opts);
$file = file_get_contents($this->nclink.'/api/deletefile/'.$event->getNode()->getId().'/87zuhjk87GHJ546tzgvhas76aaskbdhr45edfVHAKia87s6gbAVGFGSR3451627gBHAKJBN', false, $context);
}
}