Merge pull request #17335 from owncloud/better-federated-cloud-sharing-activities

Improve federated cloud sharing activities
This commit is contained in:
Joas Schilling 2015-07-06 10:23:33 +02:00
commit 4dbc8ab77f
2 changed files with 26 additions and 13 deletions

View File

@ -22,6 +22,8 @@
namespace OCA\Files_Sharing\API; namespace OCA\Files_Sharing\API;
use OCA\Files_Sharing\Activity;
class Server2Server { class Server2Server {
/** /**
@ -69,8 +71,8 @@ class Server2Server {
$user = $owner . '@' . $this->cleanupRemote($remote); $user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity( \OC::$server->getActivityManager()->publishActivity(
'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user), '', array(), Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(),
'', '', $shareWith, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW); '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
return new \OC_OCS_Result(); return new \OC_OCS_Result();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -102,8 +104,8 @@ class Server2Server {
list($file, $link) = self::getFile($share['uid_owner'], $share['file_source']); list($file, $link) = self::getFile($share['uid_owner'], $share['file_source']);
\OC::$server->getActivityManager()->publishActivity( \OC::$server->getActivityManager()->publishActivity(
'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_ACCEPTED, array($share['share_with'], basename($file)), '', array(), Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_ACCEPTED, array($share['share_with'], basename($file)), '', array(),
$file, $link, $share['uid_owner'], \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW); $file, $link, $share['uid_owner'], Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
} }
return new \OC_OCS_Result(); return new \OC_OCS_Result();
@ -133,8 +135,8 @@ class Server2Server {
list($file, $link) = $this->getFile($share['uid_owner'], $share['file_source']); list($file, $link) = $this->getFile($share['uid_owner'], $share['file_source']);
\OC::$server->getActivityManager()->publishActivity( \OC::$server->getActivityManager()->publishActivity(
'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_DECLINED, array($share['share_with'], basename($file)), '', array(), Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_DECLINED, array($share['share_with'], basename($file)), '', array(),
$file, $link, $share['uid_owner'], \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW); $file, $link, $share['uid_owner'], Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
} }
return new \OC_OCS_Result(); return new \OC_OCS_Result();
@ -170,9 +172,15 @@ class Server2Server {
$query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share_external` WHERE `remote_id` = ? AND `share_token` = ?'); $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share_external` WHERE `remote_id` = ? AND `share_token` = ?');
$query->execute(array($id, $token)); $query->execute(array($id, $token));
if ($share['accepted']) {
$path = trim($mountpoint, '/');
} else {
$path = trim($share['name'], '/');
}
\OC::$server->getActivityManager()->publishActivity( \OC::$server->getActivityManager()->publishActivity(
'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_UNSHARED, array($owner, $mountpoint), '', array(), Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_UNSHARED, array($owner, $path), '', array(),
'', '', $user, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_MEDIUM); '', '', $user, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_MEDIUM);
} }
return new \OC_OCS_Result(); return new \OC_OCS_Result();

View File

@ -150,6 +150,10 @@ class Activity implements IExtension {
if ($app === self::FILES_SHARING_APP) { if ($app === self::FILES_SHARING_APP) {
switch ($text) { switch ($text) {
case self::SUBJECT_REMOTE_SHARE_RECEIVED: case self::SUBJECT_REMOTE_SHARE_RECEIVED:
if (sizeof($params) === 2) {
// New activity ownCloud 8.2+
return (string) $l->t('You received a new remote share %2$s from %1$s', $params);
}
return (string) $l->t('You received a new remote share from %s', $params); return (string) $l->t('You received a new remote share from %s', $params);
case self::SUBJECT_REMOTE_SHARE_ACCEPTED: case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
return (string) $l->t('%1$s accepted remote share %2$s', $params); return (string) $l->t('%1$s accepted remote share %2$s', $params);
@ -190,14 +194,15 @@ class Activity implements IExtension {
if ($app === self::FILES_SHARING_APP) { if ($app === self::FILES_SHARING_APP) {
switch ($text) { switch ($text) {
case self::SUBJECT_REMOTE_SHARE_RECEIVED: case self::SUBJECT_REMOTE_SHARE_RECEIVED:
case self::SUBJECT_REMOTE_SHARE_UNSHARED:
return array( return array(
0 => '',// We can not use 'username' since the user is in a different ownCloud 0 => 'federated_cloud_id',
//1 => 'file', in theory its a file, but it does not exist yet/anymore
); );
case self::SUBJECT_REMOTE_SHARE_ACCEPTED: case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
case self::SUBJECT_REMOTE_SHARE_DECLINED: case self::SUBJECT_REMOTE_SHARE_DECLINED:
case self::SUBJECT_REMOTE_SHARE_UNSHARED:
return array( return array(
0 => '',// We can not use 'username' since the user is in a different ownCloud 0 => 'federated_cloud_id',
1 => 'file', 1 => 'file',
); );
case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED: case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
@ -214,7 +219,7 @@ class Activity implements IExtension {
case self::SUBJECT_SHARED_GROUP_SELF: case self::SUBJECT_SHARED_GROUP_SELF:
return [ return [
0 => 'file', 0 => 'file',
//1 => 'group', Group does not exist yet 1 => 'group',
]; ];
} }
} }
@ -230,7 +235,7 @@ class Activity implements IExtension {
* @return integer|false * @return integer|false
*/ */
public function getGroupParameter($activity) { public function getGroupParameter($activity) {
if ($activity['app'] === 'files') { if ($activity['app'] === self::FILES_SHARING_APP) {
switch ($activity['subject']) { switch ($activity['subject']) {
case self::SUBJECT_SHARED_LINK_SELF: case self::SUBJECT_SHARED_LINK_SELF:
case self::SUBJECT_SHARED_WITH_BY: case self::SUBJECT_SHARED_WITH_BY: