Commit graph

53 commits

Author SHA1 Message Date
Philip How
78b42c5efd
Add trusted role via API (#20455)
* rubocop

* use has_trusted_role? in tests, not trusted? due to pesky caching issues

* swagger
2023-12-18 18:38:05 +00:00
Anna Buianova
81b042ee25
Give admins the ability to add spam role to users via the API (#20445) 2023-12-12 14:35:55 +00:00
Anna Buianova
df0b134ec4
Added followers count to /api/users/me endpoint (#20378)
* Added followers_count to /api/users/me

* Updated the api user docs

* Rubocop fixes fro swagger_helper

* Added me jbuilder view for api/v0
2023-11-22 20:22:06 +00:00
Ben Halpern
eccd5fd9e3
Add custom_display_label to billboards and update API (#20355)
* Add a/b test for which comments to show in feed

* Adjust figure

* Started at

* Add custom_display_label to billboards and update API

* Add custom_display_label to billboards and update API
2023-11-15 09:57:39 -05:00
Anna Buianova
a315bc18a6
Paginate api comments (#20304)
* Comments api pagination

* Comments api docs

* Removed Comments::Tree
2023-11-02 15:59:15 -04:00
Joshua Wehner
2c138d86ef
Add or remove limited role via API (#20136)
* Refactor API user suspend, make room for more roles

* Handle adding limited

* Handle remove limited

* And swagger docs

* Update & refactor roles spec

* Remove old route

* Remove old specs
2023-09-26 09:57:14 -04:00
Ben Halpern
22f836edc2
Add priority weight to billboards (#20019)
* Add priority weight to billboards

* Rewrite query as activerecord

* Change naming from priority_weight to just weight
2023-09-05 16:04:18 -04:00
Anna Buianova
7e83f18eca
Renamed display ad leftovers (test descriptions, swagger) (#20007) 2023-08-30 17:52:55 +03:00
Anna Buianova
2d6b740940
Renamed DisplayAd model to Billboard (#19993)
* Renamed Resource Admin: DisplayAd to Billboard

* Renamed DisplayAd to Billboard

* Added a data update script for roles
2023-08-28 08:09:36 -04:00
PJ
9725160709
Update billboard API to support target geolocations (#19857)
* update params to permit target_geolocations

* API docs

* fix param and JSON schema issues

* update docs again
2023-08-10 19:11:30 +01:00
Duke Greene
9a6f04bd37
api v1 endpoint for creating an organization (#19778)
* api v1 endpoint for creating an organization

* address failing specs, regenerate swagger docs

* remove old comment in destroy now that woreker call takes third argument

* refactor our services for profile images into images folder
2023-07-21 07:43:56 -04:00
Duke Greene
dd7e34ac53
define api v1 routes for organizations (#19681)
* define api routes and create controllers, sketch out index and create actions

* add api v1 organizations CRUD spec and docs spec, need to run swagger

* swagger dry run on admin organizations routes, typo fix in api.rb

* flesh out specs and sketch out admin actions

* move actions out of concerns/include pattern and into v1 inline

* remove private constant call

* add v1 accept header to doc spec, fix syntax in a before block

* update controllers to address failing specs

* simplify controller and clarify route config

* flesh out tests for errors

* fix long line

* add missing commas

* return username show route to v0 concern controller

* create separate show route and action name, remove nesting from create/update params requirement

* clean up syntax in controller params and update show path in specs; move routes

* fix up syntax in params permit

* create organization in index spec

* one more syntax tweak for org params

* refactoring to one show route that handles username or id

* tweak spec syntax to expect the right array

* tweak controller and specs, simplify routing to show

* remove create route, action, and specs from this branch

* add clarifying comment in show controller action

* add explicit not found return to show route

* fix controller formatting causing 404 errors

* remove comment, update specs

* remove commment and fix id show response and specs

* fix show route and request spec for username param

* update unauthorized user specs to use put for now instead of post, regenerate swagger docs

* adjust update 422 spec to break org validity

* fix admin update spec, rerun swagger

* reorganiza controller actions, update specs, ensure authorized update and delete

* improve spec, handle finding one org more gracefully, delete via worker

* copy routes into api namespace instead of moving them from general namespace

* update param in v0 show route to fit more general naming

* regenerate v1 swagger docs

* use profile image url getter in update controller response

* update swagger docs and remove unneeded comment from org' model

* configure organizations destroy action for super admins only (for now)
2023-07-19 09:51:05 -04:00
Joshua Wehner
e0d7658138
Follow-ups for suggested organizations follows during onboarding (#19619)
* Documentation for /api/follows end-point

* Rename and refactor User suggester

* Clean up feature flag

* User average count should be unscoped
2023-06-29 11:49:01 +02:00
Ben Halpern
5d6dc64245
Add ability to mark billboard (display_ad) as "priority" (boolean) (#19599)
* Add ability to mark billboard (display_ad) as "priority" (boolean)

* Fix invocation

* Update spec/models/display_ad_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/models/display_ad_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/models/display_ad_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/models/display_ad_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-12 16:28:15 -04:00
Joshua Wehner
abcd4ac3c8
Add ability to assign arbitrary segment ID to /display_ads API (#19529)
* DisplayAd audience_segment_id in API

* Rubocop

* Manual not valid if missing id

* manual-type requires an id

* Better audience_segment_type reader

* Use inclusion validation

* Swagger update

* Remove unnecessary
2023-05-31 18:11:35 +02:00
PJ
453c2eeccb
Manual Audience Segments API read endpoints (#19542)
* getting and listing segments

* get list of users in segment

* docs???
2023-05-26 15:10:26 +01:00
PJ
795cfc3da0
Manual Audience Segments API write endpoints (#19476)
* add composite index to segmented_users table

* bulk queries for segmented users

* create segment endpoint

* adding and removing users

* deleting segments 😪

* fix time precision in specs

* api docs 🎉

* pluck improvements that couldn't be cherry-picked

* better service objects; also introduce batch upserting

* docs???
2023-05-25 20:37:18 +01:00
Lawrence
1b32e9a8e3
Hero Billboard Placement (#19467)
* init

* add option to swagger docs

* in_house validation

* filtered ad quesry changes

* styling and prioritizing home hero banner over campaign banner

* rubocop

* typo

* broken spec

* more spec fixes

* found the spec break culprit

* derp

* Update app/views/shared/_display_ad.html.erb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update app/controllers/stories_controller.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* remove immediate return

* styling feedback and moving banner to articles index

* remove nil

* updated styling

* add signed in bool

* add feature flag

* remove feature flag data scripts

---------

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-05-18 12:37:32 -05:00
Joshua Wehner
7a9d71666f
Refactor for_display to pass article instead of params (#19376)
* Refactor for_display to pass article instead of params

* Refactor: use options in FilteredAdsQuery, deconstruct article in DisplayAd.for_display

* Typo

* Restore applicable comments
2023-04-26 16:57:10 +02:00
Joshua Wehner
dc1ab81401
Allow DisplayAd to target users via audience segmentation (#19284)
* Trying some models for audience segmentation

* AudienceSegment basics

* Attach AudienceSegment to DisplayAd

* Possibly use a DUS to populate AudienceSegments

* Add to display ad form UI

* Add to display ad API

* Refresh strategy for audience segments

* Add user_id to async ads query

* Maybe :testing -> :manual, for no-refresh segment

* Test & tweak segment refresh

* Testing audience_segment#refresh logic

* Coverage: testing human_readable

* Scope segment refresh to recently active users

* Tweak logic for when to refresh

* Tweak experience levels to match SettingsHelper

* Test for front-end logic

* Fix test, hope this helps coverage?

* Better test names

* One worker for all, many workers for each, perform_bulk

* Fix audience segment UI, needs to use id, not enum

* cron/schedule should RefreshAll

* Singular id in RefreshWorker
2023-04-25 08:41:10 -04:00
Ridhwana
940c67a904
Load post_sidebar billboard asynchronously (#19317)
* feat: add a route to the async_info for display ads

* feat: load the billboard asyncronously

* feat: move the methods to the display_ads controller

* feat: handle params better

* feat: cache control headers

* feat: test fastly caching headers on display ads

* fix: surrogate key test

* feat: use safe navigation operator to handle cases where there is no article id

* fix: article id present then find the article

* feat: add a response test

* Fragment caching

* feat: update the article decorator

* feat: update cache keys for fragment

* feat: remove an empty line

* feat: add article id

* feat: bust cache

* feat: setup dropdown for billboard

* chore: add chunk to same line

* feat: add to safe params for caching

* Update app/controllers/display_ads_controller.rb

Co-authored-by: Joshua Wehner <joshua@forem.com>

* feat: remove the cache deletion

* feat: update the routes to follow a new scope

* feat: update the cache params

* feat: get and replace all ads on the article page

* feat: do not go into the if statement if there is no async url property so that the ad fails gracefully

* chore: remove duplicate pack

* Update app/views/articles/show.html.erb

Co-authored-by: Joshua Wehner <joshua@forem.com>

* Update app/views/articles/_sticky_nav.html.erb

Co-authored-by: Joshua Wehner <joshua@forem.com>

* chore: add other params

* feat: allows adding placeholder content in the ad if need be

---------

Co-authored-by: Joshua Wehner <joshua@forem.com>
2023-04-13 19:23:27 +02:00
Rajat Talesra
cbc19ca6c5
New home feed display ads API documentation update (#19306)
* Basic implementation of all 3 ad placements

* UI fixes

* Dropdown bug fix

* Optimised code

* Updated tests

* Updated tes

* EOF added

* Improved a11y

* Display Ad documentation updates
2023-04-12 19:20:16 +05:30
Joshua Wehner
d3f8e127fa
Add an article exclusion list to Billboards (#19280)
* Add exclude_article_ids int array

* Add specs, normalize inputs better

* Add to form & controller

* Add exclude_article_ids to DisplayAd API

* Use exclude_article_ids in query

* Rubocop

* Comment typo

* Tweak rspec example length config

* Arguments all the way down

* Typo

* Update spec/requests/api/v1/docs/display_ads_spec.rb

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>

* Update spec/requests/api/v1/docs/display_ads_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Swagger schema for Display Ad

---------

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-04-05 09:10:22 -04:00
Joshua Wehner
db2b571bd6
Require an owner for 'community' billboards (#19167)
* Require an owner for 'community' billboards

* Reduce flakiness in this unrelated test
2023-02-27 14:22:47 +01:00
Joshua Wehner
c251f4000d
Add creator to DisplayAd (#19126) 2023-02-22 14:17:22 -05:00
Anna Buianova
efe540dfce
Billboards type_of: added field to the API and small admin form changes (#19125)
Co-authored-by: Joshua Wehner <joshua.wehner@gmail.com>
Co-authored-by: Mac Siri <mac@forem.com>
2023-02-21 14:17:40 -05:00
Joshua Wehner
a4654f2d2f
Reaction emoji with consistent underscores (#19116) 2023-02-15 08:32:19 +01:00
Fernando Valverde
b2444d032d
/organizations api docs (#19055)
* /organizations api docs

* Remove Listings support
2023-02-03 15:12:03 -06:00
Fernando Valverde
c6419d7300
/tags api docs (#19048)
* /tags api docs

* Merge main
2023-02-03 14:11:38 -06:00
Fernando Valverde
bb7e193b3e
/videos api docs (#19049)
* /videos api docs

* Merge main
2023-02-03 10:22:57 -06:00
Fernando Valverde
13288c5626
API V1 Users docs (#19046)
* /users/me api docs

* Updated api_v1.json

* Missing users api docs
2023-02-03 05:43:48 -06:00
Joshua Wehner
fd7021b001
Pages API: create, update, and delete (#19009)
* Pages API pt 1 (read/get/index+show)

* Update spec/requests/api/v1/docs/pages_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/requests/api/v1/docs/pages_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* API Key not required for index & show

* API Feature flag has long since been removed

* Page schema

* Fix spec broken by merge

* Temporary bugfix: slug uniqueness not working for Page

* Pages API endpoints for create, update, and destroy

* Fix swagger error

---------

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-02-02 17:24:11 +01:00
Fernando Valverde
db821a806f
/comments API docs (#18983)
* file

* Comments API
2023-01-25 12:06:43 -06:00
Joshua Wehner
7f41dae631
Pages API: Read (get index+show) (#18970)
* Pages API pt 1 (read/get/index+show)

* Update spec/requests/api/v1/docs/pages_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/requests/api/v1/docs/pages_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* API Key not required for index & show

* API Feature flag has long since been removed

* Page schema

* Fix spec broken by merge

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-01-25 17:15:27 +01:00
Fernando Valverde
8c62f9d6b3
Add the missing API docs for /articles (#18848)
* Progress on more articles API docs

* Some progress

* Broken update article doc spec but some progress

* Fix articles put rswag spec

* Fix spec

* Add missing specs

* Apply PR review feedback
2023-01-24 13:44:29 -06:00
Lawrence
0ac9852663
[API v1 docs] Followed Tags (#18952)
* Followed Tags swag docs

* Update spec/requests/api/v1/docs/followed_tags_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add to swagger helper

* minor tweaks

* more cleanup

* syntax change

* name change

* User doesn't have to be an admin

* Update spec/requests/api/v1/docs/followed_tags_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spec/requests/api/v1/docs/followed_tags_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* update v1 json structure

* Update spec/swagger_helper.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update spec/requests/api/v1/docs/followed_tags_spec.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* re-generate swagger file

* Update spec/requests/api/v1/docs/followed_tags_spec.rb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* regenerated swagger file

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-01-23 13:28:36 -06:00
Ridhwana
03bee374d2
[API v1 docs] Followers (#18965) 2023-01-20 15:03:39 +02:00
Ridhwana
bf88b1e125
[API v1 docs] Profile Images by Username (#18951) 2023-01-13 17:35:47 +02:00
Anna Buianova
a2d26df17b
[API V1 docs] Podcast Episodes (#18908)
* Podcast episodes api swagger docs (start)

* Podcast Episodes api swagger docs

* Fixed wording

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Fixed wording

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Removed commented code

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2023-01-10 15:01:22 +03:00
Joshua Wehner
0e25b1413e
Update DisplayAd API to allow setting tag_list (#18891) 2023-01-04 13:59:20 +01:00
Ridhwana
73335f3a56
[API V1 docs] Reading List (#18888)
* feat: add the docs spec file fro readinglist

* feat: add the api_v1.json file
2022-12-22 13:26:31 +02:00
Fernando Valverde
ef854eac77
v1 articles me + published + unpublished dics (#18810) 2022-12-08 10:38:25 -06:00
Joshua Wehner
a06ab31416
DisplayAd API: Write endpoints (#18736)
* Try a create endpoint

* Try an update endpoint for display_ads

* Try a delete endpoint for display_ads (unpublish)

* Unpublish

* Permit tags as well

* Update docs for DisplayAd tags via API/swagger
2022-12-05 11:12:24 +01:00
Fernando Valverde
99f04b9119
GET /articles/me/all (#18797) 2022-12-02 08:28:16 -06:00
Josh Puetz
b4a4d59581
Document a v0 endpoint in v1 (#18493)
Co-authored-by: Fernando Valverde <fernando@fdo.cr>
2022-12-01 06:39:42 -06:00
Joshua Wehner
7c82d128ff
DisplayAd API: Read endpoints (#18726)
* DisplayAd API: Read endpoints

* Updated swagger docs for display_ads read endpoints

* Update swagger with type_of

* Remove extraneous comment

* Restrict authentication to strictly api_key
2022-11-21 09:31:01 +01:00
Fernando Valverde
1f6c53a20c
Update per_page_max in API endpoints + docs bump (#18415)
* Update per_page_max in API endpoints + docs bump

* Small tweak

* Fix spec typo
2022-09-02 14:07:19 -06:00
Andy George
fada329309
remove manual changes to autogenerated file (#18414) 2022-09-02 06:54:33 -05:00
Andy George
be27fe74ab
Utilize ApplicationConfig["API_PER_PAGE_MAX"] (#18394)
* add ENV["API_PER_PAGE_LIMIT"]

* cast to int

* add private_constant PER_PAGE_MAX

* use 1000 int

* typo

* use reduced count for ListingsController

* typo

* set max/default in ArticleApiIndexService

* update initializer in ArticleApiIndexService

* Update app/controllers/concerns/api/articles_controller.rb

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

* Apply suggestions from code review

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

* update API docs

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2022-08-30 13:46:39 -05:00
Joshua Wehner
2ff67bda24
Try an idempotentish reaction create API (#18377)
* Try an idempotentish reaction create API

* Add tests for create API endpoint

* Try -> ReactionHandler

* Fix existing tests first

* Tests for .toggle; fix broken handle_existing

* Use the Handler

* Tweak http status for reaction create

* Use the category reader

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-08-30 16:43:18 +02:00