Commit graph

63 commits

Author SHA1 Message Date
Araslanov Evgeny
60d8a07276 Fix invalid body_markdown in article with video (#4258) [ci skip] 2019-10-08 15:41:44 -04:00
Andy Zhao
3b0f6f2834 Refactor remove_all and remove_each notifications and fix orphaned notifications (#3570) 2019-09-25 15:31:56 -04:00
Anna Buianova
4c9a40be41 Dispatch events to the webhook endpoints #3715 (#3872)
* Start with webhooks: table and model

* Start with webhooks api

* Start with webhooks api

* Webhook::Event class and events list

* Remove commented callbacks

* Start with sending events to webhook endpoints

* A couple of tests for Articles::Creator

* Send event to webhook endpoint on article destroy

* Dispatch event on article update

* Dispatch event when an article updated from admin

* Spec for the webhook job

* One more test for the dispatch event job

* Integration-like spec for event dispatching to webhook endpoints when creating an article

* Use Addressable::URI to parse endpoint url

* Add oj as a faster fast_jsonapi backend

* Renamed serializers

* Move article serialization out of a model

* Don't allow to create a webhook event with invalid type

* Add fields for ArticleSerializer

* Fix webhook event job specs

* Specify timeout when dispatching events

* Fix webhook job spec

* Change webhook events queue name

* Change serialized article fields for the dispatchable events

* Include user data when serializing an article for webhook event

* Moved decorating out of Webhook::DispatchEvent, fixed most specs

* Fix route in ArticleSerializer

* Move Article decoration to Webhook::PayloadAdapter

* Refactor image url helpers to avoid including helpers into serializer

* Fix specs

* Default url options for production
2019-09-07 13:17:45 -04:00
Feruz Oripov
0ccc62ffa3 Refactoring possible unprotected redirect. (#3825)
* Refactoring possible unprotected redirect.

* Security refactoring tag_adjustments_controller.rb.

* Security refactoring tag_adjustments_controller.rb.

* Security refactoring articles_controller.rb.

* Security refactoring internal/welcome_controller.rb

* Security refactoring tags_controller.rb.

* Security refactoring comments_controller.rb.

* Security refactoring stories_controller.rb.
2019-08-27 10:13:38 -04:00
Anna Buianova
9b04654e3b Refactor articles creation (#3797)
* Refactor articles creation

* Create article from /admin via a service for consistency

* Move articles destroy logic into Articles::Destroyer
2019-08-23 14:43:29 -04:00
Ben Halpern
04a810d739
Fix video image redirect issue (#3778) 2019-08-20 13:18:38 -04:00
rhymes
4689cdd266 Collection: remove optional user and add tests (#3383) 2019-08-02 10:15:04 -04:00
Mac Siri
e28aaecca4
Make xhr request's method dynamic for archiving. (#3335) 2019-07-15 14:40:01 -04:00
Andy Zhao
da224d56aa Remove notifications if article is unpublished (#3362)
* Add tests for article notifications

* Remove notifications if unpublished and refactor
2019-07-03 16:50:23 -04:00
rhymes
55634ad68f Display stats for organization article (#3232)
There was a bug where the frontend was not passing the organization id to the backend, and thus the fetching of the stats failed for organization articles.

This also adds a bit of error handling for `fetch` API
2019-06-19 09:17:35 -04:00
rhymes
7f2045b250 Pro Analytics: stats for a single article (#3120)
* Add /stats endpoint for articles, opened only to Pro users

* Add analytics to article stats page

* Add stats button to the article page and test stats page
2019-06-13 19:02:09 -04:00
Ben Halpern
a3a9f51103
Fix improper archive redirect (#3064) 2019-06-06 17:03:59 -04:00
Andy Zhao
47d9ec27fb Allow users to belong to multiple orgs (#2583)
* Allow user to have many orgs

* Allow users to handle multi orgs in settings

* Make rounded buttons inline

* Add multi org function to dashboards

* Fix merge conflicts

* Fix mistake in merge conflict fix oops

* Display the correct membership level

* Fix accessibility issues

* Display organizations for article editors

* Handle submitting org id with preact editors

* Make listings work with multiple organizations

* Allow listings to have multiple orgs on create

* Display the correct number of credits for each org

* Move script tag to Webpack

* Allow multi orgs for purchasing and viewing credits

* Use OrganizationMembership as authorization check

* Display multiple organizations for notifications

* Allow dashboard to be viewable under multi-orgs

* Remove unused method

* Add multi-org functionality for article editors

* Show pro dashboard buttons for member+ org levels

* Leave the correct organization

* Allow article API to change org id

* Add left-out authorization method oops

* Make nav buttons a bit more clear

* Fix merge conflict

* Fix adding org id for /api/articles and tests

* Fix tests for org policy

* Use proper logic for displaying org members

* Update org actions with new authorization

* Use correct org when creating a listing

* Remove additional payment charge oops

* Mark org notifications as read with authorization

* Remove deprecated post_as_organization attribute

* Use new org_admin syntax

* Remove deprecated org logic for article create and update

* Default all RSS posts to not belong to any org

* Render org_member page for guest users

* Update org policy spec to work with multi orgs

* Use org_membership for org traits and move identity code

* Use org_member trait

* Update to work with multi-orgs

* Validate article's org_id if param org_id is blank

* Make  a let variable

* Remove unnecessary eager load for credits

* Fix HTML structure and org logic for non-org users

* Update credits spec for multi-org

* Add test for failed payment when purchased by org

* Lint listings_spec

* Test that the listing was created under the user

* Add tests for POST /listings multi-org

* Use double quotes for classes

* Fix /manage and a few other multi-org bugs

* Fix test for multi org

* Use correct method SQL exists? not Rails exist?

* Fix reads spec for multi-org

* Fix org_controller actions to work with multi org

* Test only multi org and not old usage and fix leave_org

* Fix org showing user profile img test for multi-org

* Fix org logic for users with no orgs

* Remove switch org functionality

* Update tests and add hidden param for org id

* Redirect to the specific organization

* Test other org button actions

* Use settings_notice instead of legacy notice and refactor

* Fix weird extra end issue prob from merge conflicts

* Test for with new flash key

* Fix user_views_org tests for multi-org

* Test for new flash message

* Update snapshot with new a11y html

* Move styling to stylesheet

* Add site admins functionality

* Move org_member? method in user model and refactor

* Use unspent_credits_count for organizations

* Add tests for /listings/new and minor bug fixes

* Use .present? in case of empty array

* Fix a lingering deprecated method

* Use greater than 1 for random numbers

* Add tests for counting spent and unspent credits
2019-06-04 09:30:52 -04:00
Jess Lee
c3e2a0c5f1 Add missing instance var for /manage & Bust rails cache on comments (#3004) 2019-05-30 12:23:20 -04:00
rhymes
38aa45c8e3 Cleanup bodyPreview component (#2980) [ci skip] 2019-05-28 23:55:37 -04:00
rhymes
6a626e819d Refactor: fix issues raised by bullet (#2965)
* Preload organization, not user

* Preload users only when needed

* Pre-load podcasts for podcast episodes in API

* Avoid eager loading error by loading rating votes separately

* Preload associations for moderation

* Preload user comments in trees

* Preload organization for non org dashboard and cleanup queries

* Optimize ArticleSuggester to only load N articles at need

* Remove eager loading and pass variables to partials for easier debug

* Reorganize tags validation code and ignore actsastaggableon eager loading issues

* Remove unused eager loading and bring up comments relation

* Preload podcasts when loading podcast episodes

* Fix views specs

* Make sure ArticleSuggester never returns duplicates

* Remove commented code

* Re-trigger build

* Move suggested articles back to view to respect fragment caching
2019-05-28 17:32:53 -04:00
Ben Halpern
07597d307c
Fix bug to allow users to remove org from article (#2930) 2019-05-21 17:16:16 -04:00
rhymes
09a99d93a3 Return errors instead of raising an exception on ArticleCreation (#2922) 2019-05-21 15:18:02 -04:00
rhymes
85e33583c8 Fix organization article ownership code (#2904)
* Fix organization article ownership code

* Query the DB in case of user change only if needed
2019-05-20 18:50:04 -04:00
Ben Halpern
6c2498b1b8
Render correct editor based on article's existing format (#2856)
* Render correct editor based on article's existing format

* Add check for user in /new
2019-05-16 15:25:43 -04:00
Ben Halpern
fb6904f86d
Fix up articles controller (#2855)
* Fix up articles controller

* Update request specs

* Add proper post_under_org tests

* Remove create_job_opportunity

* Add user profile back in
2019-05-16 13:56:26 -04:00
rhymes
941ab4178b Articles API: create and update (#2844)
* Add system test to create article from the editor

* Move article creation from API to app controller

* Fix system test to edit posts

* Move article update from API to app controller

* Rewrite create article API using API key

* Add main_image and canonical_url to allowed creation params

* Rewrite update article API using API key

* Fix tests and have Comments API inherit from API
2019-05-16 12:26:24 -04:00
rhymes
66ddcbca02 Upgrade rubocop and rubocop-performance (#2802) [ci skip] 2019-05-13 19:21:24 -04:00
Dana Scheider
b2a8f69f83 Allow archiving of posts (#2798)
* This commit adds the "archived" attribute to the Article model, which will
enable users to automatically filter archived articles/drafts from appearing
on their dashboard. It also adds an ellipsis menu with a link to archive the
article. I've also moved the Mute Notifications button into the ellipsis menu
as well.

* Add ellipsis menu and make it work

* Fix logic error

* Hide ellipsis menus when you click elsewhere on the body

* Extract function to remove duplication

* Ensure that menu is hidden when the ellipsis button is clicked on an open menu

* Ensure that archiving post button works and that 'archived' param is accepted by the controller

* Enable link to toggle showing/hiding archived articles

* Make 'mute' and 'archive' buttons in ellipsis dropdown list work

* Refactor to make Code Climate happy

* Minor JS refactors
2019-05-13 15:40:52 -04:00
Ben Halpern
c7d7d55460
[WIP] Move both v1 and v2 editor to v2 preact-driven editor (#2797)
* Initial work on v2

* Initial changes merger

* Work to finalize v1/v2 editor adjustments

* Clean up styling

* Fiddle with form margins

* Fix some tests

* Change video

* skip a couple tests

* Modify tests to work with new code
2019-05-13 12:27:36 -04:00
Wes Delp
f08f5fcdbf Customize RSS feed by tag (#2634)
* add tag param and filter

* add tag filter request specs

* order user above tag to maintain existingdefault

* refactor #new for code climate

* add rss feed spec

* move feed tags under explicit route
2019-05-03 11:35:54 -04:00
Ben Halpern
5eb8036bad
Fix buffer_updates conditional in /manage (#2636) 2019-05-01 10:17:35 -04:00
Ben Halpern
158f56bc9d
Add page for users to "manage" their posts after publication (distribution, etc.) (#2627)
* Set up basic /manage route

* Add basic article manage page

* Add tips and finalize permissions for /manage

* Add final test and add manage button to article show

* Update failing specs
2019-05-01 09:00:09 -04:00
Ben Halpern
9578a15579
Remove unnecessary map functions in stories controller (#2402) 2019-04-12 01:10:08 -04:00
rhymes
5782ffd7e0 Use published scope for articles (#2374)
* Use published scope for articles

* Fix variable name

* The sequencing in the union query matters

* Fix spec

* Restore a published: true condition

* This test is actually misleading due to the union

* Revert this change, not sure why it's not a relation

* Fix useless diff
2019-04-11 13:18:26 -04:00
Abraham Williams
9cb40e546b Enables Rails cops (#2186)
* Enable Rails cops

* Fix Rails/DynamicFindBy

* Fix Rails/HttpStatus

* Fix Rails/Blank

* Fix Rails/RequestReferer

* Fix Rails/ActiveRecordAliases

* Fix Rails/FindBy

* Fix Rails/Presence

* Fix Rails/Delegate

* Fix Rails/Validation

* Fix Rails/PluralizationGrammar

* Fix Rails/Present

* Fix Rails/Output

* Fix Rails/Blank

* Fix Rails/FilePath

* Fix Rails/InverseOf

* Fix Rails/LexicallyScopedActionFilter

* Add Rails/OutputSafety to TODO

* Add Rails/HasManyOrHasOneDependent to TODO

* Add Rails/SkipsModelValidations to TODO
2019-03-25 09:25:55 -04:00
Tim Lange
3494264404 Enabled rubocop/lint (#2130)
* WIP: Enabled rubocop/lint

* FIX: Fixed failing test

* FIX: Small change to return

* FIX: Changed indent
2019-03-21 10:53:44 -04:00
Ben Halpern
90a44b1687
Add prefill text for /new (#2108) 2019-03-18 19:08:00 -04:00
Ben Halpern
e491cf1f65
Allow non-logged-in proper redirect for template posts (#1977) 2019-03-04 15:50:36 -08:00
Ben Halpern
fd83b33603
Add shecoded template to v2 (#1972) 2019-03-04 12:41:37 -08:00
Dmitrii Krasnov
9375d2436f Fix articles feed not filtering articles by user/organization (#1941)
* Fix articles feed not filtering articles by user/organization
fix #1940

* add specs for articles fetching in articles#feed controller action
2019-03-02 07:48:55 -08:00
rhymes
996ca23ed1 Simplify ArticlesController#feed (#1932)
* Simplify ArticlesController#feed

There's unneeded complexity in the logic of the feed method, this way what separates each path should be clearer

* Update app/controllers/articles_controller.rb

Co-Authored-By: rhymes <rhymesete@gmail.com>
2019-03-01 07:32:59 -08:00
Andy Zhao
5ace9a5fc9 Organization Notifications (#1762)
* Add spec for org reaction notification

* Add organization_id to notifications

* Add validations for user and org IDs

* Move comment json_data out of loop

* Use actual column names instead

* Add organization filters

* Remove extra text-align

* Add organization filtering

* Refactor to reduce complexity

* Add receiver argument to handle orgs

* Add has_many notifications for orgs

* Add follow notifications for orgs

* Add comment notifications for orgs

* Rename some tests for specificity

* Add mark org notifications as read functionality

* Add radix to parseInt

* Define json_data outside of loop

* Notify org followers of a new post as well

* Move test to proper location

* Add test for aggregated method

* Make send org reaction notification more readable

* Test the rest of the notification model

* Refactor tag adjustment spec

* Fix extra html
2019-02-25 14:25:37 -08:00
Ali Spittel
4f1a996e6f Fix tag template issue on editor v1 (#1793) 2019-02-13 13:43:41 -05:00
Ben Halpern
7d6c85a294
RSS feed optimizations (#1752)
* RSS feed optimizations

* Update app/views/articles/feed.rss.builder

Co-Authored-By: benhalpern <bendhalpern@gmail.com>

* Update app/controllers/articles_controller.rb

* Update app/controllers/articles_controller.rb
2019-02-06 20:31:58 -04:00
Ben Halpern
d7665fcc3f
Add comment template to post (#1692)
* add myself to the core contributors

* add comment template

* merge upstream

* make sure the template re-appears for top level comments after submission

* make interface admin only

* Adjust comment template form

* Fix merge conflicts

* Remove unnecessary comment template from json
2019-01-30 13:32:34 -05:00
Ben Halpern
049a7b7b73
Fix article taken redirect issue (#1645) 2019-01-24 18:16:35 -05:00
Ben Halpern
a0d90874a9
Move org admin privilege check into controller (#1642) 2019-01-24 13:35:39 -05:00
rhymes
6553f08d94 Rubocop cleanups (#1415)
* Update rubocop-todo.yml with new violations

* Fix Layout/EmptyLine* rules

* Fix Layout/Indentation* rules

* Fix remaining Layout/* rules

* Fix Lint/DuplicateMethods by removing unused accessor

* Fix Lint/IneffectiveAccessModifier

* Fix Lint/MissingCopEnableDirective

* Re-run rubocop auto gen config

* Fix Layout/RescueEnsureAlignment

* Fix Naming/* rules

* Fix some RSpec/* rules

* Fix typos

* Fix RSpec/LetBeforeExamples

* Series should only be an attr_writer, not an attr_accessor

* Fix RSpec/InstanceVariable

* Fix RSpec/InstanceVariable

* Fix RSpec/RepeatedDescription and RSpec/RepeatedExample

* Fix Style/ClassAndModuleChildren

* Fix Style/ConditionalAssignment

* Fix some Style/* rules

* Trigger Travis CI build because failing tests are not failing locally

* Revert "Fix Style/ClassAndModuleChildren"

This reverts commit 1686801d8a1516ba1894f79e24401a20dea65f99.
2019-01-02 11:20:02 -05:00
Andy Zhao
92cea23fcd Fix a few notification bugs (#1232)
* Remove notifications synchronously on unpublish and destroy

* Asynchronously remove reaction notifications for article

* Remove all associated notifications when destroyed

* Fix edge case for reaction notifications

* Load new comment_box file instead of old one

* Delete legacy views

* Remove unused private declaration

* Use casecmp.zero? instead of downcase for speed, and use @user

* Add friendly error message for notifications

* Use delete all and not destroy b/c no callbacks
2018-12-03 12:35:35 -05:00
Andy Zhao
a1010201f2 Notifications part 2 (#1156)
* Remove stream and add new notification views

* Actually remove Stream

* Move followers query to async method

* Remove unused tests and fix query

* Try using without delay instead

* Add without delay and escape HTML

* Make all tests pending for now
2018-11-19 18:14:24 -05:00
Andy Zhao
2db2dd1e5a WIP Refactor/notifications (#1131)
* Add new columns to notifications table

* Remove stream from notifications and add new methods

* Turn off moderation comment notifications

* Add notifiable_type index to migration

* Stop creation of Stream-based notification model instances

* Add notification model create hooks

* Add badge achievement notification creation hook

* Fix some specs

* Add missing @ symbol

* Fix for tests and rename a few things

* forgot to uncomment code sigh
2018-11-19 16:09:02 -05:00
Ben Halpern
359cc71b64
Add ability for users to publish series (#1034) 2018-10-29 13:04:42 -04:00
rhymes
1b60ee5009 Use timezone aware methods (#893)
* Use timezone aware datetime methods

* Use timezone aware date parse for GitHub issue tag

* Introduce a bit of chaos programming using Zonebie

Zonebie uses a random timezone to run tests, it's a really good way to see if the code is timezone dependent or not.

* Convert GitHub issue date as UTC
2018-10-18 16:26:29 -04:00
Ben Halpern
a14c37f4ab
Add tag when submission templated to v2 (#863)
* Add tag when submission templated to v2

* Protect against no user in articles/new
2018-10-08 16:35:02 -04:00