wco_models 3.1.0.304 → 3.1.0.305
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: 9ab5f3e9735c73de3708a8b0cedec3bba5b93a1f6c693396d6f6b492c5639702
|
|
4
|
+
data.tar.gz: 94708879c3fc160e214afe8522e9bc792fdf046fa903f9c27151e237419189d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d9e765a2b3b61a7641704fe779b297191fa7a8d2c167f5e7163f51d2a8fd0696839620e2864ad557bbbc0fa7b8b26366023f85c797ff0bb52c36b3bd59ec27f
|
|
7
|
+
data.tar.gz: 453ab1dd3bd2f1acc9239445522836ce18064a6fbb16b54499db401044e86545702f344d0c1fb1e2099b911e19dbe4386d2b2828ccc237d2a0e3a982476ae5ec
|
data/app/models/wco/photo.rb
CHANGED
|
@@ -11,17 +11,17 @@ class WcoEmail::EmailFilterCondition
|
|
|
11
11
|
FIELD_BODY_PLAIN = 'body-plain'
|
|
12
12
|
FIELD_FROM = 'from'
|
|
13
13
|
FIELD_LEADSET = 'from-leadset'
|
|
14
|
-
FIELD_NOT_TAGGED = 'leadset-not-tagged'
|
|
15
14
|
FIELD_SUBJECT = 'subject'
|
|
16
|
-
FIELD_TAGGED = 'leadset-tagged'
|
|
15
|
+
FIELD_TAGGED = 'leadset-tagged' ## either lead or leadset, actually
|
|
16
|
+
FIELD_NOT_TAGGED = 'leadset-not-tagged' ## either lead or leadset, actually
|
|
17
17
|
FIELD_TO_OR_CC = 'to-or-cc'
|
|
18
18
|
FIELD_OPTS = [
|
|
19
19
|
FIELD_BODY, FIELD_BODY_PLAIN,
|
|
20
20
|
FIELD_FROM,
|
|
21
21
|
FIELD_LEADSET,
|
|
22
|
-
FIELD_NOT_TAGGED,
|
|
23
22
|
FIELD_SUBJECT,
|
|
24
23
|
FIELD_TAGGED,
|
|
24
|
+
FIELD_NOT_TAGGED,
|
|
25
25
|
FIELD_TO_OR_CC,
|
|
26
26
|
];
|
|
27
27
|
field :field
|
|
@@ -49,10 +49,11 @@ class WcoEmail::EmailFilterCondition
|
|
|
49
49
|
|
|
50
50
|
index({ email_filter_id: 1, field: 1, operator: 1, value: 1 }, unique: true )
|
|
51
51
|
|
|
52
|
-
def apply leadset:, message:
|
|
52
|
+
def apply lead:, leadset:, message:
|
|
53
53
|
cond = self
|
|
54
54
|
reason = nil
|
|
55
55
|
case cond.field
|
|
56
|
+
|
|
56
57
|
## from match-i <value>
|
|
57
58
|
when WcoEmail::EmailFilterCondition::FIELD_FROM
|
|
58
59
|
if cond.operator == WcoEmail::EmailFilterCondition::OPERATOR_MATCH
|
|
@@ -60,7 +61,35 @@ class WcoEmail::EmailFilterCondition
|
|
|
60
61
|
reason = "#{email_skip_filter ? 'skip_' : ''}condition from match-i `#{value}`"
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
|
-
|
|
64
|
+
|
|
65
|
+
when WcoEmail::EmailFilterCondition::FIELD_TAGGED
|
|
66
|
+
## cond.operator should eql OPERATOR__ID but I don't check b/c if its slug, it should work also.
|
|
67
|
+
tag = Wco::Tag.find( cond.value ) rescue nil
|
|
68
|
+
tag ||= Wco::Tag.where( slug: cond.value ).first
|
|
69
|
+
if tag
|
|
70
|
+
if leadset.tags.include?( tag ) ||
|
|
71
|
+
lead.tags.include?( tag )
|
|
72
|
+
|
|
73
|
+
reason = "#{email_skip_filter ? 'skip_' : ''}condition TAGGED `#{tag.slug}`"
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
when WcoEmail::EmailFilterCondition::FIELD_NOT_TAGGED
|
|
79
|
+
## cond.operator should eql OPERATOR__ID but I don't check b/c if its slug, it should work also.
|
|
80
|
+
tag = Wco::Tag.find( cond.value ) rescue nil
|
|
81
|
+
tag ||= Wco::Tag.where( slug: cond.value ).first
|
|
82
|
+
if tag
|
|
83
|
+
if !leadset.tags.include?( tag ) &&
|
|
84
|
+
!lead.tags.include?( tag )
|
|
85
|
+
|
|
86
|
+
reason = "#{email_skip_filter ? 'skip_' : ''}condition NOT_TAGGED `#{tag.slug}`"
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end ## end case
|
|
92
|
+
|
|
64
93
|
# when WcoEmail::FIELD_LEADSET
|
|
65
94
|
# if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG
|
|
66
95
|
# this_tag = Wco::Tag.find cond.value
|
|
@@ -111,11 +111,6 @@ class WcoEmail::MessageStub
|
|
|
111
111
|
@message.save_attachment_postal( att )
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
## _TODO
|
|
115
|
-
# the_mail.cc&.each do |cc|
|
|
116
|
-
# Wco::Lead.find_or_create_by_email( cc )
|
|
117
|
-
# end
|
|
118
|
-
|
|
119
114
|
@conv.update_attributes({
|
|
120
115
|
status: WcoEmail::Conversation::STATUS_UNREAD,
|
|
121
116
|
latest_at: json['date'].to_time.to_s || Time.now.to_datetime,
|
|
@@ -135,7 +130,7 @@ class WcoEmail::MessageStub
|
|
|
135
130
|
reason = nil
|
|
136
131
|
|
|
137
132
|
filter.conditions.each do |cond|
|
|
138
|
-
reason ||= cond.apply(leadset: @leadset, message: @message )
|
|
133
|
+
reason ||= cond.apply(lead: @lead, leadset: @leadset, message: @message )
|
|
139
134
|
end
|
|
140
135
|
|
|
141
136
|
if reason
|
|
@@ -145,13 +140,14 @@ class WcoEmail::MessageStub
|
|
|
145
140
|
skip_reason = nil
|
|
146
141
|
|
|
147
142
|
filter.skip_conditions.each do |scond|
|
|
148
|
-
skip_reason ||= scond.apply(leadset: @leadset, message: @message )
|
|
143
|
+
skip_reason ||= scond.apply(lead: @lead, leadset: @leadset, message: @message )
|
|
149
144
|
end
|
|
150
145
|
|
|
151
146
|
if skip_reason
|
|
152
147
|
puts! "NOT Applying2 filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
|
|
153
148
|
else
|
|
154
|
-
@conv.filters << filter
|
|
149
|
+
@conv.filters << filter
|
|
150
|
+
@conv.save
|
|
155
151
|
filter.actions.each do |action|
|
|
156
152
|
@message.apply_filter_action( action )
|
|
157
153
|
end
|