ish_models 0.0.33.281 → 0.0.33.283

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 309331625ed639a9bd1ddfb2142225aede62f631849763c8b3fabd8ce0d02b17
4
- data.tar.gz: ee3439e19b8c30a296978750e572cbbe187a10f66f02ea35eec7a17526cc1d40
3
+ metadata.gz: f08684b167a8a9dd2f48caf9441d0c328ce9fef962a3964feeb0fb067a74db6c
4
+ data.tar.gz: d006ee0f98934aa7b7146fbd434faa81e696a48e8f391381ed9dd78d4b70be7f
5
5
  SHA512:
6
- metadata.gz: 30e65133826f586e41a9ad12ec57aa48e9bc26c1ba7d214811233e5eb084a73bf8a2e9ca1c866124ca49f8e187035c17ad1960e7154ef15a1db4b7ccc6d9458e
7
- data.tar.gz: 490e745619d555e1c30fc9aab472c75508af4753da93341fe6f869cc5f86d9d2194ab67f93643b76c175d0f02348f8ba2a091a9b7d645bd2b192df32d89036c0
6
+ metadata.gz: 04a4903ee82b65803e0cadd5b2235935ce9041f6c442defd558c3d81e14a522a47d6510aaf69e32b71d0bd5c16a9f8590acd7fa7506417ab17789e34fd59f88a
7
+ data.tar.gz: 5bae3c73bc973fb0b240b9cfba54cc42e2de35c6257226dc386d130bc0f272a3a2bb770e0d42144f127a2bf3b782b0ce3b6cc9aa8032aa181e1438f0bbc5cf95
@@ -53,12 +53,13 @@ class ::Ish::EmailContext
53
53
 
54
54
  field :rendered_str
55
55
 
56
- field :sent_at, type: DateTime
57
- field :send_at, type: DateTime
56
+ field :sent_at, type: DateTime
57
+ field :send_at, type: DateTime
58
+ field :unsubscribed_at, type: DateTime
58
59
 
59
60
 
60
61
  def notsent
61
- Ish::EmailContext.where( sent_at: nil )
62
+ Ish::EmailContext.where( sent_at: nil, unsubscribed_at: nil )
62
63
  end
63
64
  def self.notsent; new.notsent; end
64
65
 
@@ -26,7 +26,7 @@ class ::Ish::EmailTemplate
26
26
  field :subject
27
27
  field :body
28
28
  field :can_unsubscribe, type: :boolean, default: true
29
- field :config_exe, default: "" ## used a lot.
29
+ field :config_exe, default: "" ## unused! _vp_ 2023-09-24
30
30
  field :config_json, type: Object, default: '{}'
31
31
 
32
32
  FROM_EMAILS = [
@@ -7,12 +7,12 @@ class Ish::EmailUnsubscribe
7
7
  # validates_presence_of :email
8
8
  # validates_uniqueness_of :email
9
9
 
10
- field :lead_id
10
+ field :lead_id, type: :integer
11
11
  field :reason
12
12
  field :unsubscribed_at
13
13
 
14
- belongs_to :campaign, class_name: '::Ish::EmailCampaign', inverse_of: :unsubscribes
15
- belongs_to :template, class_name: '::Ish::EmailTemplate', inverse_of: :unsubscribes
14
+ belongs_to :campaign, class_name: '::Ish::EmailCampaign', inverse_of: :unsubscribes, optional: true
15
+ belongs_to :template, class_name: '::Ish::EmailTemplate', inverse_of: :unsubscribes, optional: true
16
16
 
17
17
 
18
18
  end
@@ -73,47 +73,6 @@ class Office::EmailConversation
73
73
  end
74
74
 
75
75
 
76
- def apply_filter filter
77
- case filter.kind
78
-
79
- when ::Office::EmailFilter::KIND_DESTROY_SCHS
80
- add_tag ::WpTag::TRASH
81
- remove_tag ::WpTag::INBOX
82
- tmp_lead = ::Lead.where( email: self.part_txt.split("\n")[1] ).first
83
- if tmp_lead
84
- tmp_lead.schs.each do |sch|
85
- sch.update_attributes({ state: ::Sch::STATE_TRASH })
86
- end
87
- end
88
-
89
- when ::Office::EmailFilter::KIND_ADD_TAG
90
- add_tag filter.wp_term_id
91
- if ::WpTag::TRASH == ::WpTag.find( filter.wp_term_id ).slug
92
- remove_tag ::WpTag::INBOX
93
- end
94
-
95
- when ::Office::EmailFilter::KIND_REMOVE_TAG
96
- remove_tag filter.wp_term_id
97
-
98
- when ::Office::EmailFilter::KIND_AUTORESPOND_TMPL
99
- Ish::EmailContext.create({
100
- email_template: filter.email_template,
101
- lead_id: lead.id,
102
- send_at: Time.now + 22.minutes,
103
- })
104
-
105
- when ::Office::EmailFilter::KIND_AUTORESPOND_EACT
106
- ::Sch.create({
107
- email_action: filter.email_action,
108
- state: ::Sch::STATE_ACTIVE,
109
- lead_id: lead.id,
110
- perform_at: Time.now + 22.minutes,
111
- })
112
-
113
- else
114
- raise "unknown filter kind: #{filter.kind}"
115
- end
116
- end
117
76
 
118
77
 
119
78
 
@@ -58,6 +58,47 @@ class Office::EmailMessage
58
58
  body
59
59
  end
60
60
 
61
+
62
+ def apply_filter filter
63
+ case filter.kind
64
+
65
+ when ::Office::EmailFilter::KIND_DESTROY_SCHS
66
+ conv.add_tag ::WpTag::TRASH
67
+ conv.remove_tag ::WpTag::INBOX
68
+ lead.schs.each do |sch|
69
+ sch.update_attributes({ state: ::Sch::STATE_TRASH })
70
+ end
71
+
72
+ when ::Office::EmailFilter::KIND_ADD_TAG
73
+ conv.add_tag filter.wp_term_id
74
+ if ::WpTag::TRASH == ::WpTag.find( filter.wp_term_id ).slug
75
+ conv.remove_tag ::WpTag::INBOX
76
+ end
77
+
78
+ when ::Office::EmailFilter::KIND_REMOVE_TAG
79
+ conv.remove_tag filter.wp_term_id
80
+
81
+ when ::Office::EmailFilter::KIND_AUTORESPOND_TMPL
82
+ Ish::EmailContext.create({
83
+ email_template: filter.email_template,
84
+ lead_id: lead.id,
85
+ send_at: Time.now + 22.minutes,
86
+ })
87
+
88
+ when ::Office::EmailFilter::KIND_AUTORESPOND_EACT
89
+ ::Sch.create({
90
+ email_action: filter.email_action,
91
+ state: ::Sch::STATE_ACTIVE,
92
+ lead_id: lead.id,
93
+ perform_at: Time.now + 22.minutes,
94
+ })
95
+
96
+ else
97
+ raise "unknown filter kind: #{filter.kind}"
98
+ end
99
+ end
100
+
101
+
61
102
  end
62
103
  ::Msg = Office::EmailMessage
63
104
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.281
4
+ version: 0.0.33.283
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox