@@ -58,8 +58,8 @@ class User < ApplicationRecord
58
58
has_many :new_messages , -> { where ( :to_user_visible => true , :muted => false , :message_read => false ) . order ( :sent_on => :desc ) } , :class_name => "Message" , :foreign_key => :to_user_id
59
59
has_many :sent_messages , -> { where ( :from_user_visible => true ) . order ( :sent_on => :desc ) . preload ( :sender , :recipient ) } , :class_name => "Message" , :foreign_key => :from_user_id
60
60
has_many :muted_messages , -> { where ( :to_user_visible => true , :muted => true ) . order ( :sent_on => :desc ) . preload ( :sender , :recipient ) } , :class_name => "Message" , :foreign_key => :to_user_id
61
- has_many :friendships , -> { joins ( :befriendee ) . where ( :users => { :status => %w[ active confirmed ] } ) }
62
- has_many :friends , :through => :friendships , :source => :befriendee
61
+ has_many :follows , -> { joins ( :befriendee ) . where ( :users => { :status => %w[ active confirmed ] } ) }
62
+ has_many :followings , :through => :follows , :source => :befriendee
63
63
has_many :preferences , :class_name => "UserPreference"
64
64
has_many :changesets , -> { order ( :created_at => :desc ) } , :inverse_of => :user
65
65
has_many :changeset_comments , :foreign_key => :author_id , :inverse_of => :author
@@ -281,7 +281,7 @@ def distance(nearby_user)
281
281
end
282
282
283
283
def friends_with? ( new_friend )
284
- friendships . exists? ( :befriendee => new_friend )
284
+ follows . exists? ( :befriendee => new_friend )
285
285
end
286
286
287
287
##
@@ -412,7 +412,7 @@ def max_messages_per_hour
412
412
def max_friends_per_hour
413
413
account_age_in_seconds = Time . now . utc - created_at
414
414
account_age_in_hours = account_age_in_seconds / 3600
415
- recent_friends = Friendship . where ( :befriendee => self ) . where ( :created_at => Time . now . utc - 3600 ..) . count
415
+ recent_friends = Follow . where ( :befriendee => self ) . where ( :created_at => Time . now . utc - 3600 ..) . count
416
416
max_friends = account_age_in_hours . ceil + recent_friends - ( active_reports * 10 )
417
417
max_friends . clamp ( 0 , Settings . max_friends_per_hour )
418
418
end
0 commit comments