effective_mailchimp 0.10.0 → 0.11.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed0d9672a777f604ae9fabd3de41d47c623a8285bc20f406cd24cb03f363ecd0
|
4
|
+
data.tar.gz: 3f82c087cd92d5522dac3a3f10368199add11f848cf51ff4e9a83f1ec6b0ea2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a9f05f7d1d363360809299def2d0c57bf9c220bc0000d2a2ed2ae9c7cd864a10560b9ab48cbe56b7f6c8f2bb6726cc11648d297abac45633513afe84882eea4
|
7
|
+
data.tar.gz: cc246424d5db654a52aa8831a78b916e16096ab2dd780117d33817a60cbf032f6436a09074ffb29053892113d3e1c89261d86387964271ed4c8d1412515c5c5a
|
@@ -16,7 +16,7 @@ module EffectiveMailchimpUser
|
|
16
16
|
def effective_mailchimp_user?; true; end
|
17
17
|
|
18
18
|
def require_mailchimp_update_fields
|
19
|
-
['email', 'last_name', 'first_name']
|
19
|
+
['id', 'email', 'last_name', 'first_name']
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -33,10 +33,14 @@ module EffectiveMailchimpUser
|
|
33
33
|
includes(mailchimp_list_members: [:mailchimp_list])
|
34
34
|
}
|
35
35
|
|
36
|
+
# A new user is created
|
37
|
+
after_commit(on: [:create], if: -> { EffectiveMailchimp.api_present? }, unless: -> { EffectiveMailchimp.supressed? || @mailchimp_member_update_enqueued }) do
|
38
|
+
mailchimp_subscribe_to_force_subscribe!
|
39
|
+
end
|
40
|
+
|
36
41
|
# The user updated the form
|
37
|
-
after_commit(if: -> { mailchimp_member_update_required? }, unless: -> { EffectiveMailchimp.supressed? || @mailchimp_member_update_enqueued }) do
|
38
|
-
|
39
|
-
EffectiveMailchimpUpdateJob.perform_later(self) # This calls user.mailchimp_update! on the background
|
42
|
+
after_commit(on: [:update], if: -> { mailchimp_member_update_required? }, unless: -> { EffectiveMailchimp.supressed? || @mailchimp_member_update_enqueued }) do
|
43
|
+
mailchimp_update_async!
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -233,6 +237,8 @@ module EffectiveMailchimpUser
|
|
233
237
|
def mailchimp_update!(api: EffectiveMailchimp.api, only: [], except: [])
|
234
238
|
assign_attributes(mailchimp_user_form_action: nil)
|
235
239
|
|
240
|
+
return if mailchimp_member_update_blocked?
|
241
|
+
|
236
242
|
mailchimp_list_members.each do |member|
|
237
243
|
next if only.present? && Array(only).exclude?(member.mailchimp_list)
|
238
244
|
next if except.present? && Array(except).include?(member.mailchimp_list)
|
@@ -257,6 +263,14 @@ module EffectiveMailchimpUser
|
|
257
263
|
save!
|
258
264
|
end
|
259
265
|
|
266
|
+
# Subscribe to force_subscribe lists
|
267
|
+
def mailchimp_subscribe_to_force_subscribe!
|
268
|
+
mailchimp_lists = Effective::MailchimpList.where(force_subscribe: true).to_a
|
269
|
+
return unless mailchimp_lists.present?
|
270
|
+
|
271
|
+
mailchimp_subscribe!(mailchimp_lists)
|
272
|
+
end
|
273
|
+
|
260
274
|
private
|
261
275
|
|
262
276
|
def mailchimp_with_retries(retries: 3, wait: 2, &block)
|
@@ -273,7 +287,14 @@ module EffectiveMailchimpUser
|
|
273
287
|
end
|
274
288
|
end
|
275
289
|
|
290
|
+
def mailchimp_member_update_blocked?
|
291
|
+
return false if try(:email).to_s.start_with?('user') && try(:email).to_s.end_with?('.site')
|
292
|
+
true
|
293
|
+
end
|
294
|
+
|
276
295
|
def mailchimp_member_update_required?
|
296
|
+
return false unless EffectiveMailchimp.api_present?
|
297
|
+
|
277
298
|
return false unless mailchimp_user_form_action
|
278
299
|
return false if self.class.respond_to?(:effective_memberships_user) && membership&.mailchimp_membership_update_required?
|
279
300
|
|
@@ -159,7 +159,7 @@ module Effective
|
|
159
159
|
payload = {
|
160
160
|
email_address: member.user.email,
|
161
161
|
status: (member.subscribed ? 'subscribed' : 'unsubscribed'),
|
162
|
-
merge_fields: merge_fields.
|
162
|
+
merge_fields: merge_fields.transform_values { |value| value || '' },
|
163
163
|
interests: member.interests_hash.presence
|
164
164
|
}.compact
|
165
165
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|