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: 5535374df402db303704a28ec72c3ffc00aa1d7adb39868828a63c2c7a6724fb
4
- data.tar.gz: 6eaceebe59b11aa0c9e15434a662a3322a928c9007e02d37e0d9d0d9ea453221
3
+ metadata.gz: 4713c8ceb10373af0516bafd1226ca2aab981755fb4792b049b142b58143696d
4
+ data.tar.gz: 1f2b36b9ab6768e32fe18d18d74cf0713ddffe28b198d0aed5018ba8b2877560
5
5
  SHA512:
6
- metadata.gz: ce63ee0d0e56a785e2628815586d4a3a35cb94a802f68b4be9f5a8275456b27ca97e803f9cc04e4deaa01adc6f6236ab9ed130666f64ae64fdfd96de23545cb3
7
- data.tar.gz: 945b43524d99c26498e597690b87a8e05a7e2cab5c4be7d91f6ce1c830df0badf20205bf83ade855f3026b658ff4757b94c2ba86e058d985f8d4da112b41e614
6
+ metadata.gz: 31fca4d7d89ccb14e14c52771352a7183d6104be3b785e9a703a5acb488d0e2910f2fae836791e3e55b80b5f2d86c66bb05887d24307fd41845b2d4b92bfc168
7
+ data.tar.gz: b9cc541f597e7aa1d13fadf51be0ca282293f7be2c4dfc0b33f212d3c495372a894e771835d876a91f04c8951756efcce00479539b611cc3411a42388203e7e0
@@ -10,7 +10,6 @@ module Ishapi
10
10
  before_action :check_jwt
11
11
 
12
12
  def delete
13
- puts! params, 'deleting email conversations'
14
13
  authorize! :email_conversations_delete, ::Ishapi
15
14
  convos = Office::EmailConversation.find params[:ids]
16
15
  convos.map &:destroy
@@ -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 = client.get_object( bucket: ::S3_CREDENTIALS[:bucket_ses], key: stub.object_key ).body.read
65
- the_mail = Mail.new(_mail)
66
- message_id = the_mail.header['message-id'].decoded
67
- in_reply_to_id = the_mail.header['in-reply-to']&.to_s
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.create!({
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.create!({
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.create!({
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
- term_ids: (conv.term_ids + stub.term_ids).uniq,
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.where( company_url: domain ).first
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.where( email: @message.from ).first
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?( inbox_tag.id )
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
@@ -33,7 +33,6 @@ class Ishapi::Ability
33
33
  ## superuser
34
34
  ##
35
35
  if %w| victor@wasya.co victor@piousbox.com piousbox@gmail.com |.include?( user_profile.email )
36
- puts! user_profile, 'ze profile'
37
36
 
38
37
  can [ :email_conversations_delete ], ::Ishapi
39
38
 
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.221
4
+ version: 0.1.8.223
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox