shopify_app 21.9.0 → 22.00.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug-report.md +23 -18
- data/.github/workflows/build.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/rubocop.yml +2 -2
- data/CHANGELOG.md +20 -1
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile.lock +7 -9
- data/README.md +0 -1
- data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +5 -1
- data/app/controllers/concerns/shopify_app/ensure_installed.rb +2 -2
- data/app/controllers/shopify_app/callback_controller.rb +15 -14
- data/config/routes.rb +1 -1
- data/docs/Upgrading.md +25 -1
- data/docs/shopify_app/controller-concerns.md +21 -0
- data/docs/shopify_app/generators.md +2 -2
- data/docs/shopify_app/sessions.md +26 -17
- data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_expires_at_column.erb +5 -0
- data/lib/generators/shopify_app/user_model/user_model_generator.rb +20 -0
- data/lib/shopify_app/configuration.rb +8 -0
- data/lib/shopify_app/controller_concerns/embedded_app.rb +12 -4
- data/lib/shopify_app/controller_concerns/login_protection.rb +15 -11
- data/lib/shopify_app/engine.rb +1 -2
- data/lib/shopify_app/session/session_repository.rb +12 -5
- data/lib/shopify_app/session/shop_session_storage.rb +4 -0
- data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +4 -0
- data/lib/shopify_app/session/user_session_storage.rb +4 -0
- data/lib/shopify_app/session/user_session_storage_with_scopes.rb +25 -0
- data/lib/shopify_app/version.rb +1 -1
- data/lib/shopify_app.rb +0 -3
- data/package.json +1 -1
- data/shopify_app.gemspec +2 -3
- metadata +8 -28
- data/app/controllers/concerns/shopify_app/authenticated.rb +0 -17
- data/app/controllers/concerns/shopify_app/require_known_shop.rb +0 -16
- data/docs/shopify_app/script-tags.md +0 -28
- data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +0 -42
- data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +0 -63
- data/lib/shopify_app/controller_concerns/itp.rb +0 -50
- data/lib/shopify_app/jobs/scripttags_manager_job.rb +0 -16
- data/lib/shopify_app/managers/scripttags_manager.rb +0 -85
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ShopifyApp
|
4
|
-
class ScripttagsManager
|
5
|
-
def self.queue(shop_domain, shop_token, scripttags)
|
6
|
-
ShopifyApp::ScripttagsManagerJob.perform_later(
|
7
|
-
shop_domain: shop_domain,
|
8
|
-
shop_token: shop_token,
|
9
|
-
# Procs cannot be serialized so we interpolate now, if necessary
|
10
|
-
scripttags: build_src(scripttags, shop_domain),
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.build_src(scripttags, domain)
|
15
|
-
scripttags.map do |tag|
|
16
|
-
next tag unless tag[:src].respond_to?(:call)
|
17
|
-
|
18
|
-
tag = tag.dup
|
19
|
-
tag[:src] = tag[:src].call(domain)
|
20
|
-
tag
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
attr_reader :required_scripttags, :shop_domain
|
25
|
-
|
26
|
-
def initialize(scripttags, shop_domain)
|
27
|
-
ShopifyApp::Logger.deprecated("The ScripttagsManager will become deprecated in an upcoming version", "22.0.0")
|
28
|
-
@required_scripttags = scripttags
|
29
|
-
@shop_domain = shop_domain
|
30
|
-
end
|
31
|
-
|
32
|
-
def recreate_scripttags!
|
33
|
-
destroy_scripttags
|
34
|
-
create_scripttags
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_scripttags
|
38
|
-
return unless required_scripttags.present?
|
39
|
-
|
40
|
-
expanded_scripttags.each do |scripttag|
|
41
|
-
create_scripttag(scripttag) unless scripttag_exists?(scripttag[:src])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def destroy_scripttags
|
46
|
-
scripttags = expanded_scripttags
|
47
|
-
ShopifyAPI::ScriptTag.all.each do |tag|
|
48
|
-
tag.delete if required_scripttag?(scripttags, tag)
|
49
|
-
end
|
50
|
-
|
51
|
-
@current_scripttags = nil
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def expanded_scripttags
|
57
|
-
self.class.build_src(required_scripttags, shop_domain)
|
58
|
-
end
|
59
|
-
|
60
|
-
def required_scripttag?(scripttags, tag)
|
61
|
-
scripttags.map { |w| w[:src] }.include?(tag.src)
|
62
|
-
end
|
63
|
-
|
64
|
-
def create_scripttag(attributes)
|
65
|
-
scripttag = ShopifyAPI::ScriptTag.new
|
66
|
-
attributes.each { |key, value| scripttag.public_send("#{key}=", value) }
|
67
|
-
|
68
|
-
begin
|
69
|
-
scripttag.save!
|
70
|
-
rescue ShopifyAPI::Errors::HttpResponseError => e
|
71
|
-
raise ::ShopifyApp::CreationFailed, e.message
|
72
|
-
end
|
73
|
-
|
74
|
-
scripttag
|
75
|
-
end
|
76
|
-
|
77
|
-
def scripttag_exists?(src)
|
78
|
-
current_scripttags[src]
|
79
|
-
end
|
80
|
-
|
81
|
-
def current_scripttags
|
82
|
-
@current_scripttags ||= ShopifyAPI::ScriptTag.all.index_by(&:src)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|