Unverified Commit 200486b6 authored by Jonne Haß's avatar Jonne Haß
Browse files

Merge pull request #6984 from SuperTux88/6294-ignore-notifications

Don't create notifications from ignored people
parents 4afa77b0 0d338b6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ The command will report queues that still have jobs and launch sidekiq process f
* Make screenreaders read alerts [#6973](https://github.com/diaspora/diaspora/pull/6973)
* Display message when there are no posts in a stream [#6974](https://github.com/diaspora/diaspora/pull/6974)
* Add bootstrap-markdown editor to the publisher [#6551](https://github.com/diaspora/diaspora/pull/6551)
* Don't create notifications for ignored users [#6984](https://github.com/diaspora/diaspora/pull/6984)

# 0.5.10.2

+3 −2
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ class Contact < ActiveRecord::Base
  end

  def not_blocked_user
    errors.add(:base, "Cannot connect to an ignored user") if user && user.blocks.where(person_id: person_id).exists?
    if receiving && user && user.blocks.where(person_id: person_id).exists?
      errors.add(:base, "Cannot connect to an ignored user")
    end
  end
end
+7 −5
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class Notification < ActiveRecord::Base
  end

  def self.concatenate_or_create(recipient, target, actor)
    return nil if suppress_notification?(recipient, target)
    return nil if suppress_notification?(recipient, actor)

    find_or_initialize_by(recipient: recipient, target: target, unread: true).tap do |notification|
      notification.actors |= [actor]
@@ -42,12 +42,14 @@ class Notification < ActiveRecord::Base
    end
  end

  def self.create_notification(recipient_id, target, actor)
    create(recipient_id: recipient_id, target: target, actors: [actor])
  def self.create_notification(recipient, target, actor)
    return nil if suppress_notification?(recipient, actor)

    create(recipient: recipient, target: target, actors: [actor])
  end

  private_class_method def self.suppress_notification?(recipient, post)
    post.is_a?(Post) && recipient.is_shareable_hidden?(post)
  private_class_method def self.suppress_notification?(recipient, actor)
    recipient.blocks.where(person: actor).exists?
  end

  def self.types
+3 −2
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@ module Notifications
      recipient_ids = commentable.participants.local.where.not(id: [commentable.author_id, actor.id]).pluck(:owner_id)

      User.where(id: recipient_ids).find_each do |recipient|
        concatenate_or_create(recipient, commentable, actor)
          .try {|notification| notification.email_the_user(comment, actor) }
        next if recipient.is_shareable_hidden?(commentable)

        concatenate_or_create(recipient, commentable, actor).try(:email_the_user, comment, actor)
      end
    end
  end
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ module Notifications

        next if recipient == actor || !(mentionable.public || recipient_user_ids.include?(recipient.owner_id))

        create_notification(recipient.owner_id, mention, actor).email_the_user(mention, actor)
        create_notification(recipient.owner, mention, actor).try(:email_the_user, mention, actor)
      end
    end
  end
Loading