зеркало из https://github.com/nextcloud/activity.git
Return batchtime for when filtering the users for email
This commit is contained in:
Родитель
b07dffb5f9
Коммит
c1c5b944e8
|
@ -89,7 +89,6 @@ class Hooks {
|
|||
$filteredStreamUsers = self::filterUsersBySetting(array_keys($affectedUsers), 'stream', $activity_type);
|
||||
$filteredEmailUsers = self::filterUsersBySetting(array_keys($affectedUsers), 'email', $activity_type);
|
||||
|
||||
|
||||
foreach ($affectedUsers as $user => $path) {
|
||||
if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) {
|
||||
continue;
|
||||
|
@ -294,7 +293,8 @@ class Hooks {
|
|||
* @param array $users
|
||||
* @param string $method
|
||||
* @param string $type
|
||||
* @return array
|
||||
* @return array Returns a "username => b:true" Map for method = stream
|
||||
* Returns a "username => i:batchtime" Map for method = email
|
||||
*/
|
||||
public static function filterUsersBySetting($users, $method, $type) {
|
||||
if (empty($users) || !is_array($users)) return array();
|
||||
|
@ -328,12 +328,37 @@ class Hooks {
|
|||
}
|
||||
}
|
||||
|
||||
// Get the batch time setting from the database
|
||||
if ($method == 'email') {
|
||||
$chunkedFilteredUsers = array_chunk(array_keys($filteredUsers), 50);
|
||||
foreach ($chunkedFilteredUsers as $chunk) {
|
||||
$placeholders = (sizeof($chunk) == 50) ? $placeholders_50 : implode(',', array_fill(0, sizeof($chunk), '?'));
|
||||
|
||||
$query = \OCP\DB::prepare(
|
||||
'SELECT `userid`, `configvalue` '
|
||||
. ' FROM `*PREFIX*preferences` '
|
||||
. ' WHERE `appid` = ? AND `configkey` = ? AND `userid` IN (' . $placeholders . ')');
|
||||
$result = $query->execute(array_merge(array(
|
||||
'activity',
|
||||
'notify_setting_batchtime',
|
||||
), $chunk));
|
||||
|
||||
while ($row = $result->fetchRow()) {
|
||||
$filteredUsers[$row['userid']] = $row['configvalue'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($users)) {
|
||||
// If the setting is enabled by default,
|
||||
// we add all users that didn't set the preference yet.
|
||||
if (\OCA\Activity\Data::getUserDefaultSetting($method, $type)) {
|
||||
foreach ($users as $user) {
|
||||
$filteredUsers[$user] = true;
|
||||
if ($method == 'stream') {
|
||||
$filteredUsers[$user] = true;
|
||||
} else {
|
||||
$filteredUsers[$user] = \OCA\Activity\Data::getUserDefaultSetting('setting', 'batchtime');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче