Skip to content

Commit

Permalink
Update for NC21 compatibility. WIP Notify if favorited file is locked
Browse files Browse the repository at this point in the history
  • Loading branch information
orzuionut committed Jun 15, 2021
1 parent ff57605 commit 14b0f2f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 64 deletions.
4 changes: 2 additions & 2 deletions w2g2/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</description>
<licence>AGPL</licence>
<author>Ionut Orzu</author>
<version>3.0.5</version>
<version>3.2.6</version>
<category>social</category>
<category>files</category>

Expand Down Expand Up @@ -42,7 +42,7 @@
</activity>

<settings>
<admin>OCA\w2g2\Controller\AdminController</admin>
<admin>OCA\w2g2\Settings\AdminSettings</admin>
</settings>

<repair-steps>
Expand Down
5 changes: 4 additions & 1 deletion w2g2/js/w2g2.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@

//Walk through all files in the active Filelist
$('#content').delegate('#fileList', 'fileActionsReady', function (event) {
window.x = event.$files;

for (var i = 0; i < event.$files.length; i++) {
var file = event.$files[i][0];
var $file = $(file);

if ($file && $file.hasOwnProperty('context')) {
// if ($file && $file.hasOwnProperty('context')) {
if ($file) {
files.push([
$file.attr('data-id'),
$file.attr('data-file'),
Expand Down
3 changes: 2 additions & 1 deletion w2g2/lib/Activity/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class EventHandler {
private $activityListener;
private $notificationListener;

public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener)
{
$this->activityListener = $activityListener;
$this->notificationListener = $notificationListener;
}
Expand Down
42 changes: 14 additions & 28 deletions w2g2/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

namespace OCA\w2g2\AppInfo;

use OCA\w2g2\Activity\ActivityListener;
use OCA\w2g2\Activity\EventHandler;
use OCA\w2g2\File;
use OCA\w2g2\Notification\NotificationListener;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Notification\IManager;
use OCP\IUserManager;
use OCP\App\IAppManager;
use OCP\IUserSession;
use OCP\Files\Config\IUserMountCache;
use Psr\Container\ContainerInterface;

use OCA\w2g2\Notification\Notifier;
use OCA\w2g2\Controller\AdminController;
use OCA\w2g2\Controller\AdminSettings;
use OCA\w2g2\Controller\ConfigController;
use OCA\w2g2\Controller\LockController;
use OCA\w2g2\Service\AdminService;
Expand All @@ -27,6 +27,9 @@
use OCA\w2g2\Db\FileMapper;
use OCA\w2g2\Db\GroupFolderMapper;
use OCA\w2g2\Db\LockMapper;
use OCA\w2g2\Activity\ActivityListener;
use OCA\w2g2\File;
use OCA\w2g2\Notification\NotificationListener;

class Application extends App implements IBootstrap
{
Expand All @@ -41,7 +44,7 @@ public function __construct()
$this->registerMappers($container);
$this->registerServices($container);
$this->registerControllers($container);
$this->registerVarious($container);
// $this->registerVarious($container);
}

public function boot(IBootContext $context): void
Expand Down Expand Up @@ -76,15 +79,6 @@ public function registerScripts()

protected function registerControllers($container)
{
$container->registerService('AdminController', function(ContainerInterface $c){
return new AdminController(
$c->get('AppName'),
$c->get('Request'),
$c->get('ConfigService'),
$c->get('AdminService')
);
});

$container->registerService('ConfigController', function(ContainerInterface $c){
return new ConfigController(
$c->get('AppName'),
Expand Down Expand Up @@ -184,26 +178,18 @@ protected function registerVarious($container)
{
$container->registerService('ActivityListener', function(ContainerInterface $c){
return new ActivityListener(
$c->get('IManager'),
$c->get('IUserSession'),
$c->get('IAppManager'),
$c->get('IUserMountCache')
$c->query(IManager::class),
$c->query(IUserSession::class),
$c->query(IAppManager::class),
$c->query(IUserMountCache::class)
);
});

$container->registerService('NotificationListener', function(ContainerInterface $c){
return new NotificationListener(
$c->get('IManager'),
$c->get('IUserManager'),
$c->query(IManager::class),
$c->get('FavoriteMapper')
);
});

$container->registerService('EventHandler', function(ContainerInterface $c){
return new EventHandler(
$c->get('ActivityListener'),
$c->get('NotificationListener')
);
});
}
}
6 changes: 3 additions & 3 deletions w2g2/lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace OCA\w2g2;

use OCA\w2g2\Activity\FileLockEvent;
use OCA\w2g2\Activity\EventHandler;

class Event {
class Event
{
public static function emit($type, $fileId, $lockerUser)
{
$eventType = $type === 'lock' ? FileLockEvent::EVENT_LOCK : FileLockEvent::EVENT_UNLOCK;
Expand All @@ -14,7 +14,7 @@ public static function emit($type, $fileId, $lockerUser)

$app = new \OCP\AppFramework\App('w2g2');

$eventHandler = $app->getContainer()->query(EventHandler::class);
$eventHandler = $app->getContainer()->query('OCA\w2g2\Activity\EventHandler');
$eventHandler->handle($fileLockEvent);
}
}
20 changes: 4 additions & 16 deletions w2g2/lib/Notification/NotificationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,18 @@

namespace OCA\w2g2\Notification;

use OCP\IUserManager;
use OCP\Notification\IManager;
use OCA\w2g2\Activity\FileLockEvent;
use OCA\w2g2\Db\FavoriteMapper;

class NotificationListener {
/** @var IManager */
class NotificationListener
{
protected $notificationManager;

/** @var IUserManager */
protected $userManager;

protected $favoriteMapper;

/**
* Listener constructor.
*
* @param IManager $notificationManager
* @param IUserManager $userManager
*/
public function __construct(IManager $notificationManager, IUserManager $userManager, FavoriteMapper $favoriteMapper)
public function __construct(FavoriteMapper $favoriteMapper)
{
$this->notificationManager = $notificationManager;
$this->userManager = $userManager;
$this->notificationManager = \OC::$server->get(\OCP\Notification\IManager::class);
$this->favoriteMapper = $favoriteMapper;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<?php

namespace OCA\w2g2\Controller;
namespace OCA\w2g2\Settings;

use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;
use OCP\Settings\ISettings;

use OCA\w2g2\Service\ConfigService;
use OCA\w2g2\Service\AdminService;

class AdminController extends Controller implements ISettings {
class AdminSettings implements ISettings
{
protected $appName;
protected $configService;
protected $adminService;

public function __construct($AppName, IRequest $request, ConfigService $configService, AdminService $adminService)
public function __construct()
{
parent::__construct($AppName, $request);
$this->appName = 'w2g2';

$app = new \OCP\AppFramework\App('w2g2');

$this->appName = $AppName;
$this->configService = $configService;
$this->adminService = $adminService;
$this->configService = $app->getContainer()->get('ConfigService');
$this->adminService = $app->getContainer()->get('AdminService');
}

public function getForm()
Expand All @@ -38,7 +35,7 @@ public function getForm()

'lockingByUsername' => $lockingByNameRule === "rule_username" ? 'checked' : '',
'lockingByDisplayName' => $lockingByNameRule === "rule_displayname" ? 'checked' : '',

'directoryLockingAll' => $directoryLock === "directory_locking_all",
'directoryLockingFiles' => $directoryLock === "directory_locking_files",
'directoryLockingNone' => $directoryLock === "directory_locking_none",
Expand Down

0 comments on commit 14b0f2f

Please sign in to comment.