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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d08d69bbceb0955e2194960083a649395ae71dfd50f5868888d404632893d78a
4
- data.tar.gz: 02b01369f8ab5e36b8aa39454d040c240681d87e11839b5ab5095c4072fb5144
3
+ metadata.gz: 4a9b5821802e8c966adddf0709fd2ffc3e3bb45dd1530630498480b3a79fc542
4
+ data.tar.gz: 73c04826bb8d276cd691989bb12c2ff4254b53de47cc05eb08b340517fe75783
5
5
  SHA512:
6
- metadata.gz: 385e57f53836fb43de6f8497ca9c5bd86d2632a58ea33372854f8743143421066b24e8f68d8cd593d7a05780a61d198faaf2f9f0674ac6df2983c30f5913761e
7
- data.tar.gz: 68ac61a6a5fecf04b715c626c7d98c9b0727b8bb1a84996625b75d878474218cd2dbaab5fb157ebde13ff622e5008e6c865b93a8793e6ba668045de62e7a15ac
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 = conv.id
153
+ @message.update_attributes({ email_conversation_id: conv.id })
149
154
  conv.update_attributes({
150
- state: Conv::STATE_UNREAD,
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( filter.from_regex ) ) &&
167
- ( filter.from_exact.blank? || @message.from.include?( filter.from_exact ) ) &&
168
- # ( filter.body_regex.blank? || @message.part_html.match( filter.body_regex ) ) &&
169
- ( filter.body_exact.blank? || @message.part_html.include?( filter.body_exact ) ) &&
170
- ( filter.subject_regex.blank? || @message.subject.match( filter.subject_regex ) ) &&
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.271
4
+ version: 0.1.8.272
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox