ishapi 0.1.8.271 → 0.1.8.272
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/ishapi/email_message_intake_job.rb +14 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a9b5821802e8c966adddf0709fd2ffc3e3bb45dd1530630498480b3a79fc542
|
4
|
+
data.tar.gz: 73c04826bb8d276cd691989bb12c2ff4254b53de47cc05eb08b340517fe75783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f98f56355046723fa4b7eb2d6d7737b9885647ec5f6f29bdf62ed9ff48c14418451c06096243ec57e0f9d8887a713b5276c07a1ba87a5ae1bae2a20042924f
|
7
|
+
data.tar.gz: c1bb78d47ccd0594eb8720fad830ea1f9c29e0d9f298ebc7753d3d47712bb09630832113fd51e76692322ef548bdc5e1a3e4c4da62093a3cdbcc6a490d31c2c9
|
@@ -127,6 +127,11 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
+
## Leadset, Lead
|
131
|
+
domain = @message.from.split('@')[1]
|
132
|
+
leadset = Leadset.find_or_create_by( company_url: domain )
|
133
|
+
lead = Lead.find_or_create_by( email: @message.from, m3_leadset_id: leadset.id )
|
134
|
+
|
130
135
|
## Conversation
|
131
136
|
if in_reply_to_id
|
132
137
|
in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
|
@@ -145,30 +150,22 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
145
150
|
subject: the_mail.subject,
|
146
151
|
})
|
147
152
|
end
|
148
|
-
@message.email_conversation_id
|
153
|
+
@message.update_attributes({ email_conversation_id: conv.id })
|
149
154
|
conv.update_attributes({
|
150
|
-
state:
|
155
|
+
state: Conv::STATE_UNREAD,
|
151
156
|
latest_at: the_mail.date || Time.now.to_datetime,
|
157
|
+
lead_ids: conv.lead_ids.push( lead.id ).uniq,
|
152
158
|
wp_term_ids: ( [ email_inbox_tag_id ] + conv.wp_term_ids + stub.wp_term_ids ).uniq,
|
153
159
|
})
|
154
160
|
|
155
|
-
## Leadset
|
156
|
-
domain = @message.from.split('@')[1]
|
157
|
-
leadset = Leadset.find_or_create_by( company_url: domain )
|
158
|
-
|
159
|
-
## Lead
|
160
|
-
lead = Lead.find_or_create_by( email: @message.from, m3_leadset_id: leadset.id )
|
161
|
-
conv.lead_ids = conv.lead_ids.push( lead.id ).uniq
|
162
|
-
|
163
161
|
## Actions & Filters
|
164
162
|
email_filters = Office::EmailFilter.active
|
165
163
|
email_filters.each do |filter|
|
166
|
-
if ( filter.from_regex.blank? || @message.from.match(
|
167
|
-
( filter.from_exact.blank? || @message.from.include?(
|
168
|
-
|
169
|
-
( filter.
|
170
|
-
( filter.
|
171
|
-
( filter.subject_exact.blank? || @message.subject.include?( filter.subject_exact ) )
|
164
|
+
if ( filter.from_regex.blank? || @message.from.match( filter.from_regex ) ) &&
|
165
|
+
( filter.from_exact.blank? || @message.from.downcase.include?( filter.from_exact ) ) &&
|
166
|
+
( filter.body_exact.blank? || @message.part_html.include?( filter.body_exact ) ) &&
|
167
|
+
( filter.subject_regex.blank? || @message.subject.match( filter.subject_regex ) ) &&
|
168
|
+
( filter.subject_exact.blank? || @message.subject.include?( filter.subject_exact ) )
|
172
169
|
|
173
170
|
# || MiaTagger.analyze( @message.part_html, :is_spammy_recruite ).score > .5
|
174
171
|
|
@@ -176,17 +173,10 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
176
173
|
end
|
177
174
|
end
|
178
175
|
|
179
|
-
## Save to exit
|
180
|
-
flag = @message.save
|
181
|
-
# if flag
|
182
|
-
# puts! @message.message_id, 'Saved this message'
|
183
|
-
# else
|
184
|
-
# puts! @message.errors.full_messages.join(', '), 'Cannot save email_message'
|
185
|
-
# end
|
186
|
-
conv.save
|
187
176
|
stub.update_attributes({ state: ::Office::EmailMessageStub::STATE_PROCESSED })
|
188
177
|
|
189
178
|
## Notification
|
179
|
+
conv.reload
|
190
180
|
if conv.wp_term_ids.include?( email_inbox_tag_id )
|
191
181
|
out = ::Ishapi::ApplicationMailer.forwarder_notify( @message.id.to_s )
|
192
182
|
Rails.env.production? ? out.deliver_later : out.deliver_now
|