Commit graph

771 commits

Author SHA1 Message Date
Josh Puetz
35c2800c89
Add json support at stories/index endpoint (#6070)
* Add json support at stories/index endpoint

* Tweak tests

* Add main image

* Some light refactoring in StoriesController

* Tiny test refactor

* Split feed generation to it's own controller

* Use Jbuilder for article formatting

* Blank lines thanks Rubocop

* Don't cache this response: we want it generated per use each time

* Whoops!

* PR changes and tweaks to Timeframmer constants

* Remove initializer test since arguments aren't required
2020-02-18 15:15:40 -06:00
Ridhwana
39007b4dab
Campaign settings (#6141) [deploy]
* feat: port over changes (+ suggestions) from https://github.com/thepracticaldev/dev.to/pull/5892/files

* chore: add query over multiple lines

* refactor: move the sql logic into the controller instead of in the template

* chore: appease code climate
2020-02-18 11:02:09 -06:00
rhymes
6cbfb01394
Stop using legacy user's organization_id and remove followers unused code (#6079) [deploy] 2020-02-18 11:27:43 -05:00
rhymes
a56eb8fab0
Enable CORS on public API endpoints (#6116) [deploy]
* Enable CORS for public API

* Add specs for Articles API

* Mention CORS in the API docs
2020-02-18 10:47:07 -05:00
Molly Struve
98f25e2b9d
Remove UserHistory Feature and PageViews from Algolia (#6127) [deploy] 2020-02-18 10:06:30 -05:00
Ben Halpern
d0dd79ac29
Make sure profile images show up in onboarding (#6134) [deploy] 2020-02-17 20:19:06 -05:00
Ridhwana
8641f0a93e
Update the number of Published Posts to match the approved articles where necessary. (#6098)
* feat: the number of published posts should show up by approved article.

* chore: Do not use spaces between -> and ( in lambda literals

* refactor: use the existing function in order to spawn the one where we need approval

* refactor: move logic to the controller instead of the view :)

* chore: code climate syntax

* chore: more codeclimate
2020-02-17 12:18:33 -05:00
rhymes
d438349550
Revert "[deploy] Switch decorators from Draper to Rails builtin decorations (#6040)" (#6122) [deploy]
This reverts commit cc53b55a4a.
2020-02-17 11:28:32 -05:00
Andy Zhao
acd3b92b32
Add sink user service and specs for mass vomits (#6006)
* Add sink user service and specs for mass vomits

* Use new score calculation

* Lower articles' scores instead and make async

* Add lower score functionality to controllers

* Remove unused variable

* Use correct var and add missing arg

* Remove unused status

* Add composite index for reactable_type and ID

* Use alias instead of additional boolean

* Use medium priority for sink worker

* Log to honeybadger and not logs

* Log the error and not a string
2020-02-17 10:29:50 -05:00
Jacob Herrington
40bc7ecedd
Remove unnecessary eager loading (#6063)
Bullet doesn't seem to like this, and it makes sense because we don't
want to load ALL reactions, just some of them.

Co-authored-by: nspinazz89 <nspinazz89@gmail.com>

Co-authored-by: Nick S <nspinazz89@gmail.com>
2020-02-17 09:39:30 -05:00
rhymes
cc53b55a4a
[deploy] Switch decorators from Draper to Rails builtin decorations (#6040)
* Convert SponsorshipDecorator to Rails decorator

* Remove empty ReactionDecorator

* Rename SponsorshipDecorator#level_color_hex to level_background_color

* Convert CommentDecorator to Rails decorator

* Add specs and fix bugs for NotificationDecorator

* Convert NotificationDecorator to Rails decorator

* Add specs and fix bugs for OrganizationDecorator

* Convert OrganizationDecorator to Rails decorator

* Add specs to PodcastEpisodeDecorator and fix bugs

* Convert PodcastEpisodeDecorator to a Rails decorator

* Add missing specs for ArticleDecorator and fix bugs

* Convert ArticleDecorator to Rails decorator

* Add missing specs to UserDecorator and fix issues

* Convert UserDecorator to Rails decorator

* Add .decorate_collection method

* Add decorator for AR relations and remove Draper

* Rename BaseDecorator back to ApplicationDecorator

* Rename .decorate_ back to .decorate

* Restore decorate_collection (WTH)

* Add decorated?

* Fix bugs and failing specs

* Decoration should always be explicit
2020-02-17 09:32:32 -05:00
Molly Struve
7ff79f77b8
Search Tags in Elasticsearch from Classified Listing and Post Creation (#6024) [deploy] 2020-02-17 08:16:45 -05:00
Ben Halpern
8837531195
Add additional safeguards for config write access (#6064) [deploy]
* Add additional safeguards for config write access

* Change spec name and confirmation step
2020-02-13 18:39:55 -05:00
Michael Kohl
2a0a89239c
Add health check endpoint for Mailchimp unsubscribe webhook (#6034) [deploy] 2020-02-12 15:55:21 -05:00
Mac Siri
a31e15f90d
Skips verify_authenticity_token in MailchimpUnsubscribesController (#6038) 2020-02-12 15:18:50 -05:00
rhymes
1df24046d8
Small API controllers refactoring (#6021) [deploy]
* TagsController inherits from ApiController
* Let ApiController inherit from ActionController::Base to have its own lifecycle
* Remove unused method
* Use only one respond_to :json for the entire API
* ApiController inherits from ActionController::Base
* Use Pundit only where needed
2020-02-12 11:51:42 -05:00
Mac Siri
6b481166fe
Add unsubscribe option to badge and connect emails (#6027) 2020-02-12 10:48:51 -05:00
Josh Puetz
38622317b7
Consolidate server side main article feed logic (#5953) [deploy]
* Consolidate `.decorate` calls

* Move Activerecord finders out of main stories feed partial

* Add back in decorates to sticky_articles partial

* Combine top and new articles returned from StoriesController

* Extract feed construction logic to a service

* Some PR tweaks (naming)

* Quick test fix
2020-02-12 08:43:20 -06:00
Andy Zhao
0f9b52f800
Use post instead of get for CSRF (#6026) 2020-02-11 17:56:11 -05:00
Maykon Menezes
cefa95b92d
fix response when article can't be found (#5999) 2020-02-11 15:23:44 -05:00
Ben Halpern
2add3ae300
Replace dev.to with ApplicationConfig in a few locations (#6008) [deploy]
* Replace dev.to with ApplicationConfig in a few locations

* Update app/labor/badge_rewarder.rb
2020-02-11 14:48:27 -05:00
Michael Kohl
050a2e2726
Implement Mailchimp unsubscribe webhook (#5804) [deploy] 2020-02-11 14:25:48 -05:00
Vaidehi Joshi
c33d6936b5
Do not allow staff_user_id to be mutated (#6009) [deploy]
Allowing ids to be mutated by admins from the /internal/config pages is dangerous.
This could cause issues if an admin tries to update the SiteConfig.staff_user_id to an id that is another user's id, or to an id that isn't valid.
2020-02-10 16:35:18 -08:00
Molly Struve
0eecdf616c
soft save notification_subscription and then check persisted (#5962) [deploy] 2020-02-10 16:37:28 -05:00
Alex
78a25dfd54
Validate that API article params are a Hash (#5963)
* Add check for article param being a Hash & spec

* Remove unnecessary blank line

* Move logic to private method and before_action call

* Change check_if to validate

* Use is_a? to type check

* Fix type check for specs
2020-02-10 10:24:11 -05:00
rhymes
c41d66e900
Replace ban/banned with suspend/suspended in user facing text (#5816) [deploy] 2020-02-10 10:12:53 -05:00
Molly Struve
e159217dce
Remove Unused ChatChannel Indexing (#5907) [deploy]
* remove unused algolia code from chat channel

* remove new chat_channel index code and unused methods
2020-02-07 12:39:59 -05:00
rhymes
69b04d38aa
Refactor API Reactions controller and add specs (#5936)
* Add specs

* Check the object, not the ID

* Use permitted params and delete cache only after create

* Inherit from ApiController, bail if the reaction user does not exist, fix naming

* Remove superflous test
2020-02-07 12:39:24 -05:00
Vaidehi Joshi
c7a1bd9449
Fix logging for dev and test environments (#5922)
* Fix logging for dev and test environments

We had some unused code for Timber in our config files for development and test.
However, this was completely clobbering Rails' default behavior of logging out to log/development.log and log/test.log. We should allow for logging in these environments in particular, and since we're not using Timber there, we can just revert to using the Rails default debugging log levels.

* Add Timber logger to specs that explicitly require it

* Restore default Rails.logger in specs using Timber logger

* Explicitly use Rails.logger in OmniauthCallbacksController

We seem to have different logger classes leaking into this controller in tests.
I'm not entirely sure why this is/haven't been able to investigate yet, but I do think we should be using the Rails.logger explicitly until we can figure that out.
2020-02-07 10:15:08 -05:00
Molly Struve
bbeb3fc79d
Ensure user is authenticated before doing onboarding Actions (#5937)
* ensure user is authenticated before doing onboarding checks

* add specs for authenticating users for onboarding updates
2020-02-07 09:56:29 -05:00
rhymes
6cd46ae2f9
Enable bullet during tests to catch N+1 early (and some cleanups) (#5930) [deploy]
* Remove unused methods

* Small refactorings

* Enable bullet in testing mode

* Remove unused eager loading for notes

* Skip bullet on rolify method

* Use .present?

* Fix method name
2020-02-07 09:02:22 -05:00
Sebastien
665f5aac0f
Refactor ProfileImage (#5803) 2020-02-07 08:56:16 -05:00
Maykon Menezes
01dc81afa9
Move Podcasts::GetEpisodesJob to Sidekiq (#5443) [deploy]
* Refactored Podcast::GetEpisodesJob to sidekiq

* fixing specs

* removing env keys

* Change arguments to Hash

* Update specs and add spec for queue

* Update references for Hash argument

* Add comment to explain parameters of #perform

Co-authored-by: Alex <alexandersmith223@gmail.com>
2020-02-06 09:42:55 -08:00
rhymes
92f6a9f007
Fix serialization error with video_thumbnail_url (#5933) 2020-02-06 10:50:44 -05:00
rhymes
fd5643bc9d
Improve API controllers efficiency by selecting only columns needed for serialization (#5805) [deploy] 2020-02-06 07:36:56 -05:00
Michael Kohl
52759c9427
Allow deleting comments if article has already been deleted (#5889) [deploy] 2020-02-05 17:10:19 -05:00
Gonzalo Ricco
dd796aaef3
Fix raising validation if followable already exist(race condition) (#5826)
* Fix raising validation if followable already exist(race condition)

* Change Rails Logger for DataDogStatsClient and remove 'begin' keyword in follow method

Co-authored-by: Gonzalo Ricco <gonzalo.ricco@leniolabs.com>
2020-02-05 12:25:26 -05:00
Maja Komel
28440d1fa1
Return NotFound error if ChatChannelMembership is not found (#5806) 2020-02-05 12:24:40 -05:00
Michael Kohl
7270d5ab4c
Move user deletion by moderator to worker (#5887) [deploy] 2020-02-05 08:27:07 -05:00
Alex
97ee0a804f
Move HtmlVariantTrial#create inline (#5901) [deploy] 2020-02-04 17:29:46 -08:00
Vaidehi Joshi
e84dec1db6
Allow broadcasts to be created from internal/broadcast (#5908) [deploy]
Also raise errors when necessary in all broadcast endpoints.
Clean up tests and add specs for POST /internal/broadcast
2020-02-04 15:57:17 -08:00
Alex
de3ee9ebec
Move HtmlVariantSuccessesCreate from job to inline (#5879) [deploy] 2020-02-04 10:24:39 -08:00
Vaidehi Joshi
267e08f6f0
Improve dropdown UX for internal/badges (#5880) [deploy]
* Improve dropdown UX for internal/badges

Add a "blank" option to the dropdown to list of badges on internal/badges route.
Also add some checks to handle if an admin accidentally tries to award a "blank" badge.

* Ensure error is surfaced as flash message
2020-02-04 09:02:14 -08:00
rhymes
42b33f29ae
Add signin=true as a param correctly if the URL already has params (#5866) [deploy] 2020-02-04 09:41:10 -05:00
Fran Zekan
cba4e99525
Return a 404 response If @event is Not Found (#5798) [deploy] 2020-02-03 11:30:52 -05:00
Molly Struve
a5dd0c6abb
track stripe errors in Datadog so we can alert on them (#5797) 2020-02-03 09:11:38 -05:00
Ben Halpern
82f2281b1c
Create dynamic robots.txt page (#5794) [deploy]
* Create dynamic robots.txt page

* Add tests and remove cachebust
2020-01-28 16:49:34 -05:00
Michael Kohl
96ac213614 Add comment explaing catch + reraise (#5782) 2020-01-28 08:36:40 -05:00
rhymes
5444c53df2 Improve API podcast episodes controller caching and fetching (#5772) [deploy]
* Refactor caching and add some tests

* Only select needed columns

* Add more tests
2020-01-27 16:57:37 -05:00
rhymes
397ef313de Improve video controllers caching and retrieving (#5709) [deploy]
* Add tests and improve pagination and caching

* Add two more specs

* Add .with_video scope

* Get rid of N+1

* Only select needed columns

* Improve efficiency of the video page as well

* Add missing set_cache_control_headers to API videos#index
2020-01-27 15:51:12 -05:00