Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New circles are treated as an "all user" activity - but no option for this being on/off #204 #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ var elements = {
// test_async_wait: null,
members_limit: null,
allow_linked_groups: null,
allow_federated_circles: null
allow_federated_circles: null,
disable_notification_for_seen_users: null
};


Expand All @@ -46,6 +47,7 @@ $(document).ready(function () {
elements.members_limit = $('#members_limit');
elements.allow_linked_groups = $('#allow_linked_groups');
elements.allow_federated_circles = $('#allow_federated_circles');
elements.disable_notification_for_seen_users = $('#disable_notification_for_seen_users');

// elements.test_async_wait.hide().on('click', function () {
// self.refreshResult();
Expand Down Expand Up @@ -81,6 +83,10 @@ $(document).ready(function () {
elements.allow_federated_circles.on('change', function () {
saveChange();
});

elements.disable_notification_for_seen_users.on('change', function () {
saveChange();
});

saveChange = function () {
$.ajax({
Expand All @@ -91,12 +97,15 @@ $(document).ready(function () {
allow_linked_groups: (elements.allow_linked_groups.is(
':checked')) ? '1' : '0',
allow_federated_circles: (elements.allow_federated_circles.is(
':checked')) ? '1' : '0',
disable_notification_for_seen_users: (elements.disable_notification_for_seen_users.is(
':checked')) ? '1' : '0'
}
}).done(function (res) {
elements.members_limit.val(res.membersLimit);
elements.allow_linked_groups.prop('checked', (res.allowLinkedGroups === '1'));
elements.allow_federated_circles.prop('checked', (res.allowFederatedCircles === '1'));
elements.disable_notification_for_seen_users.prop('checked', (res.disableNotificationForSeenUsers === '1'));
});
};

Expand Down
6 changes: 5 additions & 1 deletion js/circles.app.elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ var elements = {
settingsName: null,
settingsDesc: null,
settingsLimit: null,
settingsEntryLimit: null,
settingsEntryLimit: null,
settingsLink: null,
settingsLinkAuto: null,
settingsLinkFiles: null,
settingsNotification: null,
settingsEntryLink: null,
settingsEntryLinkAuto: null,
settingsEntryLinkFiles: null,
settingsEntryNotification: null,
settingsSave: null,

addMember: null,
Expand Down Expand Up @@ -139,9 +141,11 @@ var elements = {
elements.settingsLink = $('#settings-link');
elements.settingsLinkAuto = $('#settings-link-auto');
elements.settingsLinkFiles = $('#settings-link-files');
elements.settingsNotification = $('#settings-notification');
elements.settingsEntryLink = $('#settings-entry-link');
elements.settingsEntryLinkAuto = $('#settings-entry-link-auto');
elements.settingsEntryLinkFiles = $('#settings-entry-link-files');
elements.settingsEntryNotification = $('#settings-entry-notification');
elements.settingsSave = $('#settings-submit');

elements.addMember = $('#addmember');
Expand Down
1 change: 1 addition & 0 deletions js/circles.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var curr = {
allowed_linked_groups: 0,
allowed_federated_circles: 0,
allowed_circles: 0,
disabled_notification_for_seen_users: 0,

defineCircle: function (data) {
curr.circle = data.circle_id;
Expand Down
4 changes: 4 additions & 0 deletions js/circles.app.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ var settings = {
(curr.circleSettings['allow_links_auto'] === 'true'));
elements.settingsLinkFiles.prop('checked',
(curr.circleSettings['allow_links_files'] === 'true'));
elements.settingsNotification.prop('checked',
(curr.circleSettings['disable_notification_for_seen_users'] === 'true'));

elements.settingsLink.on('change', function () {
settings.interactUISettings();
Expand All @@ -86,6 +88,8 @@ var settings = {
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryLinkFiles, elements.settingsLinkFiles,
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryNotification, elements.settingsNotification,
(elements.settingsNotification.is(":checked")));
},

enableSetting: function (entry, input, enable) {
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function settings() {
'members_list' => $this->configService->getAppValue(ConfigService::CIRCLES_MEMBERS_LIMIT),
'allowed_linked_groups' => $this->configService->getAppValue(ConfigService::CIRCLES_ALLOW_LINKED_GROUPS),
'allowed_federated_circles' => $this->configService->getAppValue(ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES),
'disabled_notification_for_seen_users' => $this->configService->getAppValue(ConfigService::CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS),
'status' => 1
];

Expand Down
8 changes: 7 additions & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ public function getSettings() {
),
'allowFederatedCircles' => $this->configService->getAppValue(
ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES
),
'disableNotificationForSeenUsers' => $this->configService->getAppValue(
ConfigService::CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS
)
];

return $params;
}


public function setSettings($members_limit, $allow_linked_groups, $allow_federated_circles) {
public function setSettings($members_limit, $allow_linked_groups, $allow_federated_circles, $disable_notification_for_seen_users) {
$this->configService->setAppValue(
ConfigService::CIRCLES_MEMBERS_LIMIT, $members_limit
);
Expand All @@ -65,6 +68,9 @@ public function setSettings($members_limit, $allow_linked_groups, $allow_federat
$this->configService->setAppValue(
ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES, $allow_federated_circles
);
$this->configService->setAppValue(
ConfigService::CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS, $disable_notification_for_seen_users
);

return $this->getSettings();
}
Expand Down
18 changes: 17 additions & 1 deletion lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ConfigService {
const CIRCLES_ALLOW_LINKED_GROUPS = 'allow_linked_groups';
const CIRCLES_ALLOW_NON_SSL_LINKS = 'allow_non_ssl_links';
const CIRCLES_NON_SSL_LOCAL = 'local_is_non_ssl';
const CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS = 'disable_notification_for_seen_users';

const CIRCLES_TEST_ASYNC_LOCK = 'test_async_lock';
const CIRCLES_TEST_ASYNC_INIT = 'test_async_init';
Expand All @@ -55,7 +56,8 @@ class ConfigService {
self::CIRCLES_ALLOW_LINKED_GROUPS => '0',
self::CIRCLES_ALLOW_FEDERATED_CIRCLES => '0',
self::CIRCLES_ALLOW_NON_SSL_LINKS => '0',
self::CIRCLES_NON_SSL_LOCAL => '0'
self::CIRCLES_NON_SSL_LOCAL => '0',
self::CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS => '0',
];

/** @var string */
Expand Down Expand Up @@ -87,6 +89,9 @@ class ConfigService {

/** @var int */
private $localNonSSL = -1;

/** @var int */
private $disabledNotificationForSeenUsers = -1;

/**
* ConfigService constructor.
Expand Down Expand Up @@ -181,6 +186,17 @@ public function isNonSSLLinksAllowed() {
return ($this->allowedNonSSLLinks === 1);
}

/**
* @return bool
*/
public function isDisabledNotificationForSeenUsers() {
if ($this->disabledNotificationForSeenUsers === -1) {
$this->disabledNotificationForSeenUsers =
(int)$this->getAppValue(self::CIRCLES_DISABLE_NOTIFICATION_FOR_SEEN_USERS);
}

return ($this->disabledNotificationForSeenUsers === 1);
}

/**
* @param string $remote
Expand Down
27 changes: 17 additions & 10 deletions lib/Service/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,29 @@ public function __construct(
* @param Circle $circle
*/
public function onCircleCreation(Circle $circle) {
$event = $this->generateEvent('circles_as_member');
$event->setSubject('circle_create', ['circle' => json_encode($circle)]);

if ($circle->getType() !== Circle::CIRCLES_PUBLIC
&& $circle->getType() !== Circle::CIRCLES_CLOSED
) {
$this->publishEvent($event, [\OC::$server->getUserSession()->getUser()]);
$this->dispatch('\OCA\Circles::onCircleCreation', ['circle' => $circle]);
return;
}

$event = $this->generateEvent('circles_as_member');
$event->setSubject('circle_create', ['circle' => json_encode($circle)]);

$this->userManager->callForSeenUsers(
function($user) use ($event) {
/** @var IUser $user */
$this->publishEvent($event, [$user]);
}
);

$disableNotificationForSeenUsers = \OC::$server->getAppConfig()->getValue('circles', 'disable_notification_for_seen_users', false);
if ($disableNotificationForSeenUsers) {
$this->publishEvent($event, [\OC::$server->getUserSession()->getUser()]);
} else {
$this->userManager->callForSeenUsers(
function($user) use ($event) {
/** @var IUser $user */
$this->publishEvent($event, [$user]);
}
);
}

$this->dispatch('\OCA\Circles::onCircleCreation', ['circle' => $circle]);
}

Expand Down
5 changes: 5 additions & 0 deletions templates/navigate.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@
</td>
<td><input type="checkbox" value="1" id="settings-link-auto"></td>
</tr>
<tr id="settings-entry-notification">
<td class="left"><?php p($l->t('Disable notification for seen users.')); ?>
</td>
<td><input type="checkbox" value="0" id="settings-notification"></td>
</tr>

<tr>
<td colspan="2" style="text-align: center;">
Expand Down
5 changes: 5 additions & 0 deletions templates/settings.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@
<label for="allow_federated_circles"><?php p($l->t('Allow federated circles')); ?></label>
<em><?php p($l->t('Circles from different Nextclouds can be linked together.')); ?></em>
</p>
<p>
<input type="checkbox" value="0" id="disable_notification_for_seen_users" class="checkbox"/>
<label for="disable_notification_for_seen_users"><?php p($l->t('Disable notification for seen users.')); ?></label>
<em><?php p($l->t('Disable notification for seen users.')); ?></em>
</p>
</div>