Skip to content

Commit

Permalink
Fixing bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Oct 18, 2023
1 parent 47a3403 commit c9d252b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/models/tipline_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ def save_ignoring_duplicate!
end
end

private

def verify_user_rate_limit
rate_limit = CheckConfig.get('tipline_user_max_messages_per_day', 1500, :integer)
# Block tipline user when they have sent more than X messages in 24 hours
if self.state == 'received' && TiplineMessage.where(uid: self.uid, created_at: Time.now.ago(1.day)..Time.now, state: 'received').count > rate_limit
Bot::Smooch.block_user(self.uid)
end
end

def media_url
payload = begin JSON.parse(self.payload).to_h rescue self.payload.to_h end
media_url = nil
Expand All @@ -41,6 +31,16 @@ def media_url
media_url || payload['mediaUrl']
end

private

def verify_user_rate_limit
rate_limit = CheckConfig.get('tipline_user_max_messages_per_day', 1500, :integer)
# Block tipline user when they have sent more than X messages in 24 hours
if self.state == 'received' && TiplineMessage.where(uid: self.uid, created_at: Time.now.ago(1.day)..Time.now, state: 'received').count > rate_limit
Bot::Smooch.block_user(self.uid)
end
end

class << self
def from_smooch_payload(msg, payload, event = nil, language = nil)
msg = msg.with_indifferent_access
Expand Down

0 comments on commit c9d252b

Please sign in to comment.