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

Add OCS sharing info to capabilities #13692

Merged
merged 9 commits into from
Feb 6, 2015
Merged

Add OCS sharing info to capabilities #13692

merged 9 commits into from
Feb 6, 2015

Conversation

rullzer
Copy link
Contributor

@rullzer rullzer commented Jan 26, 2015

Patch for #13673

@PVince81 PVince81 added this to the 8.1-next milestone Jan 26, 2015
@PVince81
Copy link
Contributor

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

@PVince81
Copy link
Contributor

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.
On the other hand this could be done through validation.

Disclosing too much isn't always a good thing, isn't it @LukasReschke ?

@PVince81
Copy link
Contributor

Forgot to say: thanks a lot for your PR 😄

@DeepDiver1975
Copy link
Member

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.

@DeepDiver1975
Copy link
Member

Forgot to say: thanks a lot for your PR 😄

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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use single quotes

@PVince81
Copy link
Contributor

@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 ?

@DeepDiver1975
Copy link
Member

I'm afraid it might not be possible to make this class non-static

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(/* ... */);
    }
    }
}

@rullzer
Copy link
Contributor Author

rullzer commented Jan 27, 2015

@DeepDiver1975 unit tests are on the way, however why should the class be non static for that?

@DeepDiver1975
Copy link
Member

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.

@rullzer
Copy link
Contributor Author

rullzer commented Feb 4, 2015

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;
Copy link
Member

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

Copy link
Contributor Author

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
@rullzer
Copy link
Contributor Author

rullzer commented Feb 6, 2015

I pushed a new commit (I did not update the unit tests just yet).

Now it basically has to following structure:

<files_sharing>
    <public>
        <password_enforced>1</password_enforced>
        <expire_date>
            <days>7</days>
            <enforce></enforce>
        </expire_date>
        <send_mail>1</send_mail>
    </public>
    <user>
        <send_mail>1</send_mail>
    </user>
    <resharing>1</resharing>
</files_sharing>

So an element it empty when set to false in json this looks better:

            "files_sharing":{
                "public":{
                    "password_enforced":true,
                    "expire_date":{
                        "days":"7",
                        "enforce":false
                    },
                    "send_mail":true
                },
                "user":{
                    "send_mail":true
                },
                "resharing":true
            }

Anyway I think this structure looks better and is easier to understand.
Any comments or suggestions? Else I'll start editing the unit tests.

@scrutinizer-notifier
Copy link

The inspection completed: 11 new issues, 20 updated code elements

@ghost
Copy link

ghost commented Feb 6, 2015

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/8896/
Test PASSed.

@karlitschek
Copy link
Contributor

👍

@craigpg
Copy link

craigpg commented Feb 6, 2015

👍 did pair testing with @karlitschek.

karlitschek added a commit that referenced this pull request Feb 6, 2015
Add OCS sharing info to capabilities
@karlitschek karlitschek merged commit 0b421e8 into owncloud:master Feb 6, 2015
@LukasReschke
Copy link
Member

Please adjust at least the milestone when merging such critical bug fixes…

screen shot 2015-02-06 at 22 54 06

@LukasReschke
Copy link
Member

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;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

@rullzer
Copy link
Contributor Author

rullzer commented Feb 6, 2015

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 {
Copy link
Member

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.

@PVince81
Copy link
Contributor

PVince81 commented Feb 6, 2015

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 ?

@DeepDiver1975
Copy link
Member

Please revert this - we did schedule this for 8.1! THX @karlitschek

@LukasReschke
Copy link
Member

Reverted with c8e8456

@rullzer Sorry for the trouble. Can I ask you to reopen a new PR for this? Thanks a lot!

@MorrisJobke MorrisJobke removed this from the 8.1-next milestone Feb 17, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants