ishapi 0.1.8.306 → 0.1.8.308
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 +29 -29
- 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: d2c02f71e6adddb15a1722d560e9a8b9f56a5a10daa82471cb60bc9b9399000f
|
4
|
+
data.tar.gz: a3d36b4b360ddf7285ce4950e9d5adb9a784beff39117c4b37a23914234d490c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24949079b8dae5559f5046e42e693610ae5943f9a81fd4e461ee7fa1310998dff2120d60ceaf26b64356bd2d46a98168c0dc9c03e1958f1d4355f9d5a0fd5898
|
7
|
+
data.tar.gz: fc860e2a11a220c176cd5c67f0d0ce7766f6198dbac1fd50be0cdb4b7fdec44c315587f134e355273413b507c723e70515520772db9101be01233461bfba15bb
|
@@ -11,7 +11,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
11
11
|
|
12
12
|
=begin
|
13
13
|
|
14
|
-
object_key = '
|
14
|
+
object_key = 'fom5a97nif6j9urfp46sbchi33sks90e9kkrn181'
|
15
15
|
MsgStub.where({ object_key: object_key }).delete
|
16
16
|
|
17
17
|
stub = MsgStub.create!({ object_key: object_key })
|
@@ -41,24 +41,40 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
41
41
|
message_id = the_mail.header['message-id'].decoded
|
42
42
|
in_reply_to_id = the_mail.header['in-reply-to']&.to_s
|
43
43
|
email_inbox_tag_id = WpTag.emailtag(WpTag::INBOX).id
|
44
|
+
the_mail.to = [ 'NO-RECIPIENT' ] if !the_mail.to
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
46
|
+
subject = ::Msg.strip_emoji the_mail.subject
|
47
|
+
subject ||= '(wco-no-subject)'
|
48
48
|
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
## Conversation
|
51
|
+
if in_reply_to_id
|
52
|
+
in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
|
53
|
+
if !in_reply_to_msg
|
54
|
+
conv = ::Office::EmailConversation.find_or_create_by({
|
55
|
+
subject: subject,
|
56
|
+
})
|
57
|
+
in_reply_to_msg = ::Office::EmailMessage.find_or_create_by({
|
58
|
+
message_id: in_reply_to_id,
|
59
|
+
email_conversation_id: conv.id,
|
60
|
+
})
|
61
|
+
end
|
62
|
+
conv = in_reply_to_msg.email_conversation
|
63
|
+
else
|
64
|
+
conv = ::Office::EmailConversation.find_or_create_by({
|
65
|
+
subject: subject,
|
66
|
+
})
|
67
|
+
end
|
52
68
|
|
53
69
|
@message = ::Office::EmailMessage.where( message_id: message_id ).first
|
54
70
|
@message ||= ::Office::EmailMessage.create({
|
55
71
|
raw: raw,
|
72
|
+
email_conversation_id: conv.id,
|
56
73
|
|
57
74
|
message_id: message_id,
|
58
75
|
in_reply_to_id: in_reply_to_id,
|
59
76
|
|
60
77
|
object_key: stub.object_key,
|
61
|
-
# object_path: stub.object_path,
|
62
78
|
|
63
79
|
subject: subject,
|
64
80
|
date: the_mail.date,
|
@@ -71,8 +87,6 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
71
87
|
|
72
88
|
cc: the_mail.cc ? the_mail.cc[0] : nil,
|
73
89
|
ccs: the_mail.cc,
|
74
|
-
|
75
|
-
# bccs: the_mail.bcc,
|
76
90
|
})
|
77
91
|
if !@message.persisted?
|
78
92
|
throw "Could not create email_message: #{@message.errors.full_messages.join(', ')} ."
|
@@ -138,6 +152,10 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
138
152
|
end
|
139
153
|
end
|
140
154
|
|
155
|
+
if !@message.save
|
156
|
+
puts! @message.errors.full_messages.join(", "), "Could not save @message"
|
157
|
+
end
|
158
|
+
|
141
159
|
## Leadset, Lead
|
142
160
|
domain = @message.from.split('@')[1] rescue 'unknown.domain'
|
143
161
|
leadset = Leadset.find_or_create_by( company_url: domain )
|
@@ -148,25 +166,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
148
166
|
Lead.find_or_create_by( email: cc, m3_leadset_id: leadset.id )
|
149
167
|
end
|
150
168
|
|
151
|
-
|
152
|
-
if in_reply_to_id
|
153
|
-
in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
|
154
|
-
if !in_reply_to_msg
|
155
|
-
conv = ::Office::EmailConversation.find_or_create_by({
|
156
|
-
subject: @message.subject,
|
157
|
-
})
|
158
|
-
in_reply_to_msg = ::Office::EmailMessage.find_or_create_by({
|
159
|
-
message_id: in_reply_to_id,
|
160
|
-
email_conversation_id: conv.id,
|
161
|
-
})
|
162
|
-
end
|
163
|
-
conv = in_reply_to_msg.email_conversation
|
164
|
-
else
|
165
|
-
conv = ::Office::EmailConversation.find_or_create_by({
|
166
|
-
subject: @message.subject,
|
167
|
-
})
|
168
|
-
end
|
169
|
-
@message.update_attributes({ email_conversation_id: conv.id })
|
169
|
+
# @message.update_attributes({ email_conversation_id: conv.id })
|
170
170
|
conv.update_attributes({
|
171
171
|
state: Conv::STATE_UNREAD,
|
172
172
|
latest_at: the_mail.date || Time.now.to_datetime,
|
@@ -191,7 +191,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
191
191
|
|
192
192
|
# || MiaTagger.analyze( @message.part_html, :is_spammy_recruite ).score > .5
|
193
193
|
|
194
|
-
puts! "applying filter #{filter} to conv #{conv}" if DEBUG
|
194
|
+
# puts! "applying filter #{filter} to conv #{conv}" if DEBUG
|
195
195
|
|
196
196
|
@message.apply_filter( filter )
|
197
197
|
end
|