ishapi 0.1.8.298 → 0.1.8.301

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: 1c64b331e6a7707a42488a92ee911239c17f4d4d161ef0c416e77d6a2e5ae345
4
- data.tar.gz: 64b8e6bf17bdb026194be3b3018d1eb3d53288b8574da59687db21ca8c0907c2
3
+ metadata.gz: e6229aa67b706172dea159f73ff6f5e45d9281c8cb64b9de70e384995f1a869c
4
+ data.tar.gz: af1216cc0d2d17bcb6a6e6b00e977e7b8ebca3768c6db71c7cd2568a3c21a4cf
5
5
  SHA512:
6
- metadata.gz: 370a87f0676d5ecc97008db8973602faf0f5a20558fe97f51d30c525efea99d859e506ce5d8ebb1c61422c1f2b8b02b45cab0ef95314354485bef95fa1f2b732
7
- data.tar.gz: 3a30529de7eee80030dde9274b7a738c1445b45571e1976dc84502d9d7771b1994bca04356482511d25e16c9148b512b9ed657a287ee72425bac078f288ee3eb
6
+ metadata.gz: d16c460663a76a261be7a0ad5b29483cd71c800632bc990b5590206c8315aafea77abbb9b2ba65b8916ad3483e250cb019eeb6d3e22762a19389f1b4be775237
7
+ data.tar.gz: 9580c4aea9c855f492087492bbc266eb5db78344d6d966fdb929bd45157d5bbfe868d0f473594f579eed7cee33dd47eebd1c04d26a3c025ea75dc6c9ae7f56b2
@@ -14,6 +14,7 @@ module Ishapi
14
14
  convos = Office::EmailConversation.find params[:ids]
15
15
  outs = convos.map do |convo|
16
16
  convo.add_tag( params[:emailtag] )
17
+ convo.remove_tag( WpTag::INBOX ) if params[:is_move]
17
18
  end
18
19
  flash[:notice] = "outcome: #{outs}"
19
20
  render json: { status: :ok }
@@ -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.298
4
+ version: 0.1.8.301
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-03 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