go back to preUnshare hooks since sharing doesn't trigger post unshare hooks
This commit is contained in:
parent
9b49832090
commit
5a64c96d06
|
@ -16,8 +16,8 @@ OCP\Util::connectHook( 'OC_User', 'pre_setPassword','OCA\Encryption\Hooks', 'set
|
||||||
|
|
||||||
// Sharing-related hooks
|
// Sharing-related hooks
|
||||||
OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' );
|
OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' );
|
||||||
OCP\Util::connectHook( 'OCP\Share', 'post_unshare', 'OCA\Encryption\Hooks', 'postUnshare' );
|
OCP\Util::connectHook( 'OCP\Share', 'pre_unshare', 'OCA\Encryption\Hooks', 'preUnshare' );
|
||||||
OCP\Util::connectHook( 'OCP\Share', 'post_unshareAll', 'OCA\Encryption\Hooks', 'postUnshareAll' );
|
OCP\Util::connectHook( 'OCP\Share', 'pre_unshareAll', 'OCA\Encryption\Hooks', 'preUnshareAll' );
|
||||||
|
|
||||||
// Webdav-related hooks
|
// Webdav-related hooks
|
||||||
OCP\Util::connectHook( 'OC_Webdav_Properties', 'update', 'OCA\Encryption\Hooks', 'updateKeyfile' );
|
OCP\Util::connectHook( 'OC_Webdav_Properties', 'update', 'OCA\Encryption\Hooks', 'updateKeyfile' );
|
||||||
|
|
|
@ -157,8 +157,6 @@ class Hooks {
|
||||||
, \OC_Log::ERROR
|
, \OC_Log::ERROR
|
||||||
);
|
);
|
||||||
|
|
||||||
error_log( "Client side encryption is enabled but the client doesn't provide an encryption key for the file!" );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,7 +167,7 @@ class Hooks {
|
||||||
* @brief
|
* @brief
|
||||||
*/
|
*/
|
||||||
public static function postShared( $params ) {
|
public static function postShared( $params ) {
|
||||||
|
error_log("post shared triggered!");
|
||||||
// NOTE: $params is an array with these keys:
|
// NOTE: $params is an array with these keys:
|
||||||
// itemSource -> int, filecache file ID
|
// itemSource -> int, filecache file ID
|
||||||
// shareWith -> string, uid of user being shared to
|
// shareWith -> string, uid of user being shared to
|
||||||
|
@ -214,22 +212,27 @@ class Hooks {
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*/
|
*/
|
||||||
public static function postUnshare( $params ) {
|
public static function preUnshare( $params ) {
|
||||||
$shares = \OCP\Share::getUsersSharingFile( $params['fileTarget'], 1 );
|
$items = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']);
|
||||||
|
$shares = \OCP\Share::getUsersSharingFile( $item[0]['file_target'], 1 );
|
||||||
|
|
||||||
$userIds = array();
|
$userIds = array();
|
||||||
foreach ( $shares as $share ) {
|
foreach ( $shares as $share ) {
|
||||||
$userIds[] = $share['userId'];
|
$userIds[] = $share['userId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Crypt::encKeyfileToMultipleUsers($userIDs, $params['fileTarget']);
|
// remove the user from the list from which the file will be unshared
|
||||||
|
unset($userIds[$params['shareWith']]);
|
||||||
|
|
||||||
|
return Crypt::encKeyfileToMultipleUsers($userIDs, $item[0]['file_target']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*/
|
*/
|
||||||
public static function postUnshareAll( $params ) {
|
public static function preUnshareAll( $params ) {
|
||||||
return self::postUnshare($params);
|
$items = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']);
|
||||||
|
return Crypt::encKeyfileToMultipleUsers(array($items[0]['uid_owner']), $items[0]['file_target']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue