Scrap the notifications when the share is accepted or declined

This commit is contained in:
Joas Schilling 2015-09-01 18:56:09 +02:00
parent d191a0dacc
commit 805f1d0096
8 changed files with 33 additions and 2 deletions

View file

@ -52,6 +52,7 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
\OC::$server->getUserSession()->getUser()->getUID()
);

View file

@ -23,6 +23,7 @@ namespace OCA\Files_Sharing\API;
use OC\Files\Filesystem;
use OCA\Files_Sharing\External\Manager;
use OCP\Notification\IManager;
class Remote {
@ -38,6 +39,7 @@ class Remote {
Filesystem::getMountManager(),
Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
\OC_User::getUser()
);
@ -56,6 +58,7 @@ class Remote {
Filesystem::getMountManager(),
Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
\OC_User::getUser()
);
@ -78,6 +81,7 @@ class Remote {
Filesystem::getMountManager(),
Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
\OC_User::getUser()
);
@ -87,5 +91,4 @@ class Remote {
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
}
}

View file

@ -70,6 +70,7 @@ class Server2Server {
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
$shareWith
);

View file

@ -93,6 +93,7 @@ class Application extends App {
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
$server->getHTTPHelper(),
$server->getNotificationManager(),
$uid
);
});

View file

@ -28,6 +28,7 @@ namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
use OCP\Files;
use OCP\Notification\IManager;
class Manager {
const STORAGE = '\OCA\Files_Sharing\External\Storage';
@ -57,20 +58,27 @@ class Manager {
*/
private $httpHelper;
/**
* @var IManager
*/
private $notificationManager;
/**
* @param \OCP\IDBConnection $connection
* @param \OC\Files\Mount\Manager $mountManager
* @param \OCP\Files\Storage\IStorageFactory $storageLoader
* @param \OC\HTTPHelper $httpHelper
* @param IManager $notificationManager
* @param string $uid
*/
public function __construct(\OCP\IDBConnection $connection, \OC\Files\Mount\Manager $mountManager,
\OCP\Files\Storage\IStorageFactory $storageLoader, \OC\HTTPHelper $httpHelper, $uid) {
\OCP\Files\Storage\IStorageFactory $storageLoader, \OC\HTTPHelper $httpHelper, IManager $notificationManager, $uid) {
$this->connection = $connection;
$this->mountManager = $mountManager;
$this->storageLoader = $storageLoader;
$this->httpHelper = $httpHelper;
$this->uid = $uid;
$this->notificationManager = $notificationManager;
}
/**
@ -206,6 +214,7 @@ class Manager {
$acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid));
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
$this->scrapNotification($share['remote_id']);
return true;
}
@ -228,12 +237,24 @@ class Manager {
$removeShare->execute(array($id, $this->uid));
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
$this->scrapNotification($share['remote_id']);
return true;
}
return false;
}
/**
* @param int $remoteShare
*/
protected function scrapNotification($remoteShare) {
$filter = $this->notificationManager->createNotification();
$filter->setApp('files_sharing')
->setUser($this->uid)
->setObject('remote_share', (int) $remoteShare);
$this->notificationManager->markProcessed($filter);
}
/**
* inform remote server whether server-to-server share was accepted/declined
*
@ -265,6 +286,7 @@ class Manager {
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
$params['user']
);

View file

@ -33,6 +33,7 @@ class Hooks {
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
$params['uid']);
$manager->removeUserShares($params['uid']);

View file

@ -50,6 +50,7 @@ class ManagerTest extends TestCase {
$this->mountManager,
new StorageFactory(),
$httpHelper,
\OC::$server->getNotificationManager(),
$this->uid
);
}

View file

@ -154,6 +154,7 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
$toDelete
);