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

Remove notifications if article is unpublished #3362

Merged

Conversation

Zhao-Andy
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Bug Fix

Description

This fixes an issue where some notifications will linger if an article is published and then unpublished.

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jul 1, 2019
@@ -268,6 +267,15 @@ def article_params_json
params.require(:article).permit(allowed_params)
end

def handle_notifications(updated)
if updated && @article.published && @article.saved_changes["published"] == [false, true]
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the following be enough?

Suggested change
if updated && @article.published && @article.saved_changes["published"] == [false, true]
if updated && @article.saved_changes["published"] == [false, true]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah probably. I decided to keep the previous code and think it over. It's probably fine to change it though.

Notification.send_to_followers(@article, "Published")
elsif @article.saved_changes["published"] == [true, false]
Notification.remove_all_without_delay(notifiable_id: @article.id, notifiable_type: "Article", action: "Published")
Notification.remove_all(notifiable_id: @article.id, notifiable_type: "Article", action: "Reaction")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider also removing article's comment notification? I could be overthinking this.

Copy link
Contributor

@maestromac maestromac left a comment

Choose a reason for hiding this comment

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

LGTM!

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jul 1, 2019
if updated && @article.published && @article.saved_changes["published"] == [false, true]
Notification.send_to_followers(@article, "Published")
elsif @article.saved_changes["published"] == [true, false]
Notification.remove_all_without_delay(notifiable_id: @article.id, notifiable_type: "Article", action: "Published")
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me why removing "Published" notifications is synchronous and removing "Reaction" notifications is async 🤔

Copy link
Contributor Author

@Zhao-Andy Zhao-Andy Jul 2, 2019

Choose a reason for hiding this comment

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

@lightalloy The publish notifications contain the data of the article, and is sent to the followers. IMO those should be removed immediately since that data is revoked. The reaction notifications only belong to the author so I think it's okay of those are removed async.

I think based on how we handle reaction notifications though there's only one reaction notification for the article. So performance-wise it probably doesn't matter all that much. Ah never mind, I'm wrong about that, oops 🙈

@benhalpern benhalpern merged commit da224d5 into forem:master Jul 3, 2019
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jul 3, 2019
nicolas-amabile added a commit to nicolas-amabile/dev.to that referenced this pull request Jul 7, 2019
Fix for missing post_reaction_notifications on organizations

Allow full links for cache buster tool (forem#3378)

Rescue possible SSLError when fetching a podcast (forem#3374)

Add functionality to remove and recover identity (forem#3377)

* Lint some quotation marks

* Add BackupData table

* Add identity and removal functionality

* Test additional functionality

* Remove dependent destroy for backup data

* Add auth_data_dump column

* Add challenge to reserved words

* Add more shoulda matchers

Self-serve sponsorship options (forem#3371)

* WIP - Initial work on sponsorship landing page

* Add initial partnership page

Remove notifications if article is unpublished (forem#3362)

* Add tests for article notifications

* Remove notifications if unpublished and refactor

Moved creating a new podcast to a separate ActiveJob forem#2952 (forem#3373)

* Podcasts reachable status forem#2952

* Specs for podcasts statuses

* Moved podcast episode create to a separate ActiveJob

* Use RssItemData wrapper in GetEpisode for consistency

* Reorganize services/podcasts

Escape comment.title to fix failing spec (forem#3385)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants