wco_models 3.1.0.59 → 3.1.0.60

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: 2b11007f01745aba3d77e2ba586b7989ec42ac5554aa9f53684098cd6f0fd4a1
4
- data.tar.gz: 835baafdae5711debc5e503730f4fda22e342ecec976e3543fbd9d4ab0cc8a62
3
+ metadata.gz: cb93491d155b30b81d71bb16ad9929b3fce38bd0bda3a915e1b716feb9ec195d
4
+ data.tar.gz: 859abb66b1c27fba4d80dfc54ecf4ca63efdbe1b310f88a65838372a82b839d1
5
5
  SHA512:
6
- metadata.gz: 1432d0dbfe12b637baee8916c5b1d38f5ebd187678ea3d83ce06527ed304b623051b404602868383feff6897861e15821178199a24f0271d27fbd145075705ed
7
- data.tar.gz: f43b68d4282382af6bacd3ec26ee511e8d29b1c49e02df4648daa65e8ce0d3df02d412ee9e4a9ec461770c5402c69936a8be4961296322a6690bf2534bee1a16
6
+ metadata.gz: f1eab179dda685dd1f22d188c9216c7dab65dfe67d00689e7dadac911d50ebfca8933dd5f93b6145d9a147da168822148ae79345eafa8991e518d04117f16356
7
+ data.tar.gz: 50412046c73aa10b4437fdba003ed0ab467b27c60abdee510d51be3b9a6137173789e3ad27843c64a0146502a3e36d40be792e80f670e5acd0ba5c0df7edb527
@@ -11,6 +11,8 @@ class Wco::Tag
11
11
 
12
12
  # parent-child
13
13
 
14
+ has_many :email_filters, class_name: 'WcoEmail::EmailFilter', inverse_of: :tag
15
+
14
16
  has_and_belongs_to_many :conversations, class_name: 'WcoEmail::Conversation'
15
17
  has_and_belongs_to_many :message_stubs, class_name: 'WcoEmail::MessageStub'
16
18
  has_and_belongs_to_many :headlines # , class_name: 'Headline'
@@ -17,6 +17,7 @@ class WcoEmail::EmailFilter
17
17
  field :body_regex
18
18
  field :body_exact
19
19
 
20
+ belongs_to :tag, class_name: 'Wco::Tag', inverse_of: :email_filters, optional: true
20
21
 
21
22
  KIND_AUTORESPOND_TMPL = 'autorespond-template'
22
23
  KIND_AUTORESPOND_EACT = 'autorespond-email-action'
@@ -24,9 +25,10 @@ class WcoEmail::EmailFilter
24
25
  KIND_ADD_TAG = 'add-tag'
25
26
  KIND_DESTROY_SCHS = 'destroy-schs'
26
27
 
27
- KIND_AUTORESPOND = 'autorespond' # @deprecated, DO NOT USE!
28
- KIND_DELETE = 'delete' # @deprecated, use add-tag
29
- KIND_SKIP_INBOX = 'skip-inbox' # @deprecated, use remove-tag
28
+ ## @deprecated
29
+ KIND_AUTORESPOND = 'autorespond' ## @deprecated, DO NOT USE!
30
+ KIND_DELETE = 'delete' ## @deprecated, use add-tag
31
+ KIND_SKIP_INBOX = 'skip-inbox' ## @deprecated, use remove-tag
30
32
 
31
33
  KINDS = [ nil, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_ADD_TAG, KIND_REMOVE_TAG, KIND_DESTROY_SCHS]
32
34
  field :kind
@@ -131,7 +131,7 @@ class WcoEmail::EmailTemplate
131
131
  def self.blank; self.blank_template; end
132
132
 
133
133
  def self.list
134
- all.map { |p| [ p.slug, p.id ] }
134
+ [[nil,nil]] + all.map { |p| [ p.slug, p.id ] }
135
135
  end
136
136
 
137
137
  end
@@ -71,8 +71,8 @@ class WcoEmail::Message
71
71
 
72
72
  belongs_to :stub, class_name: 'WcoEmail::MessageStub'
73
73
 
74
- has_many :assets, class_name: '::Wco::Asset'
75
- has_many :photos, class_name: '::Wco::Photo'
74
+ has_many :assets, class_name: '::Wco::Asset'
75
+ has_many :photos, class_name: '::Wco::Photo'
76
76
  has_many :replies, class_name: '::WcoEmail::Context', inverse_of: :reply_to_message
77
77
 
78
78
  def apply_filter filter
@@ -81,23 +81,23 @@ class WcoEmail::Message
81
81
  case filter.kind
82
82
 
83
83
  when WcoEmail::EmailFilter::KIND_DESTROY_SCHS
84
- conv.add_tag ::WpTag::TRASH
85
- conv.remove_tag ::WpTag::INBOX
84
+ conv.tags.push Wco::Tag.trash
85
+ conv.tags -= [ Wco::Tag.inbox ]
86
86
  lead.schs.each do |sch|
87
87
  sch.update_attributes({ state: ::Sch::STATE_TRASH })
88
88
  end
89
89
 
90
90
  when WcoEmail::EmailFilter::KIND_ADD_TAG
91
- conv.add_tag filter.wp_term_id
92
- if ::WpTag::TRASH == ::WpTag.find( filter.wp_term_id ).slug
93
- conv.remove_tag ::WpTag::INBOX
91
+ conv.tags.push filter.tag
92
+ if filter.tag == Wco::Tag.trash
93
+ conv.tags.remove Wco::Tag.inbox
94
94
  end
95
95
 
96
96
  when WcoEmail::EmailFilter::KIND_REMOVE_TAG
97
- conv.remove_tag filter.wp_term_id
97
+ conv.tags -= [ filter.tag ]
98
98
 
99
99
  when WcoEmail::EmailFilter::KIND_AUTORESPOND_TMPL
100
- Ish::EmailContext.create({
100
+ WcoEmail::Context.create({
101
101
  email_template: filter.email_template,
102
102
  lead_id: lead.id,
103
103
  send_at: Time.now + 22.minutes,
@@ -114,6 +114,8 @@ class WcoEmail::Message
114
114
  else
115
115
  raise "unknown filter kind: #{filter.kind}"
116
116
  end
117
+
118
+ conv.save
117
119
  end
118
120
 
119
121
  ## From: https://stackoverflow.com/questions/24672834/how-do-i-remove-emoji-from-string/24673322
@@ -171,8 +171,7 @@ class WcoEmail::MessageStub
171
171
  ##
172
172
  ## Tags
173
173
  ##
174
- inbox_tag = Wco::Tag.inbox
175
- conv.tags.push inbox_tag
174
+ conv.tags.push Wco::Tag.inbox
176
175
  conv.tags.push stub.tags
177
176
  conv.save
178
177
 
@@ -211,7 +210,7 @@ class WcoEmail::MessageStub
211
210
  ;
212
211
  else
213
212
  conv = WcoEmail::Conversation.find( conv.id )
214
- if conv.tags.include? inbox_tag
213
+ if conv.tags.include? Wco::Tag.inbox
215
214
  out = WcoEmail::ApplicationMailer.forwarder_notify( @message.id.to_s )
216
215
  Rails.env.production? ? out.deliver_later : out.deliver_now
217
216
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.59
4
+ version: 3.1.0.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev