discourse_subscription_client 0.1.0.pre5 → 0.1.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -15
- data/app/models/subscription_client_subscription.rb +6 -1
- data/app/models/subscription_client_supplier.rb +6 -0
- data/config/routes.rb +1 -0
- data/config/settings.yml +0 -2
- data/db/migrate/20230223135957_add_products_to_subscription_client_suppliers.rb +7 -0
- data/extensions/discourse_subscription_client/{current_user.rb → current_user_serializer.rb} +12 -0
- data/extensions/discourse_subscription_client/site_serializer.rb +15 -0
- data/lib/discourse_subscription_client/engine.rb +26 -5
- data/lib/discourse_subscription_client/resources.rb +16 -3
- data/lib/discourse_subscription_client/subscriptions/result.rb +6 -109
- data/lib/discourse_subscription_client/subscriptions/update_result.rb +118 -0
- data/lib/discourse_subscription_client/subscriptions.rb +1 -1
- data/lib/discourse_subscription_client/version.rb +1 -1
- metadata +23 -6
- /data/app/jobs/{regular/discourse_subscription_client_find_resources.rb → discourse_subscription_client_find_resources.rb} +0 -0
- /data/app/jobs/{scheduled/discourse_subscription_client_update_notices.rb → discourse_subscription_client_update_notices.rb} +0 -0
- /data/app/jobs/{scheduled/discourse_subscription_client_update_subscriptions.rb → discourse_subscription_client_update_subscriptions.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3449957ada14519fd11be48009e904a8fbfc06d6f12f2ede952a1b7e426c2b53
|
4
|
+
data.tar.gz: 3befbc23e94b37dfcf7f9f7ecef9aa07d7bba851d2c9a0395a990af7adbcc501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 057bd00307d2c7f8a9d5aec6e71871efee9fa5ffe52bddee16ca4a3c2373cf21f7d9dfa18ea16be62435184c5112c4f4b2d9366f740189a8bddb293fbdfa404e
|
7
|
+
data.tar.gz: 9d2a38b104215c347bc51caa6725c0f1c5123de9cd9d0c916c825814cda2b9c3586c52332f1485c37858a073c0aad5258f6ab86055910b104a55ce2d47c215c5
|
data/README.md
CHANGED
@@ -1,28 +1,60 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# Discourse Subscription Client Gem
|
2
|
+
This gem is only for use with Discourse plugins. It provides subscription client support to a Discourse plugin, primarily for use with the Discourse Subscription Server plugin.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to your plugin's `plugin.rb` file
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem "discourse_subscription_client", "0.1.0.pre5", require_name: "discourse_subscription_client"
|
9
|
+
```
|
3
10
|
|
4
11
|
## Usage
|
5
|
-
How to use my plugin.
|
6
12
|
|
7
|
-
|
8
|
-
|
13
|
+
The gem API is accessible through the `DiscourseSubscriptionClient` class. Supported methods are described below.
|
14
|
+
|
15
|
+
### find_subscriptions
|
9
16
|
|
10
17
|
```ruby
|
11
|
-
|
18
|
+
DiscourseSubscriptionClient.find_subscriptions(resource_name)
|
12
19
|
```
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
|
21
|
+
#### Arguments
|
22
|
+
|
23
|
+
##### resource_name
|
24
|
+
|
25
|
+
The name of a resource defined in the `discourse-subscription-server` plugin's `subscription_server_subscriptions` setting.
|
26
|
+
|
27
|
+
#### Returns
|
28
|
+
|
29
|
+
Returns a `DiscourseSubscriptionClient::Subscriptions::Result` object, containing the supplier, resource and any active subscriptions.
|
30
|
+
|
31
|
+
#### Example
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
result = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
|
35
|
+
result.supplier # <DiscourseSubscriptionSupplier name="Pavilion" ...>
|
36
|
+
result.resource # <DiscourseSubscriptionResource name="discourse-custom-wizard" ...>
|
37
|
+
result.subscriptions # [<DiscourseSubscriptionSubscription product_name="Business" ...>]
|
17
38
|
```
|
18
39
|
|
19
|
-
|
20
|
-
|
21
|
-
|
40
|
+
## Development
|
41
|
+
|
42
|
+
### Tests
|
43
|
+
The gem has to create a dummy Discourse environment when running specs, so there are a few testing quirks.
|
44
|
+
|
45
|
+
Discourse migrations go in `db/migrate` as normal. They are including in the rails migrations_paths in `lib/discourse_subscription_client/engine.rb`.
|
46
|
+
|
47
|
+
If you add new migrations, run test migrations as normal (from the root of the gem)
|
48
|
+
|
49
|
+
```
|
50
|
+
RAILS_ENV=test rake db:drop db:create db:migrate
|
22
51
|
```
|
23
52
|
|
24
|
-
|
25
|
-
|
53
|
+
If you're not adding new migrations you only need to load the schema. If you are running migrations you need to also load the schema (in addition to running the migrations)
|
54
|
+
|
55
|
+
```
|
56
|
+
RAILS_ENV=test rake db:schema:load
|
57
|
+
```
|
26
58
|
|
27
59
|
## License
|
28
|
-
The gem is available as open source under the terms of the [
|
60
|
+
The gem is available as open source under the terms of the [GNU GPL v2 License](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).
|
@@ -6,7 +6,12 @@ class SubscriptionClientSubscription < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
belongs_to :resource, class_name: "SubscriptionClientResource"
|
8
8
|
|
9
|
-
scope :active,
|
9
|
+
scope :active, lambda {
|
10
|
+
where(
|
11
|
+
"subscription_client_subscriptions.subscribed = true AND
|
12
|
+
subscription_client_subscriptions.updated_at > ?", SubscriptionClientSubscription.update_period
|
13
|
+
)
|
14
|
+
}
|
10
15
|
|
11
16
|
def active
|
12
17
|
subscribed && updated_at.to_datetime > self.class.update_period.to_datetime
|
@@ -23,6 +23,12 @@ class SubscriptionClientSupplier < ActiveRecord::Base
|
|
23
23
|
api_key.present?
|
24
24
|
end
|
25
25
|
|
26
|
+
def product_slugs
|
27
|
+
@product_slugs ||= products.each_with_object({}) do |product, result|
|
28
|
+
result[product["product_id"]] = product["product_slug"]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
26
32
|
def deactivate_all_subscriptions!
|
27
33
|
subscriptions.update_all(subscribed: false)
|
28
34
|
end
|
data/config/routes.rb
CHANGED
data/config/settings.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
plugins:
|
2
2
|
subscription_client_enabled:
|
3
3
|
default: true
|
4
|
-
client: true
|
5
4
|
subscription_client_verbose_logs:
|
6
5
|
default: false
|
7
6
|
subscription_client_warning_notices_on_dashboard:
|
@@ -10,7 +9,6 @@ plugins:
|
|
10
9
|
default: false
|
11
10
|
subscription_client_allow_moderator_supplier_management:
|
12
11
|
default: false
|
13
|
-
client: true
|
14
12
|
subscription_client_request_plugin_statuses:
|
15
13
|
default: false
|
16
14
|
hidden: true
|
data/extensions/discourse_subscription_client/{current_user.rb → current_user_serializer.rb}
RENAMED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
module DiscourseSubscriptionClient
|
4
4
|
module CurrentUserSerializerExtension
|
5
|
+
def attributes
|
6
|
+
super.tap do |attrs|
|
7
|
+
attrs[:subscription_notice_count] = subscription_notice_count if include_subscription_notice_count?
|
8
|
+
attrs[:can_manage_subscriptions] = can_manage_subscriptions
|
9
|
+
attrs[:can_manage_suppliers] = can_manage_suppliers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
def subscription_notice_count
|
6
14
|
SubscriptionClientNotice.list(visible: true).count
|
7
15
|
end
|
@@ -13,5 +21,9 @@ module DiscourseSubscriptionClient
|
|
13
21
|
def can_manage_subscriptions
|
14
22
|
scope.can_manage_subscriptions?
|
15
23
|
end
|
24
|
+
|
25
|
+
def can_manage_suppliers
|
26
|
+
scope.can_manage_suppliers?
|
27
|
+
end
|
16
28
|
end
|
17
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DiscourseSubscriptionClient
|
4
|
+
module SiteSerializerExtension
|
5
|
+
def attributes
|
6
|
+
super.tap do |attrs|
|
7
|
+
attrs[:subscription_client_enabled] = subscription_client_enabled
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def subscription_client_enabled
|
12
|
+
SiteSetting.subscription_client_enabled
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -23,6 +23,7 @@ module DiscourseSubscriptionClient
|
|
23
23
|
./notices
|
24
24
|
./subscriptions
|
25
25
|
./subscriptions/result
|
26
|
+
./subscriptions/update_result
|
26
27
|
../../app/models/subscription_client_notice
|
27
28
|
../../app/models/subscription_client_resource
|
28
29
|
../../app/models/subscription_client_subscription
|
@@ -35,16 +36,17 @@ module DiscourseSubscriptionClient
|
|
35
36
|
../../app/serializers/discourse_subscription_client/resource_serializer
|
36
37
|
../../app/serializers/discourse_subscription_client/notice_serializer
|
37
38
|
../../app/serializers/discourse_subscription_client/subscription_serializer
|
38
|
-
../../app/jobs/
|
39
|
-
../../app/jobs/
|
40
|
-
../../app/jobs/
|
41
|
-
../../extensions/discourse_subscription_client/
|
39
|
+
../../app/jobs/discourse_subscription_client_find_resources
|
40
|
+
../../app/jobs/discourse_subscription_client_update_subscriptions
|
41
|
+
../../app/jobs/discourse_subscription_client_update_notices
|
42
|
+
../../extensions/discourse_subscription_client/current_user_serializer
|
43
|
+
../../extensions/discourse_subscription_client/site_serializer
|
42
44
|
../../extensions/discourse_subscription_client/guardian
|
43
45
|
].each do |path|
|
44
46
|
require_relative path
|
45
47
|
end
|
46
48
|
|
47
|
-
Jobs.enqueue(:discourse_subscription_client_find_resources) if
|
49
|
+
Jobs.enqueue(:discourse_subscription_client_find_resources) if !Rails.env.test? && DiscourseSubscriptionClient.database_exists?
|
48
50
|
|
49
51
|
Rails.application.routes.append do
|
50
52
|
mount DiscourseSubscriptionClient::Engine, at: "/admin/plugins/subscription-client"
|
@@ -54,6 +56,7 @@ module DiscourseSubscriptionClient
|
|
54
56
|
|
55
57
|
Guardian.prepend DiscourseSubscriptionClient::GuardianExtension
|
56
58
|
CurrentUserSerializer.prepend DiscourseSubscriptionClient::CurrentUserSerializerExtension
|
59
|
+
SiteSerializer.prepend DiscourseSubscriptionClient::SiteSerializerExtension
|
57
60
|
|
58
61
|
User.has_many(:subscription_client_suppliers)
|
59
62
|
|
@@ -93,5 +96,23 @@ module DiscourseSubscriptionClient
|
|
93
96
|
else
|
94
97
|
true
|
95
98
|
end
|
99
|
+
|
100
|
+
def find_subscriptions(resource_name = nil)
|
101
|
+
return nil unless resource_name
|
102
|
+
|
103
|
+
subscriptions = SubscriptionClientSubscription.active
|
104
|
+
.includes(resource: [:supplier])
|
105
|
+
.references(resource: [:supplier])
|
106
|
+
.where("subscription_client_resources.name = ? ", resource_name)
|
107
|
+
|
108
|
+
result = DiscourseSubscriptionClient::Subscriptions::Result.new
|
109
|
+
return result unless subscriptions.exists?
|
110
|
+
|
111
|
+
result.resource = subscriptions.first.resource
|
112
|
+
result.supplier = subscriptions.first.resource.supplier
|
113
|
+
result.subscriptions = subscriptions.to_a
|
114
|
+
|
115
|
+
result
|
116
|
+
end
|
96
117
|
end
|
97
118
|
end
|
@@ -51,8 +51,8 @@ module DiscourseSubscriptionClient
|
|
51
51
|
request = DiscourseSubscriptionClient::Request.new(:supplier, supplier.id)
|
52
52
|
data = request.perform("#{url}/subscription-server")
|
53
53
|
|
54
|
-
if data
|
55
|
-
supplier.update(name: data[:supplier])
|
54
|
+
if valid_supplier_data?(data)
|
55
|
+
supplier.update(name: data[:supplier], products: data[:products])
|
56
56
|
@suppliers << supplier
|
57
57
|
else
|
58
58
|
supplier.destroy!
|
@@ -89,9 +89,22 @@ module DiscourseSubscriptionClient
|
|
89
89
|
|
90
90
|
@resources << {
|
91
91
|
name: metadata.name,
|
92
|
-
supplier_url: metadata.subscription_url
|
92
|
+
supplier_url: ENV["TEST_SUBSCRIPTION_URL"] || metadata.subscription_url
|
93
93
|
}
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
def valid_supplier_data?(data)
|
98
|
+
return false unless %i[supplier products].all? { |key| data.key?(key) }
|
99
|
+
return false unless data[:supplier].is_a?(String)
|
100
|
+
return false unless data[:products].is_a?(Array)
|
101
|
+
|
102
|
+
data[:products].all? do |product|
|
103
|
+
product.is_a?(Hash) &&
|
104
|
+
%i[product_id product_slug].all? do |key|
|
105
|
+
product.key?(key) && product[key].is_a?(String)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
96
109
|
end
|
97
110
|
end
|
@@ -1,117 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module DiscourseSubscriptionClient
|
4
4
|
class Subscriptions
|
5
5
|
class Result
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
price_id
|
10
|
-
].freeze
|
11
|
-
OPTIONAL_KEYS ||= %i[
|
12
|
-
product_name
|
13
|
-
price_name
|
14
|
-
].freeze
|
15
|
-
KEYS = REQUIRED_KEYS + OPTIONAL_KEYS
|
6
|
+
attr_accessor :supplier,
|
7
|
+
:resource,
|
8
|
+
:subscriptions
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
:infos
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@errors = []
|
23
|
-
@infos = []
|
24
|
-
end
|
25
|
-
|
26
|
-
def not_authorized(supplier)
|
27
|
-
error("not_authorized", supplier)
|
28
|
-
end
|
29
|
-
|
30
|
-
def retrieve_subscriptions(supplier, raw_data)
|
31
|
-
subscriptions_data = raw_data[:subscriptions].compact
|
32
|
-
|
33
|
-
unless subscriptions_data.present? && subscriptions_data.is_a?(Array)
|
34
|
-
error("invalid_response", supplier)
|
35
|
-
return []
|
36
|
-
end
|
37
|
-
|
38
|
-
# subscriptions must be properly formed
|
39
|
-
|
40
|
-
subscriptions_data =
|
41
|
-
subscriptions_data
|
42
|
-
.map(&:symbolize_keys)
|
43
|
-
.each { |data| data[:resource_id] = data[:resource] }
|
44
|
-
.select { |data| REQUIRED_KEYS.all? { |key| data.key?(key) } }
|
45
|
-
|
46
|
-
# we only care about subscriptions for resources on this instance
|
47
|
-
|
48
|
-
resources = SubscriptionClientResource.where(
|
49
|
-
supplier_id: supplier.id,
|
50
|
-
name: subscriptions_data.map { |data| data[:resource] }
|
51
|
-
)
|
52
|
-
|
53
|
-
subscriptions_data.each_with_object([]) do |data, result|
|
54
|
-
resource = resources.select { |r| r.name === data[:resource] }.first
|
55
|
-
|
56
|
-
if resource.present?
|
57
|
-
data[:resource_id] = resource.id
|
58
|
-
result << OpenStruct.new(
|
59
|
-
required: data.slice(*REQUIRED_KEYS),
|
60
|
-
create: data.slice(*KEYS),
|
61
|
-
subscription: nil
|
62
|
-
)
|
63
|
-
else
|
64
|
-
info("no_resource", supplier, resource: data[:resource])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def connection_error(supplier)
|
70
|
-
error("supplier_connection", supplier)
|
71
|
-
end
|
72
|
-
|
73
|
-
def no_suppliers
|
74
|
-
info("no_suppliers")
|
75
|
-
end
|
76
|
-
|
77
|
-
def no_subscriptions(supplier)
|
78
|
-
info("no_subscriptions", supplier)
|
79
|
-
end
|
80
|
-
|
81
|
-
def updated_subscription(supplier, subscription_ids: nil)
|
82
|
-
info("updated_subscription", supplier, subscription_ids: subscription_ids)
|
83
|
-
end
|
84
|
-
|
85
|
-
def created_subscription(supplier, subscription_ids: nil)
|
86
|
-
info("created_subscription", supplier, subscription_ids: subscription_ids)
|
87
|
-
end
|
88
|
-
|
89
|
-
def failed_to_create_subscription(supplier, subscription_ids: nil)
|
90
|
-
info("failed_to_create_subscription", supplier, subscription_ids: subscription_ids)
|
91
|
-
end
|
92
|
-
|
93
|
-
def info(key, supplier = nil, subscription_ids: nil, resource: nil)
|
94
|
-
attrs = {}
|
95
|
-
|
96
|
-
if supplier
|
97
|
-
attrs = {
|
98
|
-
supplier: supplier.name,
|
99
|
-
supplier_url: supplier.url,
|
100
|
-
deep_interpolation: true,
|
101
|
-
price: "",
|
102
|
-
resource_name: ""
|
103
|
-
}
|
104
|
-
end
|
105
|
-
|
106
|
-
attrs.merge!(subscription_ids) if subscription_ids.present?
|
107
|
-
attrs[:resource] if resource.present?
|
108
|
-
|
109
|
-
@infos << I18n.t("subscription_client.subscriptions.info.#{key}", **attrs)
|
110
|
-
end
|
111
|
-
|
112
|
-
def error(key, supplier)
|
113
|
-
@errors << I18n.t("subscription_client.subscriptions.error.#{key}", supplier: supplier.name,
|
114
|
-
supplier_url: supplier.url)
|
10
|
+
def any?
|
11
|
+
supplier.present? && resource.present? && subscriptions.present?
|
115
12
|
end
|
116
13
|
end
|
117
14
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ::DiscourseSubscriptionClient
|
4
|
+
class Subscriptions
|
5
|
+
class UpdateResult
|
6
|
+
REQUIRED_KEYS ||= %i[
|
7
|
+
resource_id
|
8
|
+
product_id
|
9
|
+
price_id
|
10
|
+
].freeze
|
11
|
+
OPTIONAL_KEYS ||= %i[
|
12
|
+
product_name
|
13
|
+
price_name
|
14
|
+
].freeze
|
15
|
+
KEYS = REQUIRED_KEYS + OPTIONAL_KEYS
|
16
|
+
|
17
|
+
attr_reader :errors,
|
18
|
+
:errored_suppliers,
|
19
|
+
:infos
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@errors = []
|
23
|
+
@infos = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def not_authorized(supplier)
|
27
|
+
error("not_authorized", supplier)
|
28
|
+
end
|
29
|
+
|
30
|
+
def retrieve_subscriptions(supplier, raw_data)
|
31
|
+
subscriptions_data = raw_data[:subscriptions].compact
|
32
|
+
|
33
|
+
unless subscriptions_data.present? && subscriptions_data.is_a?(Array)
|
34
|
+
error("invalid_response", supplier)
|
35
|
+
return []
|
36
|
+
end
|
37
|
+
|
38
|
+
# subscriptions must be properly formed
|
39
|
+
|
40
|
+
subscriptions_data =
|
41
|
+
subscriptions_data
|
42
|
+
.map(&:symbolize_keys)
|
43
|
+
.each { |data| data[:resource_id] = data[:resource] }
|
44
|
+
.select { |data| REQUIRED_KEYS.all? { |key| data.key?(key) } }
|
45
|
+
|
46
|
+
# we only care about subscriptions for resources on this instance
|
47
|
+
|
48
|
+
resources = SubscriptionClientResource.where(
|
49
|
+
supplier_id: supplier.id,
|
50
|
+
name: subscriptions_data.map { |data| data[:resource] }
|
51
|
+
)
|
52
|
+
|
53
|
+
subscriptions_data.each_with_object([]) do |data, result|
|
54
|
+
resource = resources.select { |r| r.name === data[:resource] }.first
|
55
|
+
|
56
|
+
if resource.present?
|
57
|
+
data[:resource_id] = resource.id
|
58
|
+
result << OpenStruct.new(
|
59
|
+
required: data.slice(*REQUIRED_KEYS),
|
60
|
+
create: data.slice(*KEYS),
|
61
|
+
subscription: nil
|
62
|
+
)
|
63
|
+
else
|
64
|
+
info("no_resource", supplier, resource: data[:resource])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def connection_error(supplier)
|
70
|
+
error("supplier_connection", supplier)
|
71
|
+
end
|
72
|
+
|
73
|
+
def no_suppliers
|
74
|
+
info("no_suppliers")
|
75
|
+
end
|
76
|
+
|
77
|
+
def no_subscriptions(supplier)
|
78
|
+
info("no_subscriptions", supplier)
|
79
|
+
end
|
80
|
+
|
81
|
+
def updated_subscription(supplier, subscription_ids: nil)
|
82
|
+
info("updated_subscription", supplier, subscription_ids: subscription_ids)
|
83
|
+
end
|
84
|
+
|
85
|
+
def created_subscription(supplier, subscription_ids: nil)
|
86
|
+
info("created_subscription", supplier, subscription_ids: subscription_ids)
|
87
|
+
end
|
88
|
+
|
89
|
+
def failed_to_create_subscription(supplier, subscription_ids: nil)
|
90
|
+
info("failed_to_create_subscription", supplier, subscription_ids: subscription_ids)
|
91
|
+
end
|
92
|
+
|
93
|
+
def info(key, supplier = nil, subscription_ids: nil, resource: nil)
|
94
|
+
attrs = {}
|
95
|
+
|
96
|
+
if supplier
|
97
|
+
attrs = {
|
98
|
+
supplier: supplier.name,
|
99
|
+
supplier_url: supplier.url,
|
100
|
+
deep_interpolation: true,
|
101
|
+
price: "",
|
102
|
+
resource_name: ""
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
attrs.merge!(subscription_ids) if subscription_ids.present?
|
107
|
+
attrs[:resource] if resource.present?
|
108
|
+
|
109
|
+
@infos << I18n.t("subscription_client.subscriptions.info.#{key}", **attrs)
|
110
|
+
end
|
111
|
+
|
112
|
+
def error(key, supplier)
|
113
|
+
@errors << I18n.t("subscription_client.subscriptions.error.#{key}", supplier: supplier.name,
|
114
|
+
supplier_url: supplier.url)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -13,7 +13,7 @@ module DiscourseSubscriptionClient
|
|
13
13
|
def update
|
14
14
|
return unless SiteSetting.subscription_client_enabled
|
15
15
|
|
16
|
-
@result = DiscourseSubscriptionClient::Subscriptions::
|
16
|
+
@result = DiscourseSubscriptionClient::Subscriptions::UpdateResult.new
|
17
17
|
|
18
18
|
if @suppliers.blank?
|
19
19
|
@result.no_suppliers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_subscription_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angus McLeod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 7.0.4.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rails_multisite
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rspec-activemodel-mocks
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,9 +236,9 @@ files:
|
|
222
236
|
- app/controllers/discourse_subscription_client/notices_controller.rb
|
223
237
|
- app/controllers/discourse_subscription_client/subscriptions_controller.rb
|
224
238
|
- app/controllers/discourse_subscription_client/suppliers_controller.rb
|
225
|
-
- app/jobs/
|
226
|
-
- app/jobs/
|
227
|
-
- app/jobs/
|
239
|
+
- app/jobs/discourse_subscription_client_find_resources.rb
|
240
|
+
- app/jobs/discourse_subscription_client_update_notices.rb
|
241
|
+
- app/jobs/discourse_subscription_client_update_subscriptions.rb
|
228
242
|
- app/models/subscription_client_notice.rb
|
229
243
|
- app/models/subscription_client_request.rb
|
230
244
|
- app/models/subscription_client_resource.rb
|
@@ -242,8 +256,10 @@ files:
|
|
242
256
|
- db/migrate/20230221100529_create_subscription_client_notices.rb
|
243
257
|
- db/migrate/20230221100535_create_subscription_client_subscriptions.rb
|
244
258
|
- db/migrate/20230221100540_create_subscription_client_requests.rb
|
245
|
-
-
|
259
|
+
- db/migrate/20230223135957_add_products_to_subscription_client_suppliers.rb
|
260
|
+
- extensions/discourse_subscription_client/current_user_serializer.rb
|
246
261
|
- extensions/discourse_subscription_client/guardian.rb
|
262
|
+
- extensions/discourse_subscription_client/site_serializer.rb
|
247
263
|
- lib/discourse_subscription_client.rb
|
248
264
|
- lib/discourse_subscription_client/authorization.rb
|
249
265
|
- lib/discourse_subscription_client/engine.rb
|
@@ -252,6 +268,7 @@ files:
|
|
252
268
|
- lib/discourse_subscription_client/resources.rb
|
253
269
|
- lib/discourse_subscription_client/subscriptions.rb
|
254
270
|
- lib/discourse_subscription_client/subscriptions/result.rb
|
271
|
+
- lib/discourse_subscription_client/subscriptions/update_result.rb
|
255
272
|
- lib/discourse_subscription_client/version.rb
|
256
273
|
homepage: https://github.com/paviliondev/discourse_subscription_client
|
257
274
|
licenses:
|
File without changes
|
File without changes
|