wco_models 3.1.0.298 → 3.1.0.300

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: 7f62722438c3c27dc721d00215ab4d75ba6472cab9da0c6eb115c79c581f4414
4
- data.tar.gz: 330e5c51f4223182e51c7119a26df6e040e82de2cca3f6f0b9b36bed09cd8a2b
3
+ metadata.gz: 92cff78067ebf0b1d3864b4d34279bc2ff8301aa8b5644a06928769519a631b1
4
+ data.tar.gz: c8f2866c7c375f56c351275689f17ddbe70fdb9c7efa9e1d714c1579bceea197
5
5
  SHA512:
6
- metadata.gz: b55f74ab8ad041ab43d7b9345ba6263cd37f05d550038a4553c1dbff371226fc7e260131dff46a31963ff19539ba2190572e778986d87440417a13f8ce50180e
7
- data.tar.gz: 61df52c01b5db521d013999f458a4c07ec344a307b8a52da50c32ed4e0ec2748f0c0fcaedf0f175c7d51dfc5d7eed472cd42b60370b0663ff10a50c9106cf038
6
+ metadata.gz: 65fb700ea7bc8e05d0aa59805bd14469a248e0703a129eaaa0dba666c2943be994fbe7f9c207f79463c339e7d24725aaa62060ce1bae606f0a90ba25c8467704
7
+ data.tar.gz: b0fc24ace08414f45df24ad60b58afc91e1a03581231f87020c9d98a00ece1a236a2895d4e1baeda3c9b9f278f1d4b0acc318705a737efe4c32840a9de61c88e
@@ -2,6 +2,11 @@
2
2
  class Wco::Api::LeadsController < Wco::ApiController
3
3
 
4
4
  skip_before_action :decode_jwt
5
+ before_action :check_credentials, only: [ :by_email ]
6
+
7
+ def by_email
8
+ @lead = Wco::Lead.where( email: params[:email] ).first
9
+ end
5
10
 
6
11
  ## select2-leads-ajax
7
12
  def index
@@ -9,6 +9,13 @@ class Wco::ApiController < ActionController::Base
9
9
  ##
10
10
  private
11
11
 
12
+ def check_credentials
13
+ if params[:secret] != AWS_SES_LAMBDA_SECRET
14
+ render status: 400, json: { status: 400, message: "#check_credentials in wco says unauthorized." }
15
+ return
16
+ end
17
+ end
18
+
12
19
  def decode_jwt
13
20
  out = JWT.decode params[:jwt_token], nil, false
14
21
  email = out[0]['email']
@@ -35,6 +35,16 @@ class Wco::Tag
35
35
  find_or_create_by({ slug: BOUNCE })
36
36
  end
37
37
 
38
+ BOUNCED = 'bounced'
39
+ def self.bounced
40
+ find_or_create_by({ slug: BOUNCED })
41
+ end
42
+
43
+ DONOTSEND = 'donotsend'
44
+ def self.donotsend
45
+ find_or_create_by({ slug: DONOTSEND })
46
+ end
47
+
38
48
  INBOX = 'inbox'
39
49
  def self.inbox
40
50
  find_or_create_by({ slug: INBOX })
@@ -55,10 +65,6 @@ class Wco::Tag
55
65
  find_or_create_by({ slug: TRASH })
56
66
  end
57
67
 
58
- DONOTSEND = 'donotsend'
59
- def self.donotsend
60
- find_or_create_by({ slug: DONOTSEND })
61
- end
62
68
 
63
69
  def to_s
64
70
  slug
@@ -59,15 +59,16 @@ class WcoEmail::Message
59
59
 
60
60
  field :part_txt
61
61
 
62
- field :from, type: :string
63
- field :froms, type: Array, default: []
62
+ field :from, type: :string
63
+ field :mail_from, type: :string
64
+ field :spam_status, type: :string
64
65
  belongs_to :lead, class_name: 'Wco::Lead', inverse_of: :email_messages
65
66
 
66
67
  field :to, type: :string
67
68
  field :tos, type: Array, default: []
68
69
  field :cc, type: :string
69
70
  field :ccs, type: Array, default: []
70
- def all_ccs; (tos||[]) + (ccs||[]) + (froms||[]); end
71
+ def all_ccs; (tos||[]) + (ccs||[]) + [from] + [mail_from]; end ## this is uncertain... _vp_ 2026-07-20
71
72
  field :bcc, type: :string
72
73
  field :bccs, type: Array, default: []
73
74
 
@@ -75,6 +75,7 @@ class WcoEmail::MessageStub
75
75
  ## Leadset, Lead
76
76
  # from = json['mail_from'] || "nobody@unknown-doma.in"
77
77
  from = json['from'][/<([^>]+)>/, 1].downcase rescue json['mail_from']
78
+ mail_from = json['mail_from']
78
79
  @lead = Wco::Lead.find_or_create_by_email( from )
79
80
  @conv.leads.push @lead
80
81
  @leadset = Wco::Leadset.from_email from
@@ -95,7 +96,8 @@ class WcoEmail::MessageStub
95
96
  subject: subject,
96
97
  date: json['date'].to_s,
97
98
 
98
- from: from,
99
+ from: from,
100
+ mail_from: mail_from,
99
101
  to: json['to'],
100
102
  cc: json['cc'],
101
103
 
@@ -156,6 +158,11 @@ class WcoEmail::MessageStub
156
158
  end
157
159
  end
158
160
 
161
+ if 'Spam' == json['spam_status']
162
+ @conv.tags.push Wco::Tag.spam
163
+ conv.tags -= [ Wco::Tag.inbox ]
164
+ end
165
+
159
166
  stub.update_attributes({ status: WcoEmail::MessageStub::STATUS_PROCESSED })
160
167
 
161
168
  ## Notification
@@ -0,0 +1,12 @@
1
+
2
+ json.email @lead.email
3
+ json.leadset do
4
+ json.tags @lead.leadset.tags.each do |tag|
5
+ json.id tag.id.to_s
6
+ json.slug tag.slug
7
+ end
8
+ end
9
+ json.tags @lead.tags.each do |tag|
10
+ json.id tag.id.to_s
11
+ json.slug tag.slug
12
+ end
data/config/routes.rb CHANGED
@@ -6,8 +6,10 @@ Wco::Engine.routes.draw do
6
6
 
7
7
  namespace :api do
8
8
  get 'leads', to: 'leads#index'
9
+ get 'leads/by-email/:email', to: 'leads#by_email', constraints: { email: /[^\/]+/ }
9
10
  get 'leads/index_hash', to: 'leads#index_hash'
10
11
 
12
+
11
13
  get 'obf', to: 'obfuscated_redirects#show' ## testing only.
12
14
  get 'obf/:id', to: 'obfuscared_redirects#show'
13
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.298
4
+ version: 3.1.0.300
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-19 00:00:00.000000000 Z
11
+ date: 2026-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -545,6 +545,7 @@ files:
545
545
  - app/views/wco/_search.haml
546
546
  - app/views/wco/_select_all.haml
547
547
  - app/views/wco/_sidebar.haml
548
+ - app/views/wco/api/leads/by_email.jbuilder
548
549
  - app/views/wco/api/leads/index.jbuilder
549
550
  - app/views/wco/api/leads/index_hash.jbuilder
550
551
  - app/views/wco/api/tags/index.json.jbuilder