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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug-report.md +23 -18
  3. data/.github/workflows/build.yml +1 -1
  4. data/.github/workflows/release.yml +1 -1
  5. data/.github/workflows/rubocop.yml +2 -2
  6. data/CHANGELOG.md +20 -1
  7. data/CODE_OF_CONDUCT.md +46 -0
  8. data/Gemfile.lock +7 -9
  9. data/README.md +0 -1
  10. data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +5 -1
  11. data/app/controllers/concerns/shopify_app/ensure_installed.rb +2 -2
  12. data/app/controllers/shopify_app/callback_controller.rb +15 -14
  13. data/config/routes.rb +1 -1
  14. data/docs/Upgrading.md +25 -1
  15. data/docs/shopify_app/controller-concerns.md +21 -0
  16. data/docs/shopify_app/generators.md +2 -2
  17. data/docs/shopify_app/sessions.md +26 -17
  18. data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_expires_at_column.erb +5 -0
  19. data/lib/generators/shopify_app/user_model/user_model_generator.rb +20 -0
  20. data/lib/shopify_app/configuration.rb +8 -0
  21. data/lib/shopify_app/controller_concerns/embedded_app.rb +12 -4
  22. data/lib/shopify_app/controller_concerns/login_protection.rb +15 -11
  23. data/lib/shopify_app/engine.rb +1 -2
  24. data/lib/shopify_app/session/session_repository.rb +12 -5
  25. data/lib/shopify_app/session/shop_session_storage.rb +4 -0
  26. data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +4 -0
  27. data/lib/shopify_app/session/user_session_storage.rb +4 -0
  28. data/lib/shopify_app/session/user_session_storage_with_scopes.rb +25 -0
  29. data/lib/shopify_app/version.rb +1 -1
  30. data/lib/shopify_app.rb +0 -3
  31. data/package.json +1 -1
  32. data/shopify_app.gemspec +2 -3
  33. metadata +8 -28
  34. data/app/controllers/concerns/shopify_app/authenticated.rb +0 -17
  35. data/app/controllers/concerns/shopify_app/require_known_shop.rb +0 -16
  36. data/docs/shopify_app/script-tags.md +0 -28
  37. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +0 -42
  38. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +0 -63
  39. data/lib/shopify_app/controller_concerns/itp.rb +0 -50
  40. data/lib/shopify_app/jobs/scripttags_manager_job.rb +0 -16
  41. data/lib/shopify_app/managers/scripttags_manager.rb +0 -85
@@ -1,21 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "browser_sniffer"
4
-
5
3
  module ShopifyApp
6
4
  module LoginProtection
7
5
  extend ActiveSupport::Concern
8
6
  include ShopifyApp::SanitizedParams
9
7
 
10
8
  included do
11
- if defined?(ShopifyApp::RequireKnownShop) &&
12
- defined?(ShopifyApp::EnsureInstalled) &&
13
- ancestors.include?(ShopifyApp::RequireKnownShop || ShopifyApp::EnsureInstalled)
9
+ if defined?(ShopifyApp::EnsureInstalled) &&
10
+ ancestors.include?(ShopifyApp::EnsureInstalled)
14
11
  message = <<~EOS
15
- We detected the use of incompatible concerns (RequireKnownShop/EnsureInstalled and LoginProtection) in #{name},
16
- which may lead to unpredictable behavior. In a future release of this library this will raise an error.
12
+ We detected the use of incompatible concerns (EnsureInstalled and LoginProtection) in #{name},
13
+ which leads to unpredictable behavior. You cannot include both concerns in the same controller.
17
14
  EOS
18
- ShopifyApp::Logger.deprecated(message, "22.0.0")
15
+ raise message
19
16
  end
20
17
 
21
18
  rescue_from ShopifyAPI::Errors::HttpResponseError, with: :handle_http_error
@@ -30,6 +27,12 @@ module ShopifyApp
30
27
  return redirect_to_login
31
28
  end
32
29
 
30
+ if ShopifyApp.configuration.check_session_expiry_date && current_shopify_session.expired?
31
+ ShopifyApp::Logger.debug("Session expired, redirecting to login")
32
+ clear_shopify_session
33
+ return redirect_to_login
34
+ end
35
+
33
36
  if ShopifyApp.configuration.reauth_on_access_scope_changes &&
34
37
  !ShopifyApp.configuration.user_access_scopes_strategy.covers_scopes?(current_shopify_session)
35
38
  clear_shopify_session
@@ -141,10 +144,11 @@ module ShopifyApp
141
144
  end
142
145
 
143
146
  def close_session
144
- clear_shopify_session
145
147
  ShopifyApp::Logger.debug("Closing session")
146
- ShopifyApp::Logger.debug("Redirecting to #{login_url_with_optional_shop}")
147
- redirect_to(login_url_with_optional_shop)
148
+ clear_shopify_session
149
+
150
+ ShopifyApp::Logger.debug("Redirecting to login")
151
+ redirect_to_login
148
152
  end
149
153
 
150
154
  def handle_http_error(error)
@@ -5,7 +5,7 @@ module ShopifyApp
5
5
  private
6
6
 
7
7
  def args_info(job)
8
- log_disabled_classes = ["ShopifyApp::ScripttagsManagerJob", "ShopifyApp::WebhooksManagerJob"]
8
+ log_disabled_classes = ["ShopifyApp::WebhooksManagerJob"]
9
9
  return "" if log_disabled_classes.include?(job.class.name)
10
10
 
11
11
  super
@@ -35,7 +35,6 @@ module ShopifyApp
35
35
  ActiveSupport.on_load(:active_job) do
36
36
  if ActiveJob::Base.respond_to?(:log_arguments?)
37
37
  WebhooksManagerJob.log_arguments = false
38
- ScripttagsManagerJob.log_arguments = false
39
38
  elsif ActiveJob::Logging::LogSubscriber.private_method_defined?(:args_info)
40
39
  ActiveJob::Logging::LogSubscriber.prepend(RedactJobParams)
41
40
  end
@@ -23,6 +23,14 @@ module ShopifyApp
23
23
  user_storage.retrieve_by_shopify_user_id(user_id)
24
24
  end
25
25
 
26
+ def destroy_shop_session_by_domain(shopify_domain)
27
+ shop_storage.destroy_by_shopify_domain(shopify_domain)
28
+ end
29
+
30
+ def destroy_user_session_by_shopify_user_id(user_id)
31
+ user_storage.destroy_by_shopify_user_id(user_id)
32
+ end
33
+
26
34
  def store_shop_session(session)
27
35
  shop_storage.store(session)
28
36
  end
@@ -73,18 +81,17 @@ module ShopifyApp
73
81
  def delete_session(id)
74
82
  match = id.match(/^offline_(.*)/)
75
83
 
76
- record = if match
84
+ if match
77
85
  domain = match[1]
78
86
  ShopifyApp::Logger.debug("Destroying session by domain - domain: #{domain}")
79
- Shop.find_by(shopify_domain: match[1])
87
+ destroy_shop_session_by_domain(domain)
88
+
80
89
  else
81
90
  shopify_user_id = id.split("_").last
82
91
  ShopifyApp::Logger.debug("Destroying session by user - user_id: #{shopify_user_id}")
83
- User.find_by(shopify_user_id: shopify_user_id)
92
+ destroy_user_session_by_shopify_user_id(shopify_user_id)
84
93
  end
85
94
 
86
- record.destroy
87
-
88
95
  true
89
96
  end
90
97
 
@@ -27,6 +27,10 @@ module ShopifyApp
27
27
  construct_session(shop)
28
28
  end
29
29
 
30
+ def destroy_by_shopify_domain(domain)
31
+ destroy_by(shopify_domain: domain)
32
+ end
33
+
30
34
  private
31
35
 
32
36
  def construct_session(shop)
@@ -29,6 +29,10 @@ module ShopifyApp
29
29
  construct_session(shop)
30
30
  end
31
31
 
32
+ def destroy_by_shopify_domain(domain)
33
+ destroy_by(shopify_domain: domain)
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def construct_session(shop)
@@ -28,6 +28,10 @@ module ShopifyApp
28
28
  construct_session(user)
29
29
  end
30
30
 
31
+ def destroy_by_shopify_user_id(user_id)
32
+ destroy_by(shopify_user_id: user_id)
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def construct_session(user)
@@ -15,6 +15,7 @@ module ShopifyApp
15
15
  user.shopify_token = auth_session.access_token
16
16
  user.shopify_domain = auth_session.shop
17
17
  user.access_scopes = auth_session.scope.to_s
18
+ user.expires_at = auth_session.expires
18
19
 
19
20
  user.save!
20
21
  user.id
@@ -30,6 +31,10 @@ module ShopifyApp
30
31
  construct_session(user)
31
32
  end
32
33
 
34
+ def destroy_by_shopify_user_id(user_id)
35
+ destroy_by(shopify_user_id: user_id)
36
+ end
37
+
33
38
  private
34
39
 
35
40
  def construct_session(user)
@@ -52,6 +57,7 @@ module ShopifyApp
52
57
  scope: user.access_scopes,
53
58
  associated_user_scope: user.access_scopes,
54
59
  associated_user: associated_user,
60
+ expires: user.expires_at,
55
61
  )
56
62
  end
57
63
  end
@@ -67,5 +73,24 @@ module ShopifyApp
67
73
  rescue NotImplementedError, NoMethodError
68
74
  raise NotImplementedError, "#access_scopes= must be defined to hook into stored access scopes"
69
75
  end
76
+
77
+ def expires_at=(expires_at)
78
+ super
79
+ rescue NotImplementedError, NoMethodError
80
+ if ShopifyApp.configuration.check_session_expiry_date
81
+ raise NotImplementedError,
82
+ "#expires_at= must be defined to handle storing the session expiry date"
83
+ end
84
+ end
85
+
86
+ def expires_at
87
+ super
88
+ rescue NotImplementedError, NoMethodError
89
+ if ShopifyApp.configuration.check_session_expiry_date
90
+ raise NotImplementedError, "#expires_at must be defined to check the session expiry date"
91
+ end
92
+
93
+ nil
94
+ end
70
95
  end
71
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyApp
4
- VERSION = "21.9.0"
4
+ VERSION = "22.00.0"
5
5
  end
data/lib/shopify_app.rb CHANGED
@@ -44,7 +44,6 @@ module ShopifyApp
44
44
  require "shopify_app/controller_concerns/csrf_protection"
45
45
  require "shopify_app/controller_concerns/localization"
46
46
  require "shopify_app/controller_concerns/frame_ancestors"
47
- require "shopify_app/controller_concerns/itp"
48
47
  require "shopify_app/controller_concerns/sanitized_params"
49
48
  require "shopify_app/controller_concerns/redirect_for_embedded"
50
49
  require "shopify_app/controller_concerns/login_protection"
@@ -56,11 +55,9 @@ module ShopifyApp
56
55
 
57
56
  # jobs
58
57
  require "shopify_app/jobs/webhooks_manager_job"
59
- require "shopify_app/jobs/scripttags_manager_job"
60
58
 
61
59
  # managers
62
60
  require "shopify_app/managers/webhooks_manager"
63
- require "shopify_app/managers/scripttags_manager"
64
61
 
65
62
  # middleware
66
63
  require "shopify_app/middleware/jwt_middleware"
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify_app",
3
- "version": "21.9.0",
3
+ "version": "22.00.0",
4
4
  "repository": "git@github.com:Shopify/shopify_app.git",
5
5
  "author": "Shopify",
6
6
  "license": "MIT",
data/shopify_app.gemspec CHANGED
@@ -10,17 +10,16 @@ Gem::Specification.new do |s|
10
10
  s.author = "Shopify"
11
11
  s.summary = "This gem is used to get quickly started with the Shopify API"
12
12
 
13
- s.required_ruby_version = ">= 2.7"
13
+ s.required_ruby_version = ">= 3.0"
14
14
 
15
15
  s.metadata["allowed_push_host"] = "https://rubygems.org"
16
16
 
17
17
  s.add_runtime_dependency("activeresource") # TODO: Remove this once all active resource dependencies are removed
18
18
  s.add_runtime_dependency("addressable", "~> 2.7")
19
- s.add_runtime_dependency("browser_sniffer", "~> 2.0")
20
19
  s.add_runtime_dependency("jwt", ">= 2.2.3")
21
20
  s.add_runtime_dependency("rails", "> 5.2.1")
22
21
  s.add_runtime_dependency("redirect_safely", "~> 1.0")
23
- s.add_runtime_dependency("shopify_api", "~> 13.4")
22
+ s.add_runtime_dependency("shopify_api", "~> 14")
24
23
  s.add_runtime_dependency("sprockets-rails", ">= 2.0.0")
25
24
 
26
25
  s.add_development_dependency("byebug")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.9.0
4
+ version: 22.00.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-16 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.7'
41
- - !ruby/object:Gem::Dependency
42
- name: browser_sniffer
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: jwt
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +86,14 @@ dependencies:
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '13.4'
89
+ version: '14'
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '13.4'
96
+ version: '14'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: sprockets-rails
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -301,6 +287,7 @@ files:
301
287
  - ".ruby-version"
302
288
  - ".spin/rails/prepare-application"
303
289
  - CHANGELOG.md
290
+ - CODE_OF_CONDUCT.md
304
291
  - CONTRIBUTING.md
305
292
  - Gemfile
306
293
  - Gemfile.lock
@@ -312,11 +299,9 @@ files:
312
299
  - app/assets/javascripts/shopify_app/app_bridge_3.7.8.js
313
300
  - app/assets/javascripts/shopify_app/app_bridge_redirect.js
314
301
  - app/assets/javascripts/shopify_app/redirect.js
315
- - app/controllers/concerns/shopify_app/authenticated.rb
316
302
  - app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
317
303
  - app/controllers/concerns/shopify_app/ensure_has_session.rb
318
304
  - app/controllers/concerns/shopify_app/ensure_installed.rb
319
- - app/controllers/concerns/shopify_app/require_known_shop.rb
320
305
  - app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
321
306
  - app/controllers/shopify_app/authenticated_controller.rb
322
307
  - app/controllers/shopify_app/callback_controller.rb
@@ -364,7 +349,6 @@ files:
364
349
  - docs/shopify_app/generators.md
365
350
  - docs/shopify_app/handling-access-scopes-changes.md
366
351
  - docs/shopify_app/logging.md
367
- - docs/shopify_app/script-tags.md
368
352
  - docs/shopify_app/sessions.md
369
353
  - docs/shopify_app/testing.md
370
354
  - docs/shopify_app/webhooks.md
@@ -374,8 +358,6 @@ files:
374
358
  - lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb
375
359
  - lib/generators/shopify_app/add_app_uninstalled_job/add_app_uninstalled_job_generator.rb
376
360
  - lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt
377
- - lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
378
- - lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb
379
361
  - lib/generators/shopify_app/add_privacy_jobs/add_privacy_jobs_generator.rb
380
362
  - lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt
381
363
  - lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt
@@ -416,6 +398,7 @@ files:
416
398
  - lib/generators/shopify_app/shop_model/templates/shops.yml
417
399
  - lib/generators/shopify_app/shopify_app_generator.rb
418
400
  - lib/generators/shopify_app/user_model/templates/db/migrate/add_user_access_scopes_column.erb
401
+ - lib/generators/shopify_app/user_model/templates/db/migrate/add_user_expires_at_column.erb
419
402
  - lib/generators/shopify_app/user_model/templates/db/migrate/create_users.erb
420
403
  - lib/generators/shopify_app/user_model/templates/user.rb
421
404
  - lib/generators/shopify_app/user_model/templates/users.yml
@@ -431,7 +414,6 @@ files:
431
414
  - lib/shopify_app/controller_concerns/embedded_app.rb
432
415
  - lib/shopify_app/controller_concerns/ensure_billing.rb
433
416
  - lib/shopify_app/controller_concerns/frame_ancestors.rb
434
- - lib/shopify_app/controller_concerns/itp.rb
435
417
  - lib/shopify_app/controller_concerns/localization.rb
436
418
  - lib/shopify_app/controller_concerns/login_protection.rb
437
419
  - lib/shopify_app/controller_concerns/payload_verification.rb
@@ -440,10 +422,8 @@ files:
440
422
  - lib/shopify_app/controller_concerns/webhook_verification.rb
441
423
  - lib/shopify_app/engine.rb
442
424
  - lib/shopify_app/errors.rb
443
- - lib/shopify_app/jobs/scripttags_manager_job.rb
444
425
  - lib/shopify_app/jobs/webhooks_manager_job.rb
445
426
  - lib/shopify_app/logger.rb
446
- - lib/shopify_app/managers/scripttags_manager.rb
447
427
  - lib/shopify_app/managers/webhooks_manager.rb
448
428
  - lib/shopify_app/middleware/jwt_middleware.rb
449
429
  - lib/shopify_app/session/in_memory_session_store.rb
@@ -481,14 +461,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
481
461
  requirements:
482
462
  - - ">="
483
463
  - !ruby/object:Gem::Version
484
- version: '2.7'
464
+ version: '3.0'
485
465
  required_rubygems_version: !ruby/object:Gem::Requirement
486
466
  requirements:
487
467
  - - ">="
488
468
  - !ruby/object:Gem::Version
489
469
  version: '0'
490
470
  requirements: []
491
- rubygems_version: 3.5.4
471
+ rubygems_version: 3.5.6
492
472
  signing_key:
493
473
  specification_version: 4
494
474
  summary: This gem is used to get quickly started with the Shopify API
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyApp
4
- module Authenticated
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- ShopifyApp::Logger.deprecated(
9
- "Authenticated has been replaced by EnsureHasSession."\
10
- " Please use the EnsureHasSession controller concern for the same behavior",
11
- "22.0.0",
12
- )
13
- end
14
-
15
- include ShopifyApp::EnsureHasSession
16
- end
17
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyApp
4
- module RequireKnownShop
5
- extend ActiveSupport::Concern
6
- include ShopifyApp::EnsureInstalled
7
-
8
- included do
9
- ShopifyApp::Logger.deprecated(
10
- "RequireKnownShop has been replaced by EnsureInstalled."\
11
- " Please use the EnsureInstalled controller concern for the same behavior",
12
- "22.0.0",
13
- )
14
- end
15
- end
16
- end
@@ -1,28 +0,0 @@
1
- # ScriptTags
2
-
3
- #### Table of contents
4
-
5
- [Manage ScriptTags using the Shopify App initializer](#manage-scripttags-using-the-shopify-app-initializer)
6
-
7
- ## Manage ScriptTags using the Shopify App initializer
8
-
9
- As with webhooks, ShopifyApp can manage your app's [ScriptTags](https://shopify-dev-staging.shopifycloud.com/docs/admin-api/graphql/reference/online-store/scripttag) for you by setting which scripttags you require in the initializer:
10
-
11
- ```ruby
12
- ShopifyApp.configure do |config|
13
- config.scripttags = [
14
- {event:'onload', src: 'https://example.com/fancy.js'},
15
- {event:'onload', src: ->(domain) { dynamic_tag_url(domain) } }
16
- ]
17
- end
18
- ```
19
-
20
- You also need to have write_script_tags permission in the config scope in order to add script tags automatically:
21
-
22
- ```ruby
23
- config.scope = '... , write_script_tags'
24
- ```
25
-
26
- Scripttags are created in the same way as the [Webhooks](/docs/shopify_app/webhooks.md), with a background job which will create the required scripttags.
27
-
28
- If `src` responds to `call` its return value will be used as the scripttag's source. It will be called on scripttag creation and deletion.
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators/base"
4
-
5
- module ShopifyApp
6
- module Generators
7
- class AddMarketingActivityExtensionGenerator < Rails::Generators::Base
8
- source_root File.expand_path("../templates", __FILE__)
9
-
10
- def generate_app_extension
11
- ShopifyApp::Logger.deprecated("MarketingActivitiesController will be removed in an upcoming version", "22.0.0")
12
- template("marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb")
13
- generate_routes
14
- end
15
-
16
- private
17
-
18
- def generate_routes
19
- inject_into_file(
20
- "config/routes.rb",
21
- optimize_indentation(routes, 2),
22
- after: "root :to => 'home#index'\n",
23
- )
24
- end
25
-
26
- def routes
27
- <<~EOS
28
-
29
- resource :marketing_activities, only: [:create, :update] do
30
- patch :resume
31
- patch :pause
32
- patch :delete
33
- post :republish
34
- post :preload_form_data
35
- post :preview
36
- post :errors
37
- end
38
- EOS
39
- end
40
- end
41
- end
42
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class MarketingActivitiesController < ShopifyApp::ExtensionVerificationController
4
- def preload_form_data
5
- preload_data = {
6
- "form_data": {},
7
- }
8
- render(json: preload_data, status: :ok)
9
- end
10
-
11
- def update
12
- render(json: {}, status: :accepted)
13
- end
14
-
15
- def pause
16
- render(json: {}, status: :accepted)
17
- end
18
-
19
- def resume
20
- render(json: {}, status: :accepted)
21
- end
22
-
23
- def delete
24
- render(json: {}, status: :accepted)
25
- end
26
-
27
- def preview
28
- placeholder_img = "https://cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_small.png"
29
- preview_response = {
30
- "desktop": {
31
- "preview_url": placeholder_img,
32
- "content_type": "text/html",
33
- "width": 360,
34
- "height": 200,
35
- },
36
- "mobile": {
37
- "preview_url": placeholder_img,
38
- "content_type": "text/html",
39
- "width": 360,
40
- "height": 200,
41
- },
42
- }
43
- render(json: preview_response, status: :ok)
44
- end
45
-
46
- def create
47
- render(json: {}, status: :ok)
48
- end
49
-
50
- def republish
51
- render(json: {}, status: :accepted)
52
- end
53
-
54
- def errors
55
- request_id = params[:request_id]
56
- message = params[:message]
57
-
58
- ShopifyApp::Logger.info("[Marketing Activity App Error Feedback]"\
59
- "Request id: #{request_id}, message: #{message}")
60
-
61
- render(json: {}, status: :ok)
62
- end
63
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyApp
4
- # Cookie management helpers required for ITP implementation
5
- module Itp
6
- extend ActiveSupport::Concern
7
- included do
8
- ShopifyApp::Logger.deprecated("Itp will be removed in an upcoming version", "22.0.0")
9
- end
10
-
11
- private
12
-
13
- def set_test_cookie
14
- return unless ShopifyApp.configuration.embedded_app?
15
- return unless user_agent_can_partition_cookies
16
-
17
- session["shopify.cookies_persist"] = true
18
- end
19
-
20
- def set_top_level_oauth_cookie
21
- session["shopify.top_level_oauth"] = true
22
- end
23
-
24
- def clear_top_level_oauth_cookie
25
- session.delete("shopify.top_level_oauth")
26
- end
27
-
28
- def user_agent_is_mobile
29
- user_agent = BrowserSniffer.new(request.user_agent).browser_info
30
-
31
- user_agent[:name].to_s.match(/Shopify\sMobile/)
32
- end
33
-
34
- def user_agent_is_pos
35
- user_agent = BrowserSniffer.new(request.user_agent).browser_info
36
-
37
- user_agent[:name].to_s.match(/Shopify\sPOS/)
38
- end
39
-
40
- def user_agent_can_partition_cookies
41
- user_agent = BrowserSniffer.new(request.user_agent).browser_info
42
-
43
- is_safari = user_agent[:name].to_s.match(/Safari/)
44
-
45
- return false unless is_safari
46
-
47
- user_agent[:version].to_s.match(/12\.0/)
48
- end
49
- end
50
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyApp
4
- class ScripttagsManagerJob < ActiveJob::Base
5
- queue_as do
6
- ShopifyApp.configuration.scripttags_manager_queue_name
7
- end
8
-
9
- def perform(shop_domain:, shop_token:, scripttags:)
10
- ShopifyAPI::Auth::Session.temp(shop: shop_domain, access_token: shop_token) do
11
- manager = ScripttagsManager.new(scripttags, shop_domain)
12
- manager.create_scripttags
13
- end
14
- end
15
- end
16
- end