Änderung für File Events
This commit is contained in:
parent
f4490f2dbe
commit
f7c509650f
|
|
@ -19,4 +19,7 @@
|
|||
<icon>app.svg</icon>
|
||||
</navigation>-->
|
||||
</navigations>
|
||||
<types>
|
||||
<filesystem/>
|
||||
</types>
|
||||
</info>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue