-
Notifications
You must be signed in to change notification settings - Fork 174
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
Hide social sync option if social sync is not available #2913
Open
pboguslawski
wants to merge
5
commits into
nextcloud:main
Choose a base branch
from
ibpl:main-IB#1125033
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−12
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8a84821
Hide social sync option if social sync is not available
pboguslawski 3aaf6ef
Linting fixed
pboguslawski 2b3d45e
Merge main into main-IB#1125033
pboguslawski 8f9d697
Update src/components/AppNavigation/ContactsSettings.vue
pboguslawski b741dd6
Update ContactsSettings.vue
pboguslawski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2018 John Molakvoæ <[email protected]> | ||
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ | ||
* | ||
* @author John Molakvoæ <[email protected]> | ||
* @author Matthias Heinisch <[email protected]> | ||
|
@@ -96,8 +97,9 @@ public function index(): TemplateResponse { | |
$defaultProfile = $this->config->getAppValue(Application::APP_ID, 'defaultProfile', 'HOME'); | ||
|
||
$supportedNetworks = $this->socialApiService->getSupportedNetworks(); | ||
// allow users to retrieve avatars from social networks (default: yes) | ||
$syncAllowedByAdmin = $this->config->getAppValue(Application::APP_ID, 'allowSocialSync', 'yes'); | ||
// Allow users to retrieve avatars from social networks (default: yes). Disabled if internet connection is not available. | ||
$syncAllowedByAdmin = (($this->config->getAppValue(Application::APP_ID, 'allowSocialSync', 'yes') === 'yes') | ||
&& $this->config->getSystemValueBool('has_internet_connection', true)) ? 'yes' : 'no'; | ||
// automated background syncs for social avatars (default: no) | ||
$bgSyncEnabledByUser = $this->config->getUserValue($userId, Application::APP_ID, 'enableSocialSync', 'no'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
/** | ||
* @copyright 2017 Georg Ehrke <[email protected]> | ||
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
|
@@ -84,9 +85,9 @@ public function __construct( | |
*/ | ||
protected function run($arguments) { | ||
|
||
// check if admin allows for social updates: | ||
$syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); | ||
if (!($syncAllowedByAdmin === 'yes')) { | ||
// Social updates must be enabled by admin and internet connection must be available. | ||
if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') | ||
|| !$this->config->getSystemValueBool('has_internet_connection', true)) { | ||
return; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
/** | ||
* @copyright Copyright (c) 2020 Matthias Heinisch <[email protected]> | ||
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ | ||
* | ||
* @author Matthias Heinisch <[email protected]> | ||
* | ||
|
@@ -92,8 +93,9 @@ public function __construct( | |
* @return {array} array of the supported social networks | ||
*/ | ||
public function getSupportedNetworks() : array { | ||
$syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); | ||
if ($syncAllowedByAdmin !== 'yes') { | ||
// Check if admin allows for social updates and internet connection is available. | ||
if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') | ||
|| !$this->config->getSystemValueBool('has_internet_connection', true)) { | ||
return []; | ||
} | ||
return $this->socialProvider->getSupportedNetworks(); | ||
|
@@ -369,10 +371,10 @@ protected function sortContacts(array $a, array $b) { | |
*/ | ||
public function updateAddressbooks(string $userId, string $offsetBook = null, string $offsetContact = null, string $network = null) : JSONResponse { | ||
|
||
// double check! | ||
$syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); | ||
$bgSyncEnabledByUser = $this->config->getUserValue($userId, $this->appName, 'enableSocialSync', 'no'); | ||
if (($syncAllowedByAdmin !== 'yes') || ($bgSyncEnabledByUser !== 'yes')) { | ||
// Forbid if social sync is disabled by admin or by user or no internet connection is available. | ||
if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') | ||
|| ($this->config->getUserValue($userId, $this->appName, 'enableSocialSync', 'no') !== 'yes') | ||
|| !$this->config->getSystemValueBool('has_internet_connection', true)) { | ||
return new JSONResponse([], Http::STATUS_FORBIDDEN); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2022 Julia Kirschenheuter <[email protected]> | ||
pboguslawski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ | ||
- | ||
- @author Julia Kirschenheuter <[email protected]> | ||
- | ||
|
@@ -26,7 +27,8 @@ | |
:show-navigation="true" | ||
:open.sync="showSettings"> | ||
<AppSettingsSection id="general-settings" :title="t('contacts', 'General settings')"> | ||
<CheckboxRadioSwitch :checked="enableSocialSync" | ||
<CheckboxRadioSwitch v-if="allowSocialSync" | ||
:checked="enableSocialSync" | ||
:loading="enableSocialSyncLoading" | ||
:disabled="enableSocialSyncLoading" | ||
class="social-sync__checkbox contacts-settings-modal__form__row" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triple copyright and no https? 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md