Skip to content

Add OCS sharing info to capabilities - #13692

Merged
karlitschek merged 9 commits into
owncloud:masterfrom
rullzer:capabilities
Feb 6, 2015
Merged

karlitschek merged 9 commits into
owncloud:masterfrom
rullzer:capabilities

Conversation

@rullzer

@rullzer rullzer commented Jan 26, 2015

Copy link
Copy Markdown
Contributor

Patch for #13673

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Forgot to say: thanks a lot for your PR 😄

@DeepDiver1975

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Forgot to say: thanks a lot for your PR 😄

indeed - thanks a lot! I tend to forget this as well! Much appreciated!

Comment thread apps/files_sharing/lib/capabilities.php Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

rullzer commented Jan 27, 2015

Copy link
Copy Markdown
Contributor Author

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

@DeepDiver1975

Copy link
Copy Markdown
Contributor

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

rullzer commented Feb 4, 2015

Copy link
Copy Markdown
Contributor Author

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.

Comment thread apps/files_sharing/lib/capabilities.php Outdated

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

rullzer commented Feb 6, 2015

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

@ghost

ghost commented Feb 6, 2015

Copy link
Copy Markdown

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
Copy Markdown
Contributor

👍

@craigpg

craigpg commented Feb 6, 2015

Copy link
Copy Markdown

👍 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
Copy Markdown
Contributor

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

screen shot 2015-02-06 at 22 54 06

@LukasReschke

Copy link
Copy Markdown
Contributor

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…

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

@rullzer

rullzer commented Feb 6, 2015

Copy link
Copy Markdown
Contributor Author

Mmm I was indeed not yet done with this PR. I'll try to fix them over the weekend.

Copy link
Copy Markdown
Contributor

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

PVince81 commented Feb 6, 2015

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@LukasReschke

Copy link
Copy Markdown
Contributor

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