ish_models 0.0.33.282 → 0.0.33.284

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: e5f09926e50bdfd5eb47e0d54068d1e489da436ac66a04cbcbbdf512c54bd08d
4
- data.tar.gz: '060097f0e62e56a7b6a531d59688818156395c197fddd4e6f99ec9e2a61d2372'
3
+ metadata.gz: 4a4d957982b07fa1d853042019a04a184a7f29b72714c6cdf7a1004f280eb40f
4
+ data.tar.gz: 7e146b62cb7fc0f4a355a411ae4179da424df030c13a3c51c3290f4a7a5b829c
5
5
  SHA512:
6
- metadata.gz: 218fbb19117f7f2fd8cfb16b3bd42a926842c01935d533d38a0032f04161128a670cb618e38b3335e6f0e69b927f6b318923734f9f09195f353b1bfb182269c6
7
- data.tar.gz: 8bbc63978210f3b2e2d33887aa89ae65ad89f70c15be228eafa22604dec316727cda6bbfcc1c0af9f58fb34be468ebbbcd8bab23674476e11f0a95d97c565a91
6
+ metadata.gz: d17aebb57121789518229f7a1c2dbaf5779a7fe0ea9814cceb11f8a6d4434e0ec71564678a3b5f15c6d15870cb77b9301a2b23f6d7743507482da553a79ae96b
7
+ data.tar.gz: 9aeb3776194c1bbac334a18c493a14b85ed3eed5fa46c0456b6f7ecb6db063b7ef98ee3d8fb00bbbef69cd75f2007f804bc80bd5d365f3fc535139e475283f04
@@ -5,7 +5,7 @@ class ::Ish::EmailTemplate
5
5
 
6
6
  field :slug
7
7
  validates_uniqueness_of :slug
8
- validates_presence_of :slug
8
+ validates_presence_of :slug
9
9
 
10
10
  field :preview_str, type: :string
11
11
 
@@ -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 = [
@@ -95,5 +95,9 @@ class ::Ish::EmailTemplate
95
95
  end
96
96
  def self.blank; self.blank_template; end
97
97
 
98
+ def to_s
99
+ "Tmpl:#{slug}"
100
+ end
101
+
98
102
  end
99
103
  ::Tmpl = ::Ish::EmailTemplate
@@ -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
 
@@ -7,6 +7,9 @@ class Office::LeadAction
7
7
  include Mongoid::Timestamps
8
8
 
9
9
  belongs_to :lead_action_template, class_name: '::Office::LeadActionTemplate', inverse_of: :lead_actions, foreign_key: :tmpl_id
10
+ def tmpl
11
+ lead_action_template
12
+ end
10
13
 
11
14
  field :lead_id, type: :integer
12
15
  validates :lead_id, presence: true
@@ -14,7 +17,7 @@ class Office::LeadAction
14
17
  Lead.find( lead_id )
15
18
  end
16
19
 
17
- field :params, type: Object
20
+ field :params, type: Object, default: '{}'
18
21
 
19
22
 
20
23
  end
@@ -20,6 +20,9 @@ class Office::LeadActionTemplate
20
20
  KIND_UNSUBSCRIBE_CAMPAIGN = 'kind-unsubscribe-campaign'
21
21
  KINDS = [ KIND_UNSUBSCRIBE_TEMPLATE, KIND_UNSUBSCRIBE_CAMPAIGN ]
22
22
 
23
+ def to_s
24
+ "OLAT:#{slug}"
25
+ end
23
26
 
24
27
  def unsubscribe_from_campaign
25
28
  end
@@ -35,6 +38,10 @@ class Office::LeadActionTemplate
35
38
  })
36
39
  end
37
40
 
41
+ def self.list
42
+ [ [nil,nil] ] + all.map { |i| [ i.slug, i.id.to_s ] }
43
+ end
44
+
38
45
 
39
46
  end
40
-
47
+ OLAT = Office::LeadActionTemplate
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.282
4
+ version: 0.0.33.284
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox