-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add OCS sharing info to capabilities #13692
Conversation
I wonder if this should be in core instead. Some of these settings apply to sharing in general and might affect calendar/contacts. CC @schiesbn @icewind1991 @MorrisJobke for additional feedback |
I wonder if we should also expose the other settings that enforce the date to be only within a given number of days. This way clients could also enforce it that way. Disclosing too much isn't always a good thing, isn't it @LukasReschke ? |
Forgot to say: thanks a lot for your PR 😄 |
as defined in the contribution guidelines - we require unit test - see b533aad#diff-6a3371457528722a734f3c51d9238c13 Therefore I'd welcome to have the capabilities class not static where an instance to the config object is injected via the ctor. Feel free to ping me in case of questions. |
indeed - thanks a lot! I tend to forget this as well! Much appreciated! |
$config = \OC::$server->getConfig(); | ||
|
||
$res = array(); | ||
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === "yes") { |
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.
please use single quotes
@DeepDiver1975 I'm afraid it might not be possible to make this class non-static / make it use the app framework because it uses a special feature of the OCS routine that merges the responses together, gathered from multiple apps. Something to be considered as part of #12454 It might be possible to mock the config currently using static injection (static setConfig() method) or by replacing the service with a mock (see https://github.com/owncloud/core/blob/master/tests/lib/app.php#L493) Or do you guys have a better idea ? |
there is a way to make this work class Capabilities {
public static function getCapabilities() {
$config = \OC::$server->getConfig();
$cap = new Capabilities($config);
return $cap->getCaps();
}
public function getCaps() {
$res = array();
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === "yes") {
$res["allow_links"] = true;
/* ..... */
}
return new \OC_OCS_Result(/* ... */);
}
}
} |
@DeepDiver1975 unit tests are on the way, however why should the class be non static for that? |
to break the dependencies between objects - you want to test the class Capabilities and not the class Config. Therefore a test double/mock is to be injected. |
This fixes #13673. It now lists link sharing, passwords enforced, and if public uploads are allowed.
If I have time this evening I'll split up the unit test so each funtion tests once case. @PVince81 any update on where this should be placed? I get your concern about those settings not being limit to files sharing. However where should they go then? Extending the PR to include default expire stuff. Resharing etc. Is easy. Probably there is not really a thing as to much sharing since it is only available for users anyway. |
public function getCaps() { | ||
$res = array(); | ||
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { | ||
$res['allow_links'] = true; |
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.
I was thinking a bit more about this and from my understanding it would be better to also add false in case a capability is not available. Makes it easier from an api usage pov.
Furthermore I'd like to come up with a naming scheme to be used for the capabilities.
More an OO style of naming like
sharing.allow-links .... still thinking about this
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.
Sure that easy enough to do. I'll add that to my list.
I agree the naming is not ideal. So suggestions are welcome.
Moved to files_sharing Added more capabilities. Tried to order to capabilities more OO style
I pushed a new commit (I did not update the unit tests just yet). Now it basically has to following structure:
So an element it empty when set to false in json this looks better:
Anyway I think this structure looks better and is easier to understand. |
The inspection completed: 11 new issues, 20 updated code elements |
Refer to this link for build results (access rights to CI server needed): |
👍 |
👍 did pair testing with @karlitschek. |
Add OCS sharing info to capabilities
Furthermore that code follows not the coding practises and is missing appropriate PHPDoc which was requested by me in another PR – this PR was just not getting reviewed because it was scheduled for 8.1… |
public function getCaps() { | ||
$res = array(); | ||
|
||
$public = false;; |
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.
???
Mmm I was indeed not yet done with this PR. I'll try to fix them over the weekend. |
/** | ||
* Class Test_Files_Sharing_Capabilties | ||
*/ | ||
class Test_Files_Sharing_Capabilities extends \Test\TestCase { |
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.
Classname should be different. Those Test_
class names are legacy.
Please stop merging features so late before the release! Maybe I should have kept that OCS capability idea to myself and waited for after the release to raise it to avoid such happenings ? |
Please revert this - we did schedule this for 8.1! THX @karlitschek |
Patch for #13673