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

feat(subscriptions): add option to send notifications when not caught up #3503

Merged
merged 19 commits into from
Aug 31, 2022

Conversation

davwheat
Copy link
Member

@davwheat davwheat commented Jul 6, 2022

Changes proposed in this pull request:

This PR adds a new configurable option to Flarum Subscriptions to allow the sending of notifications even when a user is not caught up to a discussion yet. This could be seen as a easier migration step from one forum software to another, where users are more used to receiving emails for all new posts, rather than just the first new one.

Due to the notification subject for subscriptions being the discussion itself rather than the post, notifications in the frontend are still grouped into one single notification, so this change really only affects emails. Changing the subject would be a breaking change, though, as would introducing a new notification which replaces the old one.

Reviewers should focus on:

This should retain existing behaviour by default, using the memory-based settings defaults.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

@davwheat davwheat added this to the 1.4 milestone Jul 6, 2022
@davwheat davwheat requested a review from SychO9 July 6, 2022 20:06
@davwheat davwheat self-assigned this Jul 6, 2022
@davwheat davwheat changed the title feat: add subscriptions option send notifications when not caught up feat(subscriptions): add option to send notifications when not caught up Jul 6, 2022
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Looks good, two thoughts though:

  • I think when it comes to notification behavior it might be better to introduce this as a user preference instead of a global admin setting.
  • dont_notify_unless_caught_up (and the locale value) is hard to understand unless you read further or look at the code. Could we change it to notify_first_new_unread_post_only (and the locale text) ?

extensions/subscriptions/src/Job/SendReplyNotification.php Outdated Show resolved Hide resolved
@SychO9 SychO9 modified the milestones: 1.4, 1.5 Jul 7, 2022
@davwheat davwheat force-pushed the dw/allow-multiple-notifs-per-discuss branch from 53f8b70 to f1b7c9c Compare July 10, 2022 14:01
@davwheat
Copy link
Member Author

This code is rather... interesting.

I'm not sure how to go about doing validation for user preferences -- if I could be pointed in the right direction, I'd appreciate that.

I also think my DB queries might not be very performant for large communities. Will seek feedback on that from some others. If that's the case, it might be wise adding a new column on the users table to store this preference, thus allowing all the new logic in the PHP to be moved to part of the DB query instead.

The code does all work, though, it's just not that great. 😅

@davwheat
Copy link
Member Author

I think the best option is to either move the criteria option to a column on the user table, or a new table with a FK. A new col on the users table would not be a very performant migration for very large communities, though.

@luceos luceos self-requested a review July 11, 2022 08:41
@SychO9 SychO9 self-requested a review July 11, 2022 13:18
@luceos
Copy link
Member

luceos commented Jul 25, 2022

I've looked at this PR again to see whether we should "just do it", but when I'm looking at the logic to match preference to see whom to send notifications to I can only cringe. This logic seems overly convoluted and confusing. I know this isn't really a great PR review comment, sorry about that. We are all doing our best to find solutions to things that are (much) requested, but I'm unsure that this is the right approach.

This request almost warrants a completely different implementation for handling subscriptions and notifications..

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

This logic seems overly convoluted and confusing.

Our preferences system really needs a bit of a refactor. Storing them in a column is not flexible.

I think the complication lies in the: preference vs admin default vs admin enforcement. I don't think admin enforcement here is really necessary. I think we should also drop the admin default for a better admin default user preferences system in the future which would integrate seamlessly with reading user preferences.

That would probably cut down on the complexity.

@davwheat davwheat force-pushed the dw/allow-multiple-notifs-per-discuss branch from 81abf24 to 7a29602 Compare August 15, 2022 21:11
@davwheat davwheat requested a review from SychO9 August 21, 2022 14:18
SychO9 added 2 commits August 22, 2022 22:43
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of comments, and I took the liberty to push integration tests.

extensions/subscriptions/locale/en.yml Outdated Show resolved Hide resolved
extensions/subscriptions/locale/en.yml Show resolved Hide resolved
@davwheat
Copy link
Member Author

what are you referring to I'm not following 🤔

At the bottom of the email translation, it says that the user won't be notified for new.replies until the thread has been read. That needs to be removed based on user prefs.

@SychO9
Copy link
Member

SychO9 commented Aug 22, 2022

what are you referring to I'm not following thinking

At the bottom of the email translation, it says that the user won't be notified for new.replies until the thread has been read. That needs to be removed based on user prefs.

oh, yea I see it now, I don't think we can do a per preference phrase, the blueprint specifies the same email body to all users, it isn't aware of individual ones, so we can only try to tweak the wording of the email maybe so that it hints to preferences?

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

One last thing, the UI needs tobe consistent, the option should go under Automatically follow discussions that I reply to, we can do that in addSubscriptionSettings() instead without adding a new section in user settings.

@davwheat davwheat requested a review from SychO9 August 30, 2022 17:23
@davwheat
Copy link
Member Author

lets try that again...

davwheat and others added 3 commits August 30, 2022 20:37
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
@davwheat davwheat merged commit 87aaaf6 into main Aug 31, 2022
@davwheat davwheat deleted the dw/allow-multiple-notifs-per-discuss branch August 31, 2022 09:13
@luceos luceos mentioned this pull request Sep 8, 2022
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.

4 participants