docbrown/spec
Omar Bahareth dca66bd6a8 Rate limit daily user follows to 500 (#4647) [deploy]
* Rate limit daily user follows to 500 per day
Return an error in `POST /follows` JSON response when a user tries to follow more than 500 accounts in a single day.

Other Changes:
- Add a spec for follows#create.

* Turn daily account follow limit into an env var

* Avoid executing today follow count query when possible
user.following_users_count is a counter cache on how many users the person is already following, so if it's less than the limit we don't need to run the query and can just return it instead.

* Simplify today follow count query
Stop needlessly checking into the future, only check from the beginning of the day until now.

* Raise account follow limit error if followable_id count is over limit
Other changes:
- Always return JSON, the `respond_to` block from before was unnecessary since this endpoint always returns JSON.
- Rescue `DailyFollowAccountLimitReached` on the method and remove begin block, since the error can be raised from two places in the same method.

* Index created_at on users table

* Make adding created_at index on users table happen concurrently

* Rename DAILY_ACCOUNT_FOLLOW_LIMIT to RATE_LIMIT_FOLLOW_COUNT_DAILY

* Add RATE_LIMIT_FOLLOW_COUNT_DAILY to Envfile

* Move RATE_LIMIT_FOLLOW_COUNT_DAILY from env var to ApplicationConfig
2019-11-06 16:24:43 -05:00
..
black_box Update feed to have popular post stick around less (#4413) 2019-10-14 12:34:11 -04:00
decorators Display comment published timestamp according to user's locale (#1970) 2019-03-08 15:19:37 -05:00
factories New Feature: Block Users (#4411) 2019-10-23 17:14:28 -04:00
fixtures Strip EXIF and GPS data from uploaded images (#4450) 2019-10-24 16:35:10 -04:00
helpers Setting width & height attributes to SVGs on articles#show page (#4705) 2019-11-05 13:13:44 -05:00
jobs Add ChatChannels::IndexingJob (#4317) [ci skip] 2019-10-15 16:13:10 -04:00
labor Rate limit daily user follows to 500 (#4647) [deploy] 2019-11-06 16:24:43 -05:00
lib Use ActiveSupport::Cache::RedisCacheStore As RedisRailsCache (#4676) [deploy] 2019-11-01 12:19:12 -04:00
liquid_tags Add JSitor liquid tag (#4657) [deploy] 2019-11-05 09:43:52 -05:00
mailers Make The Default Email An Enviroment Variable. (#4677) 2019-11-01 09:03:06 -04:00
models fix tag input swallowing numeric keycodes [deploy] (#4283) 2019-11-05 16:20:34 -05:00
observers Remove unused spec support BackgroundJobs (#4464) [ci skip] 2019-10-24 16:49:45 -04:00
policies Fix rubocop detected offenses (#4552) 2019-10-24 11:53:03 -04:00
requests Rate limit daily user follows to 500 (#4647) [deploy] 2019-11-06 16:24:43 -05:00
routing Enabled rubocop/lint (#2130) 2019-03-21 10:53:44 -04:00
services Deduplicate giphy_img? function and add tests (#4590) 2019-10-30 11:40:17 -04:00
support Add JSitor liquid tag (#4657) [deploy] 2019-11-05 09:43:52 -05:00
system Fix rubocop detected offenses (#4552) 2019-10-24 11:53:03 -04:00
uploaders Strip EXIF and GPS data from uploaded images (#4450) 2019-10-24 16:35:10 -04:00
views Improve test speed (#3957) [ci skip] 2019-09-12 16:17:20 -04:00
rails_helper.rb Update core API endpoints to support access_token (#3644) 2019-08-08 15:55:23 -03:00
spec_helper.rb Temporarily comment out random (#2486) 2019-04-18 11:56:38 -04:00