summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/lib/activity.php32
-rw-r--r--apps/files_sharing/lib/activity.php2
-rw-r--r--lib/public/activity/iextension.php9
-rw-r--r--lib/public/activity/imanager.php8
4 files changed, 36 insertions, 15 deletions
diff --git a/apps/files/lib/activity.php b/apps/files/lib/activity.php
index fff49ea4ea5..44b051248b5 100644
--- a/apps/files/lib/activity.php
+++ b/apps/files/lib/activity.php
@@ -30,6 +30,7 @@ use OCP\IL10N;
use OCP\IURLGenerator;
class Activity implements IExtension {
+ const APP_FILES = 'files';
const FILTER_FILES = 'files';
const FILTER_FAVORITES = 'files_favorites';
@@ -78,7 +79,7 @@ class Activity implements IExtension {
* @return IL10N
*/
protected function getL10N($languageCode = null) {
- return $this->languageFactory->get('files', $languageCode);
+ return $this->languageFactory->get(self::APP_FILES, $languageCode);
}
/**
@@ -86,14 +87,21 @@ class Activity implements IExtension {
* If no additional types are to be added false is to be returned
*
* @param string $languageCode
- * @return array|false
+ * @return array|false Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [self::METHOD_*],
+ * ]
*/
public function getNotificationTypes($languageCode) {
$l = $this->getL10N($languageCode);
return [
self::TYPE_SHARE_CREATED => (string) $l->t('A new file or folder has been <strong>created</strong>'),
self::TYPE_SHARE_CHANGED => (string) $l->t('A file or folder has been <strong>changed</strong>'),
- self::TYPE_FAVORITES => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'),
+ self::TYPE_FAVORITES => [
+ 'desc' => (string) $l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'),
+ 'methods' => [self::METHOD_STREAM],
+ ],
self::TYPE_SHARE_DELETED => (string) $l->t('A file or folder has been <strong>deleted</strong>'),
self::TYPE_SHARE_RESTORED => (string) $l->t('A file or folder has been <strong>restored</strong>'),
];
@@ -107,7 +115,7 @@ class Activity implements IExtension {
* @return array|false
*/
public function getDefaultTypes($method) {
- if ($method === 'stream') {
+ if ($method === self::METHOD_STREAM) {
$settings = array();
$settings[] = self::TYPE_SHARE_CREATED;
$settings[] = self::TYPE_SHARE_CHANGED;
@@ -132,7 +140,7 @@ class Activity implements IExtension {
* @return string|false
*/
public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
- if ($app !== 'files') {
+ if ($app !== self::APP_FILES) {
return false;
}
@@ -173,7 +181,7 @@ class Activity implements IExtension {
* @return array|false
*/
function getSpecialParameterList($app, $text) {
- if ($app === 'files') {
+ if ($app === self::APP_FILES) {
switch ($text) {
case 'created_self':
case 'created_by':
@@ -223,7 +231,7 @@ class Activity implements IExtension {
* @return integer|false
*/
public function getGroupParameter($activity) {
- if ($activity['app'] === 'files') {
+ if ($activity['app'] === self::APP_FILES) {
switch ($activity['subject']) {
case 'created_self':
case 'created_by':
@@ -309,7 +317,7 @@ class Activity implements IExtension {
$user = $this->activityManager->getCurrentUserId();
// Display actions from all files
if ($filter === self::FILTER_FILES) {
- return ['`app` = ?', ['files']];
+ return ['`app` = ?', [self::APP_FILES]];
}
if (!$user) {
@@ -323,7 +331,7 @@ class Activity implements IExtension {
$favorites = $this->helper->getFavoriteFilePaths($user);
} catch (\RuntimeException $e) {
// Too many favorites, can not put them into one query anymore...
- return ['`app` = ?', ['files']];
+ return ['`app` = ?', [self::APP_FILES]];
}
/*
@@ -331,7 +339,7 @@ class Activity implements IExtension {
* or `file` is a favorite or in a favorite folder
*/
$parameters = $fileQueryList = [];
- $parameters[] = 'files';
+ $parameters[] = self::APP_FILES;
$fileQueryList[] = '(`type` <> ? AND `type` <> ?)';
$parameters[] = self::TYPE_SHARE_CREATED;
@@ -346,7 +354,7 @@ class Activity implements IExtension {
$parameters[] = $favorite . '/%';
}
- $parameters[] = 'files';
+ $parameters[] = self::APP_FILES;
return [
' CASE WHEN `app` = ? THEN (' . implode(' OR ', $fileQueryList) . ') ELSE `app` <> ? END ',
@@ -363,6 +371,6 @@ class Activity implements IExtension {
* @return bool
*/
protected function userSettingFavoritesOnly($user) {
- return (bool) $this->config->getUserValue($user, 'activity', 'notify_stream_' . self::TYPE_FAVORITES, false);
+ return (bool) $this->config->getUserValue($user, 'activity', 'notify_' . self::METHOD_STREAM . '_' . self::TYPE_FAVORITES, false);
}
}
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index e531674ddc2..204c0a037b9 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -106,7 +106,7 @@ class Activity implements IExtension {
self::TYPE_REMOTE_SHARE,
];
- if ($method === 'stream') {
+ if ($method === self::METHOD_STREAM) {
$defaultTypes[] = self::TYPE_PUBLIC_LINKS;
}
diff --git a/lib/public/activity/iextension.php b/lib/public/activity/iextension.php
index 19d1d2e83a0..5d9fe3329ef 100644
--- a/lib/public/activity/iextension.php
+++ b/lib/public/activity/iextension.php
@@ -38,6 +38,8 @@ namespace OCP\Activity;
* @since 8.0.0
*/
interface IExtension {
+ const METHOD_STREAM = 'stream';
+ const METHOD_MAIL = 'email';
const PRIORITY_VERYLOW = 10;
const PRIORITY_LOW = 20;
@@ -50,8 +52,13 @@ interface IExtension {
* If no additional types are to be added false is to be returned
*
* @param string $languageCode
- * @return array|false
+ * @return array|false Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [self::METHOD_*],
+ * ]
* @since 8.0.0
+ * @changed 8.2.0 - Added support to allow limiting notifications to certain methods
*/
public function getNotificationTypes($languageCode);
diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php
index cadb37da03b..0f5dccd8ba1 100644
--- a/lib/public/activity/imanager.php
+++ b/lib/public/activity/imanager.php
@@ -81,9 +81,15 @@ interface IManager {
/**
* Will return additional notification types as specified by other apps
+ *
* @param string $languageCode
- * @return array
+ * @return array Array "stringID of the type" => "translated string description for the setting"
+ * or Array "stringID of the type" => [
+ * 'desc' => "translated string description for the setting"
+ * 'methods' => [\OCP\Activity\IExtension::METHOD_*],
+ * ]
* @since 8.0.0
+ * @changed 8.2.0 - Added support to allow limiting notifications to certain methods
*/
function getNotificationTypes($languageCode);