ishapi 0.1.8.300 → 0.1.8.302

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: 6945769627542236522acc5aad7485a850ddc244adebe6d4cba7f096c513c01e
4
- data.tar.gz: 19bc757ce91580e831030e57f05175477e2477779424913d74d70223f7d811ea
3
+ metadata.gz: 57efdeeb134f2713ceff675afdcd38227765df6cd5769ef9f85423c79d46999e
4
+ data.tar.gz: a7ad58a601430d8172229fd66dc9b612a8ca432b7ea1602741c8fd6a54f3f561
5
5
  SHA512:
6
- metadata.gz: 5d0aca1a1045b2d8f45547cccb4dcb781ef883af365d4edcd71f27ef56292d3ba723bf2b377f6fa05afe120b7c7556cd08ef8bade4a5ce7dfcb644f117930c55
7
- data.tar.gz: 2e92c83c7513acad4656780328e5b106fa13d381c43a1caea245e744870dc92bcc99a4cb3ddb0d53edca70236f0ecb278db94039484929c23d5c09977e6c254f
6
+ metadata.gz: 16c58f71d63bf5b156fe7800f66505b0ec3c7b607d4900b89dcebbd99a7e4b98218c12af11c63b5df9320d546ad212efe1d7a302446a7bbb3763a76a42e7e0f7
7
+ data.tar.gz: c68af62bda4af804a79bd8e2a74349507a40579a2c26784496f6c65ffd24c0b869dc27c2b46bb7c79285c17c666a03cb0f3cc011fde56cb970544b99b7f2e95b
@@ -20,6 +20,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
20
20
  # "multipart/alternative; boundary=_000_BL0PR10MB2913C560ADE059F0AB3A6D11829A9BL0PR10MB2913namp_",
21
21
  # "text/html; charset=utf-8"
22
22
  # "text/plain; charset=UTF-8"
23
+ # "text/calendar; charset=utf-8; method=REQUEST"
23
24
  def churn_subpart message, part
24
25
  if part.content_disposition&.include?('attachment')
25
26
  ## @TODO: attachments !
@@ -31,15 +32,33 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
31
32
  part.parts.each do |subpart|
32
33
  churn_subpart( message, subpart )
33
34
  end
35
+ else
36
+ attachment = Office::EmailAttachment.new({
37
+ content: part.decoded,
38
+ content_type: part.content_type,
39
+ email_message: message,
40
+ })
41
+ attachment.save
34
42
 
35
- elsif part.content_type.include?('text/html')
36
- message.part_html = part.decoded
43
+ if part.content_type.include?('text/html')
44
+ message.part_html = part.decoded
37
45
 
38
- elsif part.content_type.include?("text/plain")
39
- message.part_txt = part.decoded
46
+ elsif part.content_type.include?("text/plain")
47
+ message.part_txt = part.decoded
40
48
 
41
- else
42
- puts! part.content_type, '444 No action for a part with this content_type'
49
+ elsif part.content_type.include?("text/calendar")
50
+ ;
51
+ elsif part.content_type.include?("application/pdf")
52
+ ;
53
+ elsif part.content_type.include?("image/jpeg")
54
+ ;
55
+ elsif part.content_type.include?("image/png")
56
+ ;
57
+
58
+ else
59
+ puts! part.content_type, '444 No action for a part with this content_type'
60
+
61
+ end
43
62
  end
44
63
  end
45
64
  end
@@ -96,8 +115,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
96
115
  subject ||= '(wco no subject)'
97
116
 
98
117
  @message = ::Office::EmailMessage.where( message_id: message_id ).first
99
- @message ||= ::Office::EmailMessage.new
100
- @message.assign_attributes({
118
+ @message ||= ::Office::EmailMessage.create({
101
119
  raw: _mail,
102
120
 
103
121
  message_id: message_id,
@@ -109,7 +127,7 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
109
127
  subject: subject,
110
128
  date: the_mail.date,
111
129
 
112
- from: the_mail.from ? the_mail.from[0] : "nobody@unknown.domain",
130
+ from: the_mail.from ? the_mail.from[0] : "nobody@unknown-doma.in",
113
131
  froms: the_mail.from,
114
132
 
115
133
  to: the_mail.to ? the_mail.to[0] : nil,
@@ -120,6 +138,9 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
120
138
 
121
139
  # bccs: the_mail.bcc,
122
140
  })
141
+ if !@message.persisted?
142
+ puts! @message.errors.full_messages, "Could not create email_message"
143
+ end
123
144
  if the_mail.body.preamble.present?
124
145
  @message.preamble = the_mail.body.preamble
125
146
  end
@@ -161,6 +182,11 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
161
182
  domain = @message.from.split('@')[1] rescue 'unknown.domain'
162
183
  leadset = Leadset.find_or_create_by( company_url: domain )
163
184
  lead = Lead.find_or_create_by( email: @message.from, m3_leadset_id: leadset.id )
185
+ the_mail.cc&.each do |cc|
186
+ domain = cc.split('@')[1] rescue 'unknown.domain'
187
+ leadset = Leadset.find_or_create_by( company_url: domain )
188
+ Lead.find_or_create_by( email: cc, m3_leadset_id: leadset.id )
189
+ end
164
190
 
165
191
  ## Conversation
166
192
  if in_reply_to_id
@@ -182,9 +208,9 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
182
208
  end
183
209
  @message.update_attributes({ email_conversation_id: conv.id })
184
210
  conv.update_attributes({
185
- state: Conv::STATE_UNREAD,
186
- latest_at: the_mail.date || Time.now.to_datetime,
187
- from_emails: conv.from_emails + the_mail.from,
211
+ state: Conv::STATE_UNREAD,
212
+ latest_at: the_mail.date || Time.now.to_datetime,
213
+ from_emails: ( conv.from_emails + the_mail.from ).uniq,
188
214
  })
189
215
  conv.add_tag( ::WpTag::INBOX )
190
216
  conv_lead_tie = Office::EmailConversationLead.find_or_create_by({
@@ -0,0 +1,6 @@
1
+
2
+ ## Lead
3
+ lead = Lead.create( email: @message.from )
4
+ the_mail.cc&.each do |cc|
5
+ lead = Lead.create( email: cc )
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.300
4
+ version: 0.1.8.302
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-04 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -241,6 +241,7 @@ files:
241
241
  - app/helpers/ishapi/application_helper.rb
242
242
  - app/jobs/ishapi/application_job.rb
243
243
  - app/jobs/ishapi/email_message_intake_job.rb
244
+ - app/jobs/ishapi/email_message_intake_job.rb-todo
244
245
  - app/mailers/ishapi/application_mailer.rb
245
246
  - app/mailers/ishapi/confirmations_mailer.rb
246
247
  - app/models/ishapi/ability.rb