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

Customize presentation of accept/decline buttons in iMip mail #12392

Merged
merged 7 commits into from
Aug 15, 2019
Merged

Customize presentation of accept/decline buttons in iMip mail #12392

merged 7 commits into from
Aug 15, 2019

Conversation

brad2014
Copy link
Contributor

Signed-off-by: Brad Rubenstein brad@wbr.tech

@brad2014 brad2014 requested a review from georgehrke November 10, 2018 11:54
* 'dav.invitation_link_recipients' => false,
*
*/
'dav.invitation_link_recipients' => '*', // always include accept/reject server links in iMip emails
Copy link
Contributor

Choose a reason for hiding this comment

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

For nextcloud servers accessible to the public internet, the default
"dav.invitation_link_recipients" value "true" (all recipients) is appropriate.

I guess the default here should be true?

@brad2014
Copy link
Contributor Author

brad2014 commented Nov 10, 2018

💥 Yes, you are correct, thanks! 💥 Fixed.

@@ -144,11 +144,11 @@ public function schedule(Message $iTipMessage) {

$summary = $iTipMessage->message->VEVENT->SUMMARY;

if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') {
if (strcasecmp(parse_url($iTipMessage->sender, PHP_URL_SCHEME), 'mailto') !== 0) {
Copy link
Contributor Author

@brad2014 brad2014 Nov 10, 2018

Choose a reason for hiding this comment

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

Note: One more place where mailto scheme comparison should be case insensitive (if the event contained MAILTO, then it would not have properly been detected). This is related to the fix nextcloud/calendar@82fc0a9 by @georgehrke.

@brad2014 brad2014 self-assigned this Nov 12, 2018
@brad2014
Copy link
Contributor Author

Another note: It occurs to me that RFC5545 defaults ATTENDEE rsvpparm to RSVP=FALSE. Perhaps the invite buttons should only be presented when (a) the attendee has a mailto, and (b) the method is REQUEST, and (c) RSVP=TRUE. (The examples in the RFC suggest it would be set false for optional attendees and non-individuals, e.g. resources). The code does not currently look at the RSVP parameter, as far as I can tell. May I ask @georgehrke or @MorrisJobke for advice? I'm happy to put it in if it seems the right thing to do.

@MorrisJobke MorrisJobke added this to the Nextcloud 16 milestone Nov 12, 2018
@MorrisJobke MorrisJobke added enhancement 3. to review Waiting for reviews labels Nov 12, 2018
@georgehrke
Copy link
Member

Hi @brad2014,

Thx for your pull-request!
Can you please add unit-tests for your changes?

Perhaps the invite buttons should only be presented when (a) the attendee has a mailto,

If the attendee doesn't have a mailto, we can't send this email anyway, so that's already the case.

the method is REQUEST

Will be done by this pull-request, correct?

The code does not currently look at the RSVP parameter, as far as I can tell

Most of this is not done in Nextcloud directly, but in Sabre/Dav.
But skimming over https://github.com/nextcloud/3rdparty/blob/214c4155f587f5178d792fe4a839044bdc9982f1/sabre/vobject/lib/ITip/Broker.php this doesn't seem to be the case indeed.

@brad2014 brad2014 requested a review from rullzer November 12, 2018 16:29
@brad2014
Copy link
Contributor Author

brad2014 commented Nov 12, 2018

Most of this is not done in Nextcloud directly, but in Sabre/Dav.
But skimming over https://github.com/nextcloud/3rdparty/blob/214c4155f587f5178d792fe4a839044bdc9982f1/sabre/vobject/lib/ITip/Broker.php this doesn't seem to be the case indeed.

My notes: The sabre ITip code properly passes the client's RSVP parameter through unchanged, except when processing an incoming reply (to remove the RSVP=TRUE parameter when an RSVP has been received). Other than that, it is up to the client to decide when RSVP's are desired (e.g. apps/calendar (at the UI) or server/dav (by nextcloud policy) chooses whether rsvp's are desired from "required" or "optional" participants, and, on the other end, the server/dav/lib/CalDAV/Schedule/IMipPlugin.php must decide what to present in emails when the organizer (or nextcloud by policy) has set RSVP to true or false when they created the event that generates the REQUEST.

@brad2014
Copy link
Contributor Author

Thx for your pull-request!
Can you please add unit-tests for your changes?

I need to learn how to use phpUnit. :-)

I'll look for a doc that tells me how to set up my local machine to run nextcloud tests (pointers welcome).

@brad2014
Copy link
Contributor Author

@georgehrke or @MorrisJobke : I'm looking at the existing tests, to find a model for a new unit test, and I think I need some guidance. I'm not sure where to ask, so I'll ask here. I hope you don't mind.

  1. I read unit testing. I thought I'd first try to get testing working. On a clean Fedora-28 VM with the nextcloud dependencies installed, and the latest phpunit. But when I run ./autotest.sh, I get
$ ./autotest.sh
Using PHP executable /usr/bin/php
PHP Warning:  require_once(/vagrant/server/3rdparty/autoload.php): failed to open stream: No such file or directory in /vagrant/server/build/OCPSinceChecker.php on line 23
PHP Fatal error:  require_once(): Failed opening required '/vagrant/server/3rdparty/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /vagrant/server/build/OCPSinceChecker.php on line 23

What am I missing?

  1. Any suggestions on how to make a unit test for this or where to put it in the tree? Are there any existing caldav tests I can use for a model?

@MorrisJobke
Copy link
Member

What am I missing?

Did you ran git submodule update --init to initialize the 3rdparty git submodule?

@brad2014
Copy link
Contributor Author

Thanks.

Did you ran git submodule update --init to initialize the 3rdparty git submodule?

Thanks. Not sure how I missed it - the docs are clear.

@brad2014
Copy link
Contributor Author

1. Any suggestions on how to make a unit test for this or where to put it in the tree?  Are there any existing caldav tests I can use for a model?

I think I've figured it out. I will write some unit tests shortly.

Brad Rubenstein added 6 commits February 28, 2019 01:41
Fix Issue #11230
Only present accept/decline button links in iMip mail for REQUEST, not CANCEL or others.

Fix Issue #12156
Implement config setting "dav.invitation_link_recipients", to control
which invitation recipients see accept/decline button links.  The
default, for public internet facing servers, is to always include
them.  For a server on a private intranet, this setting can be set
to the email addresses or email domains of users whose browsers can
access the nextcloud server referenced by those accept/decline
button links. It can also be set to "false" to exclude the links
from all requests.

Signed-off-by: Brad Rubenstein <brad@wbr.tech>
Signed-off-by: Brad Rubenstein <brad@wbr.tech>
If RSVP=TRUE parameter is FALSE or absent for an ATTENDEE, then do no
present accept/decline buttons. The organizer isn't asking for an RSVP.

Signed-off-by: Brad Rubenstein <brad@wbr.tech>
My oops.  The comparisons, which are copied from the IMipPlugin shipped with sabre-io/dav,
do not need to be case insensitive because the sender and recipient names are normalized by sabre,
(see calls to getNormalizedValue in voboject/lib/ITip/Broker.php).

Signed-off-by: Brad Rubenstein <brad@wbr.tech>
Existing tests required modification to correctly mock up the new config
parameter fetch, and to set the RSVP flag for attendees (since the test
was detecting token generation, and we no longer generate tokens when
no RSVP is requested by the client or sent by nextcloud).

Signed-off-by: Brad Rubenstein <brad@wbr.tech>
Signed-off-by: Brad Rubenstein <brad@wbr.tech>
@brad2014
Copy link
Contributor Author

brad2014 commented Feb 28, 2019

@georgehrke, I have added unit tests per your suggestion - In the server-generated iMIP email, I'm using link token generation as a surrogate for whether buttons and links are added (the test doesn't actually look at the generated HTML - perhaps it should).

I also did the following:

  1. Rebased my changes (trivially) to the top of the master branch.
  2. Moved all the repeated in apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php into a phpUnit setUp function. The minimal change to the test file (to add the new tests and fix the old ones) is 1dbda26, and the refactor follows in 1a29239. (It is 43% DRYer)

The tests pass, I should add, pass 😄.

@brad2014
Copy link
Contributor Author

[This is my first pull request for nextcloud - if you all have any suggestions or concerns about my code or process, I'm very interested in hearing them.]

@MorrisJobke MorrisJobke mentioned this pull request Mar 4, 2019
45 tasks
@MorrisJobke
Copy link
Member

Hi @brad2014 - sorry that we didn't had time to look into this for the Nextcloud 16 milestone. We were quite busy with other tasks. We still appreciate the work you put into this, but the freeze for Nextcloud 16 is active since last Friday and I will put this into the Nextcloud 17 bucket. I hope that is okay for you.

@MorrisJobke MorrisJobke mentioned this pull request Jul 17, 2019
28 tasks
@brad2014 brad2014 requested review from georgehrke and kesselb July 18, 2019 00:49
Per @georgehrke change request for PR #12392, instead of setting
dav.invitation_link_recipients in the system config.php file, we
set it in the database table oc_appconfig.

Furthermore, the value of the config variable is always a string:
'yes' to include links in imip mail, 'no' to exclude them, or a
comma-separated list of email addresses and/or domains for which
they should be included.  If not specified in oc_appconfig, the
default is 'yes'.

Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
@brad2014
Copy link
Contributor Author

@georgehrke I have addressed all your review comments on the branch, but I'm not sure if the next step is for me to do something to remove the "Changes Requested" blocker, or if that's something you do after additional review. Please advise. Thank you!

@georgehrke
Copy link
Member

@brad2014 The changes requested blocker will go after another review. It's already late in Germany, but i will look into this first thing tomorrow morning. :)

@brad2014
Copy link
Contributor Author

Thank you (didn't mean to rush anyone, just wasn't sure if I needed to do anything).

Copy link
Member

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

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

👍

Let me check why CI didn't start

georgehrke pushed a commit that referenced this pull request Aug 1, 2019
Per @georgehrke change request for PR #12392, instead of setting
dav.invitation_link_recipients in the system config.php file, we
set it in the database table oc_appconfig.

Furthermore, the value of the config variable is always a string:
'yes' to include links in imip mail, 'no' to exclude them, or a
comma-separated list of email addresses and/or domains for which
they should be included.  If not specified in oc_appconfig, the
default is 'yes'.

Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
@georgehrke
Copy link
Member

georgehrke pushed a commit that referenced this pull request Aug 1, 2019
Per @georgehrke change request for PR #12392, instead of setting
dav.invitation_link_recipients in the system config.php file, we
set it in the database table oc_appconfig.

Furthermore, the value of the config variable is always a string:
'yes' to include links in imip mail, 'no' to exclude them, or a
comma-separated list of email addresses and/or domains for which
they should be included.  If not specified in oc_appconfig, the
default is 'yes'.

Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
@georgehrke
Copy link
Member

@georgehrke
Copy link
Member

please review @rullzer @juliushaertl @ChristophWurst :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants