activity_notification 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/activity_notification/notifications_api_controller.rb +1 -1
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +2 -2
- data/lib/activity_notification/controllers/common_api_controller.rb +11 -0
- data/lib/activity_notification/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47f4dd8ad07b61e91c1d44516461cf8bd348807ea1eeab0dd8ffdd76e549606e
|
|
4
|
+
data.tar.gz: 52249dfbf866444bdc81aacb4d2094e1e0eb30a6a28f387aa85d33f1ed533e3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9663a31226c9b1fb504122b4ee06da5e953bd48b80c5a9de4903c658e03279ecc1d49151a2fbffee1dc9ab4ff19f028bd0e78b103b34bf9d70a181453cbe94a9
|
|
7
|
+
data.tar.gz: ed5cc0ebfa1828953db40e8ba37f339999204035bd889a647d1afe5c2873cce5884ac024d5585ede035760145910ecd329d963656184db8122cc4e827db9f4d4
|
|
@@ -154,7 +154,7 @@ module ActivityNotification
|
|
|
154
154
|
end
|
|
155
155
|
{
|
|
156
156
|
include: include_options,
|
|
157
|
-
methods: [:notifiable_path, :printable_notifiable_name, :group_member_notifier_count, :group_notification_count]
|
|
157
|
+
methods: [:notifiable_path, :printable_notifiable_name, :group_member_notifier_count, :group_notification_count] + polymorphic_association_json_methods(ActivityNotification::Notification)
|
|
158
158
|
}
|
|
159
159
|
end
|
|
160
160
|
|
|
@@ -20,7 +20,7 @@ module ActivityNotification
|
|
|
20
20
|
# @return [JSON] configured_count: count of subscription index, subscriptions: subscription index, unconfigured_count: count of unconfigured notification keys, unconfigured_notification_keys: unconfigured notification keys
|
|
21
21
|
def index
|
|
22
22
|
super
|
|
23
|
-
json_response = { configured_count: @subscriptions.size, subscriptions: @subscriptions } if @subscriptions
|
|
23
|
+
json_response = { configured_count: @subscriptions.size, subscriptions: @subscriptions.as_json(include: subscription_json_include_option, methods: subscription_json_methods_option) } if @subscriptions
|
|
24
24
|
json_response = (json_response || {}).merge(unconfigured_count: @notification_keys.size, unconfigured_notification_keys: @notification_keys) if @notification_keys
|
|
25
25
|
render json: json_response
|
|
26
26
|
end
|
|
@@ -180,7 +180,7 @@ module ActivityNotification
|
|
|
180
180
|
# Returns methods option for subscription JSON
|
|
181
181
|
# @api protected
|
|
182
182
|
def subscription_json_methods_option
|
|
183
|
-
|
|
183
|
+
polymorphic_association_json_methods(ActivityNotification::Subscription).freeze
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
# Returns JSON of @subscription
|
|
@@ -26,5 +26,16 @@ module ActivityNotification
|
|
|
26
26
|
def redirect_to_subscription_path
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# Returns methods to add polymorphic association type and id to JSON of the model.
|
|
30
|
+
# Dynamoid models store polymorphic associations as composite keys (e.g. target_key),
|
|
31
|
+
# so their type and id are added to JSON responses as with other ORMs.
|
|
32
|
+
# @api protected
|
|
33
|
+
# @param [Class] model_class Model class of the JSON (e.g. ActivityNotification::Notification)
|
|
34
|
+
# @return [Array<Symbol>] Methods to add to JSON
|
|
35
|
+
def polymorphic_association_json_methods(model_class)
|
|
36
|
+
associations = ActivityNotification.config.orm == :dynamoid ? model_class._associated_composite_records : []
|
|
37
|
+
associations.flat_map { |association| [:"#{association}_type", :"#{association}_id"] }
|
|
38
|
+
end
|
|
39
|
+
|
|
29
40
|
end
|
|
30
41
|
end
|