ishapi 0.1.8.221 → 0.1.8.222

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: 79a045487ac24d706f7d8f02f10a548153673b0b0b13bb151fb284a3ccb3837e
4
+ data.tar.gz: '08a915a9769757ec0519b5171ac2bbb17d9cc431af3dbea113b9558e1a090403'
5
5
  SHA512:
6
- metadata.gz: ce63ee0d0e56a785e2628815586d4a3a35cb94a802f68b4be9f5a8275456b27ca97e803f9cc04e4deaa01adc6f6236ab9ed130666f64ae64fdfd96de23545cb3
7
- data.tar.gz: 945b43524d99c26498e597690b87a8e05a7e2cab5c4be7d91f6ce1c830df0badf20205bf83ade855f3026b658ff4757b94c2ba86e058d985f8d4da112b41e614
6
+ metadata.gz: 74c144dc50c96c1e6e684e064f1ff1696aba730573eccc9dc4673ab7fe35f3469cc995fdf0d2bcfee4e60b1f0c50aa81fadecac44ae53c354aeb888b69811110
7
+ data.tar.gz: 5338869bbdd4d2762a050b60eccd91b8feaaed1613a9569ba0afb9e62b3419012d2a54f5400ee4dc1400976bbb20dd5fc7f14f738b1de498a056e734d7567b50
@@ -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
@@ -9,7 +9,19 @@ Ishapi::EmailMessageIntakeJob.perform_now( stub.id.to_s )
9
9
 
10
10
  =end
11
11
 
12
-
12
+ ## align companies do leads' domains
13
+ =begin
14
+ outs = Lead.all.map do |lead|
15
+ domain = lead.email.split('@')[1]
16
+ if lead.company.company_url == domain
17
+ ;
18
+ else
19
+ company = Leadset.find_or_create_by( company_url: domain )
20
+ lead.m3_leadset_id = company.id
21
+ lead.save
22
+ end
23
+ end.compact
24
+ =end
13
25
 
14
26
  ##
15
27
  ## 2023-02-26 _vp_ let's go
@@ -98,54 +110,43 @@ class Ishapi::EmailMessageIntakeJob < Ishapi::ApplicationJob
98
110
  if in_reply_to_id
99
111
  in_reply_to_msg = ::Office::EmailMessage.where({ message_id: in_reply_to_id }).first
100
112
  if !in_reply_to_msg
101
- conv = ::Office::EmailConversation.create!({
113
+ conv = ::Office::EmailConversation.find_or_create_by({
102
114
  subject: the_mail.subject,
103
- latest_at: the_mail.date,
104
115
  })
105
- in_reply_to_msg = ::Office::EmailMessage.create!({
116
+ in_reply_to_msg = ::Office::EmailMessage.find_or_create_by({
106
117
  message_id: in_reply_to_id,
107
118
  email_conversation_id: conv.id,
108
119
  })
109
120
  end
110
121
  conv = in_reply_to_msg.email_conversation
111
122
  else
112
- conv = ::Office::EmailConversation.create!({
123
+ conv = ::Office::EmailConversation.find_or_create_by({
113
124
  subject: the_mail.subject,
114
- latest_at: the_mail.date,
115
125
  })
116
126
  end
117
127
  @message.email_conversation_id = conv.id
118
128
  conv.update_attributes({
119
129
  state: Conv::STATE_UNREAD,
120
130
  latest_at: the_mail.date,
121
- term_ids: (conv.term_ids + stub.term_ids).uniq,
131
+ wp_term_ids: ( [ WpTag.email_inbox_tag.id ] + conv.wp_term_ids + stub.wp_term_ids ).uniq,
122
132
  })
123
133
 
124
134
  ## Leadset
125
135
  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
136
+ leadset = Leadset.find_or_create_by( company_url: domain )
130
137
 
131
138
  ## 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
139
+ lead = Lead.find_or_create_by( email: @message.from, m3_leadset_id: leadset.id )
138
140
  conv.lead_ids = conv.lead_ids.push( lead.id ).uniq
139
141
 
140
142
  ## Actions & Filters
141
- inbox_tag = WpTag.email_inbox_tag
142
- @message.add_tag( inbox_tag )
143
- conv.add_tag( inbox_tag )
143
+ # inbox_tag = WpTag.email_inbox_tag
144
+ # @message.add_tag( inbox_tag )
145
+ # conv.add_tag( inbox_tag )
144
146
 
145
147
  email_filters = Office::EmailFilter.active
146
148
  email_filters.each do |filter|
147
149
  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
150
  @message.apply_filter( filter )
150
151
  end
151
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.222
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox