ishapi 0.1.8.221 → 0.1.8.223
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: 4713c8ceb10373af0516bafd1226ca2aab981755fb4792b049b142b58143696d
|
4
|
+
data.tar.gz: 1f2b36b9ab6768e32fe18d18d74cf0713ddffe28b198d0aed5018ba8b2877560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31fca4d7d89ccb14e14c52771352a7183d6104be3b785e9a703a5acb488d0e2910f2fae836791e3e55b80b5f2d86c66bb05887d24307fd41845b2d4b92bfc168
|
7
|
+
data.tar.gz: b9cc541f597e7aa1d13fadf51be0ca282293f7be2c4dfc0b33f212d3c495372a894e771835d876a91f04c8951756efcce00479539b611cc3411a42388203e7e0
|
@@ -10,7 +10,6 @@ Ishapi::EmailMessageIntakeJob.perform_now( stub.id.to_s )
|
|
10
10
|
=end
|
11
11
|
|
12
12
|
|
13
|
-
|
14
13
|
##
|
15
14
|
## 2023-02-26 _vp_ let's go
|
16
15
|
## 2023-03-02 _vp_ Continue
|
@@ -61,10 +60,11 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
61
60
|
access_key_id: ::S3_CREDENTIALS[:access_key_id],
|
62
61
|
secret_access_key: ::S3_CREDENTIALS[:secret_access_key] })
|
63
62
|
|
64
|
-
_mail
|
65
|
-
the_mail
|
66
|
-
message_id
|
67
|
-
in_reply_to_id
|
63
|
+
_mail = client.get_object( bucket: ::S3_CREDENTIALS[:bucket_ses], key: stub.object_key ).body.read
|
64
|
+
the_mail = Mail.new(_mail)
|
65
|
+
message_id = the_mail.header['message-id'].decoded
|
66
|
+
in_reply_to_id = the_mail.header['in-reply-to']&.to_s
|
67
|
+
email_inbox_tag_id = WpTag.email_inbox_tag.id
|
68
68
|
|
69
69
|
@message = ::Office::EmailMessage.where( message_id: message_id ).first
|
70
70
|
@message ||= ::Office::EmailMessage.new
|
@@ -98,54 +98,39 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
98
98
|
if in_reply_to_id
|
99
99
|
in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
|
100
100
|
if !in_reply_to_msg
|
101
|
-
conv = ::Office::EmailConversation.
|
101
|
+
conv = ::Office::EmailConversation.find_or_create_by({
|
102
102
|
subject: the_mail.subject,
|
103
|
-
latest_at: the_mail.date,
|
104
103
|
})
|
105
|
-
in_reply_to_msg = ::Office::EmailMessage.
|
104
|
+
in_reply_to_msg = ::Office::EmailMessage.find_or_create_by({
|
106
105
|
message_id: in_reply_to_id,
|
107
106
|
email_conversation_id: conv.id,
|
108
107
|
})
|
109
108
|
end
|
110
109
|
conv = in_reply_to_msg.email_conversation
|
111
110
|
else
|
112
|
-
conv = ::Office::EmailConversation.
|
111
|
+
conv = ::Office::EmailConversation.find_or_create_by({
|
113
112
|
subject: the_mail.subject,
|
114
|
-
latest_at: the_mail.date,
|
115
113
|
})
|
116
114
|
end
|
117
115
|
@message.email_conversation_id = conv.id
|
118
116
|
conv.update_attributes({
|
119
117
|
state: Conv::STATE_UNREAD,
|
120
118
|
latest_at: the_mail.date,
|
121
|
-
|
119
|
+
wp_term_ids: ( [ email_inbox_tag_id ] + conv.wp_term_ids + stub.wp_term_ids ).uniq,
|
122
120
|
})
|
123
121
|
|
124
122
|
## Leadset
|
125
123
|
domain = @message.from.split('@')[1]
|
126
|
-
leadset = Leadset.
|
127
|
-
if !leadset
|
128
|
-
leadset = Leadset.create!( company_url: domain, name: domain )
|
129
|
-
end
|
124
|
+
leadset = Leadset.find_or_create_by( company_url: domain )
|
130
125
|
|
131
126
|
## Lead
|
132
|
-
lead = Lead.
|
133
|
-
if !lead
|
134
|
-
lead = Lead.new( email: @message.from )
|
135
|
-
lead.leadsets.push( leadset )
|
136
|
-
lead.save!
|
137
|
-
end
|
127
|
+
lead = Lead.find_or_create_by( email: @message.from, m3_leadset_id: leadset.id )
|
138
128
|
conv.lead_ids = conv.lead_ids.push( lead.id ).uniq
|
139
129
|
|
140
130
|
## Actions & Filters
|
141
|
-
inbox_tag = WpTag.email_inbox_tag
|
142
|
-
@message.add_tag( inbox_tag )
|
143
|
-
conv.add_tag( inbox_tag )
|
144
|
-
|
145
131
|
email_filters = Office::EmailFilter.active
|
146
132
|
email_filters.each do |filter|
|
147
133
|
if @message.from.match( filter.from_regex ) # || @message.part_html.match( filter.body_regex ) ) # || MiaTagger.analyze( @message.part_html, :is_spammy_recruite ).score > .5
|
148
|
-
|
149
134
|
@message.apply_filter( filter )
|
150
135
|
end
|
151
136
|
end
|
@@ -161,7 +146,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
|
|
161
146
|
stub.update_attributes({ state: ::Office::EmailMessageStub::STATE_PROCESSED })
|
162
147
|
|
163
148
|
## Notification
|
164
|
-
if @message.wp_term_ids.include?(
|
149
|
+
if @message.wp_term_ids.include?( email_inbox_tag_id )
|
165
150
|
# @TODO: send android notification _vp_ 2023-03-01
|
166
151
|
::Ishapi::ApplicationMailer.forwarder_notify( @message.id.to_s ).deliver_later
|
167
152
|
end
|