Skip to content
Extraits de code Groupes Projets
Valider 69b46df3 rédigé par cmrd Senya's avatar cmrd Senya Validation de Jonne Haß
Parcourir les fichiers

Notifications for comments on local posts by non-contacts

parent dc02c538
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
## Bug fixes ## Bug fixes
* Redirect to sign in page when a background request fails with 401 [#6496](https://github.com/diaspora/diaspora/pull/6496) * Redirect to sign in page when a background request fails with 401 [#6496](https://github.com/diaspora/diaspora/pull/6496)
* Correctly skip setting sidekiq logfile on Heroku [#6500](https://github.com/diaspora/diaspora/pull/6500) * Correctly skip setting sidekiq logfile on Heroku [#6500](https://github.com/diaspora/diaspora/pull/6500)
* Fix notifications for interactions by non-contacts [#6498](https://github.com/diaspora/diaspora/pull/6498)
## Features ## Features
......
...@@ -94,6 +94,7 @@ class Comment < ActiveRecord::Base ...@@ -94,6 +94,7 @@ class Comment < ActiveRecord::Base
def initialize(person, target, text) def initialize(person, target, text)
@text = text @text = text
@dispatcher_opts = {additional_subscribers: target.comments_authors.where.not(id: person.id)}
super(person, target) super(person, target)
end end
......
...@@ -9,6 +9,7 @@ Feature: Notifications ...@@ -9,6 +9,7 @@ Feature: Notifications
| email | | email |
| bob@bob.bob | | bob@bob.bob |
| alice@alice.alice | | alice@alice.alice |
| carol@carol.carol |
Scenario: someone shares with me Scenario: someone shares with me
When I sign in as "bob@bob.bob" When I sign in as "bob@bob.bob"
...@@ -67,6 +68,80 @@ Feature: Notifications ...@@ -67,6 +68,80 @@ Feature: Notifications
Then I should see "commented on your post" Then I should see "commented on your post"
And I should have 1 email delivery And I should have 1 email delivery
Scenario: unconnected user comments in reply to comment by another user who commented a post of someone who she shares with
Given "alice@alice.alice" has a public post with text "check this out!"
When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great post, alice! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment"
When I sign out
And I sign in as "carol@carol.carol"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great comment, bob! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment:nth-child(2)"
When I sign out
And I sign in as "bob@bob.bob"
And I follow "Notifications" in the header
Then the notification dropdown should be visible
And I should see "also commented on"
And I should have 3 email delivery
Scenario: unconnected user comments in reply to my comment to her post
Given "alice@alice.alice" has a public post with text "check this out!"
When I sign in as "carol@carol.carol"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great post, alice! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment"
When I sign out
And I sign in as "alice@alice.alice"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great post, carol! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment:nth-child(2)"
When I sign out
And I sign in as "carol@carol.carol"
And I follow "Notifications" in the header
Then the notification dropdown should be visible
And I should see "also commented on"
And I should have 2 email delivery
Scenario: connected user comments in reply to my comment to an unconnected user's post
Given "alice@alice.alice" has a public post with text "check this out!"
And a user with email "bob@bob.bob" is connected with "carol@carol.carol"
When I sign in as "carol@carol.carol"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great post! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment"
When I sign out
And I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
And I focus the comment field
And I fill in the following:
| text | great post! |
And I press "Comment"
Then I should see "less than a minute ago" within ".comment:nth-child(2)"
When I sign out
And I sign in as "carol@carol.carol"
And I follow "Notifications" in the header
Then the notification dropdown should be visible
And I should see "also commented on"
And I should have 3 email delivery
Scenario: someone mentioned me in their post Scenario: someone mentioned me in their post
Given a user with email "bob@bob.bob" is connected with "alice@alice.alice" Given a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob And Alice has a post mentioning Bob
......
...@@ -24,5 +24,8 @@ module Diaspora ...@@ -24,5 +24,8 @@ module Diaspora
update_all(:comments_count => self.comments.count) update_all(:comments_count => self.comments.count)
end end
def comments_authors
Person.where(id: comments.select(:author_id).distinct)
end
end end
end end
...@@ -5,13 +5,14 @@ module Federated ...@@ -5,13 +5,14 @@ module Federated
def initialize(user, target) def initialize(user, target)
@user = user @user = user
@target = target @target = target
@dispatcher_opts ||= {}
end end
def create!(options={}) def create!(options={})
relayable = build(options) relayable = build(options)
if relayable.save! if relayable.save!
logger.info "user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}" logger.info "user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}"
Postzord::Dispatcher.defer_build_and_post(@user, relayable) Postzord::Dispatcher.defer_build_and_post(@user, relayable, @dispatcher_opts)
relayable relayable
end end
end end
......
...@@ -67,8 +67,12 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver ...@@ -67,8 +67,12 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
additional_subscriber = @object.post.author.owner additional_subscriber = @object.post.author.owner
end end
Notification.notify(additional_subscriber, @object, @object.author) if additional_subscriber && Notification.notify(additional_subscriber, @object, @object.author) if needs_notification?(additional_subscriber)
additional_subscriber != @object.author.owner && end
!@users.exists?(additional_subscriber.id)
private
def needs_notification?(person)
person && person != @object.author.owner && !@users.exists?(person.id)
end end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter