Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/chaskiq/chaskiq
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Feb 22, 2024
2 parents e141a1d + 2f487ac commit a161e18
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
12 changes: 6 additions & 6 deletions app/controllers/api/v1/hooks/provider_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ def process_event
response_handler(response)
end

def find_application_package
@integration_pkg = AppPackageIntegration.decode(params[:id])
app = @integration_pkg.app
end

def oauth
response = @integration_pkg.receive_oauth_code(params)
pkg = AppPackageIntegration.decode(params[:id])
pkg = AppPackageIntegration.decode(params[:id] || params[:state])
redirect_to "/apps/#{pkg.app.key}/integrations"
end

def find_application_package
@integration_pkg = AppPackageIntegration.decode(params[:id] || params[:state])
app = @integration_pkg.app
end

def resolve_status(response)
return 422 if response[:status] == :error

Expand Down
5 changes: 5 additions & 0 deletions app/models/app_package_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AppPackageIntegration < ApplicationRecord
report_id
access_token
access_token_secret
refresh_token
user_id
user_token
credentials
Expand Down Expand Up @@ -174,6 +175,10 @@ def oauth_url
"#{Chaskiq::Config.get('HOST')}/api/v1/oauth/callback/#{encoded_id}"
end

def global_oauth_callback
"#{Chaskiq::Config.get('HOST')}/api/v1/oauth/global/callback"
end

def receive_oauth_code(params)
klass = message_api_klass.receive_oauth_code(params, self)
end
Expand Down
5 changes: 3 additions & 2 deletions app/services/payment_services/paddle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ def get_plans
)

res.filter do |o|
Plan.pluck(:id).include?(o.id)
Plan.all.map{|o| o[:id]}.include?(o.id)
end.map do |o|
p = Plan.get_by_id(o.id)
{
id: p["id"],
source: "paddle",
features: p.dig("features"),
name: p["name"],
pricing: o.recurring_price.USD
pricing: o.recurring_price.USD,
billing_type: o.recurring_price.billing_type
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/payment_services/stripe_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.sync_subscription(app)
def get_plans
res = Stripe::Price.list(limit: 20).data
data = res.filter do |o|
Plan.pluck(:id).include?(o.id)
Plan.all.map{|o| o["id"]}.include?(o.id)
end

data.map do |o|
Expand Down
6 changes: 2 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def self.fetch(name, fallback)

class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
# config.load_defaults 6.1
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
Expand All @@ -44,9 +43,6 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")


config.load_defaults '6.0'

config.encoding = 'utf-8'

config.assets.css_compressor = nil
Expand All @@ -55,6 +51,8 @@ class Application < Rails::Application

config.action_cable.disable_request_forgery_protection = true

config.active_storage.variant_processor = :mini_magick

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
Expand Down
10 changes: 10 additions & 0 deletions config/initializers/rotator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# a bug introduced in rails 7
# read: https://github.com/hotwired/turbo-rails/issues/340

Rails.application.config.after_initialize do |app|
key_generator = ActiveSupport::KeyGenerator.new app.secret_key_base,
iterations: 1000,
hash_digest_class: OpenSSL::Digest::SHA1

app.message_verifier("ActiveStorage").rotate(key_generator.generate_key("ActiveStorage"))
end
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
post 'hooks/receiver/:id' => 'api/v1/hooks/provider#process_event'
get 'hooks/receiver/:id' => 'api/v1/hooks/provider#process_event'


post 'oauth/global/callback' => 'api/v1/hooks/provider#oauth'
get 'oauth/global/callback' => 'api/v1/hooks/provider#oauth'

post 'oauth/callback/:id' => 'api/v1/hooks/provider#oauth'
get 'oauth/callback/:id' => 'api/v1/hooks/provider#oauth'

Expand Down

0 comments on commit a161e18

Please sign in to comment.