0
0
Fork 0

Add specific rate limits for posting and following (#13172)

This commit is contained in:
Eugen Rochko 2020-03-08 15:17:39 +01:00 committed by GitHub
parent 503eab1c1f
commit 339ce1c4e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 273 additions and 51 deletions

View file

@ -87,10 +87,10 @@ module AccountInteractions
has_many :announcement_mutes, dependent: :destroy
end
def follow!(other_account, reblogs: nil, uri: nil)
def follow!(other_account, reblogs: nil, uri: nil, rate_limit: false)
reblogs = true if reblogs.nil?
rel = active_relationships.create_with(show_reblogs: reblogs, uri: uri)
rel = active_relationships.create_with(show_reblogs: reblogs, uri: uri, rate_limit: rate_limit)
.find_or_create_by!(target_account: other_account)
rel.update!(show_reblogs: reblogs)
@ -99,6 +99,18 @@ module AccountInteractions
rel
end
def request_follow!(other_account, reblogs: nil, uri: nil, rate_limit: false)
reblogs = true if reblogs.nil?
rel = follow_requests.create_with(show_reblogs: reblogs, uri: uri, rate_limit: rate_limit)
.find_or_create_by!(target_account: other_account)
rel.update!(show_reblogs: reblogs)
remove_potential_friendship(other_account)
rel
end
def block!(other_account, uri: nil)
remove_potential_friendship(other_account)
block_relationships.create_with(uri: uri)