[openstreetmap/openstreetmap-website] Add UserMute to control private message visibility (PR #4284)

Gregory Igelmund notifications at github.com
Wed Oct 11 10:34:17 UTC 2023


@grekko commented on this pull request.



> +  belongs_to :appointee, :class_name => "User"
+
+  validates :appointee, :uniqueness => { :scope => :creator_id }
+
+  def self.for_message?(message)
+    sender = message.sender
+
+    !sender.administrator? &&
+      !sender.moderator? &&
+      active_for?(
+        :current_user => message.recipient,
+        :other_user => sender
+      )
+  end
+
+  def self.active_for?(current_user:, other_user:)

> Of course once you do that the question becomes is this method even needed when it's just forwarding the arguments to exists??

good point. Initially there were more places from which `UserMute.active_for?` in which the the terms `current_user` and `other_user` are used to reference the instances. So I thought it was making the code a bit easier to read/grasp from that context.

Now there is just a single call, plus the call from `UserMute#for_message?` – I think it's ok to drop `UserMute#active_for?` and just call `UserMute#exists?` directly 👌🏽 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4284#discussion_r1354648597
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4284/review/1670724973 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231011/0896c92c/attachment-0001.htm>


More information about the rails-dev mailing list