Added ShopPanel to home sidebar

• Added:
- ShopPanel to home sidebar
- DIssenter shop redux, api route/controller
This commit is contained in:
mgabdev
2020-07-01 21:33:10 -04:00
parent 0ca346b169
commit 095e646661
7 changed files with 228 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
class Api::V1::ShopController < Api::BaseController
before_action :require_user!
respond_to :json
skip_before_action :set_cache_headers
def index
type = params[:type]
if type == 'featured_products'
body = Redis.current.get("gabstore:featuredproducts")
if body.nil?
uri = URI("https://shop.dissenter.com/product/group/json")
uri.query = URI.encode_www_form({})
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
body = res.body
Redis.current.set("gabstore:featuredproducts", res.body)
Redis.current.expire("gabstore:featuredproducts", 15.minutes.seconds)
end
end
render json: body
else
raise GabSocial::NotPermittedError
end
end
end