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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb93491d155b30b81d71bb16ad9929b3fce38bd0bda3a915e1b716feb9ec195d
|
4
|
+
data.tar.gz: 859abb66b1c27fba4d80dfc54ecf4ca63efdbe1b310f88a65838372a82b839d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1eab179dda685dd1f22d188c9216c7dab65dfe67d00689e7dadac911d50ebfca8933dd5f93b6145d9a147da168822148ae79345eafa8991e518d04117f16356
|
7
|
+
data.tar.gz: 50412046c73aa10b4437fdba003ed0ab467b27c60abdee510d51be3b9a6137173789e3ad27843c64a0146502a3e36d40be792e80f670e5acd0ba5c0df7edb527
|
data/app/models/wco/tag.rb
CHANGED
@@ -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
|
-
|
28
|
-
|
29
|
-
|
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
|
@@ -71,8 +71,8 @@ class WcoEmail::Message
|
|
71
71
|
|
72
72
|
belongs_to :stub, class_name: 'WcoEmail::MessageStub'
|
73
73
|
|
74
|
-
has_many :assets,
|
75
|
-
has_many :photos,
|
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.
|
85
|
-
conv.
|
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.
|
92
|
-
if
|
93
|
-
conv.
|
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.
|
97
|
+
conv.tags -= [ filter.tag ]
|
98
98
|
|
99
99
|
when WcoEmail::EmailFilter::KIND_AUTORESPOND_TMPL
|
100
|
-
|
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
|
-
|
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?
|
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
|