docbrown/app
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
..
assets Wrap <figcaption> elements and content inside <figure> elements (#4645) 2019-11-06 15:05:45 -05:00
black_box Update feed to have popular post stick around less (#4413) 2019-10-14 12:34:11 -04:00
controllers Rate limit daily user follows to 500 (#4647) [deploy] 2019-11-06 16:24:43 -05:00
dashboards Pro: memberships (#3461) 2019-09-24 10:38:54 -07:00
decorators Move cached_followed_tags to redis (#4714) 2019-11-05 09:34:58 -05:00
errors Pro: memberships (#3461) 2019-09-24 10:38:54 -07:00
fields Enables Rails cops (#2186) 2019-03-25 09:25:55 -04:00
helpers Setting width & height attributes to SVGs on articles#show page (#4705) 2019-11-05 13:13:44 -05:00
javascript Onboarding a11y fixes (#4728) [deploy] 2019-11-06 12:51:13 -05:00
jobs Implement Moderators audit logs (#3449) 2019-10-23 10:30:45 -04:00
labor Rate limit daily user follows to 500 (#4647) [deploy] 2019-11-06 16:24:43 -05:00
lib Update constants.rb (#4394) 2019-10-14 09:15:09 -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 Add comment markdown to warned_user_ping (#3750) 2019-08-22 22:04:45 -04:00
policies Add new font and theme config, plus new navbar config option (#4462) 2019-10-24 08:38:46 -04:00
sanitizers Add support for mark element in markdown (#2089) 2019-03-18 17:10:58 -04:00
serializers/webhook Use a sortable unique ID for the event_id (#3972) 2019-09-09 10:15:12 -04:00
services Moved classic-article-for-tag to Redis (#4706) 2019-11-04 17:06:15 -05:00
uploaders Strip EXIF and GPS data from uploaded images (#4450) 2019-10-24 16:35:10 -04:00
view_objects Dispatch events to the webhook endpoints #3715 (#3872) 2019-09-07 13:17:45 -04:00
views Add noopener to sponsor links (#4733) [deploy] 2019-11-06 14:21:40 -05:00