wco_models 3.1.0.251 → 3.1.0.252

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: 39ff8539983a6709aedd6fcf0911f115be954871240531a07da6f1afb3c4190b
4
- data.tar.gz: fafe5bc829f076d8c6ac44530452ced44dab15cd0d7e6b07bd2a816fa4666d8b
3
+ metadata.gz: ed799fd6948e57e5cac5dbd097f38e5d0667f6c5463a1ddecd8c105664b615cc
4
+ data.tar.gz: 513fd17a407cda9383315c04afad64a9f3b67725619db1472e445fba722137f8
5
5
  SHA512:
6
- metadata.gz: cfe753f23ac7f15c7cf6921f30cf097354983bfa0cbd0e9edf70498a2e4a5537a9fce49b24d4b4ec3a3da5f82c10dfb821ba5615ef91c57fb4e79b711b07ce4e
7
- data.tar.gz: bf43f6f095b710c1348e97bfe107633dc11f479784ca1f3c9a3acc11d38b8d63d37c8739e5ae531234e6d1804657ec53beb04d00388b123f555c30391ff90506
6
+ metadata.gz: f78c8eef005478261535954e8fe4627d24dc88a6502abe709bd79a0499690389b4744c21ace3c991b68b45935f713308aafed1e79e7f36eb557c803fac447f14
7
+ data.tar.gz: 7904647d7475fca316cfa238d511c40bbc0d9bdef8efe3eb6f15ac44deda98b9e11eb1aab9c9637d8c5063e21672ccc970b429a78cb9013cdf8e385d57f02a4c
@@ -2,6 +2,9 @@
2
2
  ## In order to have unsubscribes_url , unsubscribes must be in wco .
3
3
  class Wco::UnsubscribesController < Wco::ApplicationController
4
4
 
5
+ skip_before_action :current_profile, only: [ :create, :do_unsubscribe, :new, ]
6
+
7
+
5
8
  def create
6
9
  authorize! :open_permission, Wco
7
10
  @lead = Wco::Lead.find params[:lead_id]
@@ -29,6 +32,19 @@ class Wco::UnsubscribesController < Wco::ApplicationController
29
32
  render layout: false
30
33
  end
31
34
 
35
+ def do_unsubscribe
36
+ authorize! :open_permission, Wco
37
+ lead = Wco::Lead.find_by email: params[:email]
38
+ if params[:token] == lead.unsubscribe_token
39
+ lead.update({ unsubscribed_at: Time.now })
40
+ flash[:notice] = 'You have been unsubscribed!'
41
+ render 'success', layout: false
42
+ else
43
+ flash[:error] = 'security token mismatch.'
44
+ render 'error', layout: false
45
+ end
46
+ end
47
+
32
48
  def index
33
49
  authorize! :index, WcoEmail::Unsubscribe
34
50
  @unsubscribes = WcoEmail::Unsubscribe.all
@@ -36,5 +52,10 @@ class Wco::UnsubscribesController < Wco::ApplicationController
36
52
  render '_table'
37
53
  end
38
54
 
55
+ def new
56
+ authorize! :open_permission, Wco
57
+ render layout: false
58
+ end
59
+
39
60
  end
40
61
 
@@ -38,8 +38,20 @@ class WcoEmail::ApplicationMailer < ActionMailer::Base
38
38
  @renderer = self.class.renderer ctx: @ctx
39
39
  rendered_str = @renderer.render_to_string("/wco_email/email_layouts/_#{@ctx.tmpl.layout}")
40
40
 
41
+ if @ctx.lead.unsubscribed_at
42
+ @ctx.update({
43
+ unsubscribed_at: Time.now,
44
+ })
45
+ return
46
+ end
47
+
48
+ ## for binding only
49
+ @lead = @ctx.lead
50
+ lead = @lead
51
+ @leadset = @ctx.lead.leadset
52
+ leadset = @leadset
53
+ rendered_subject = ERB.new( @ctx.subject ).result( binding )
41
54
 
42
- rendered_subject = ERB.new( @ctx.subject ).result( @ctx.get_binding )
43
55
  if @ctx.lead.leadset.mangle_subject || @ctx.email_template.mangle_subject
44
56
  ## From: https://www.ascii-code.com/
45
57
  n1 = 33
@@ -57,9 +69,9 @@ class WcoEmail::ApplicationMailer < ActionMailer::Base
57
69
  end
58
70
 
59
71
  @ctx.update({
60
- rendered_str: rendered_str,
61
- sent_at: Time.now,
62
- subject: rendered_subject,
72
+ rendered_str: rendered_str,
73
+ sent_at: Time.now,
74
+ rendered_subject: rendered_subject,
63
75
  })
64
76
 
65
77
  profile = Wco::Profile.find_by email: @ctx.from_email
@@ -108,6 +120,7 @@ class WcoEmail::ApplicationMailer < ActionMailer::Base
108
120
  out = self.new
109
121
  out.instance_variable_set( :@ctx, ctx )
110
122
  out.instance_variable_set( :@lead, ctx.lead )
123
+ out.instance_variable_set( :@leadset, ctx.lead.leadset )
111
124
  out.instance_variable_set( :@utm_tracking_str, ctx.utm_tracking_str )
112
125
  out.instance_variable_set( :@unsubscribe_url, ctx.unsubscribe_url )
113
126
  out.instance_variable_set( :@config, ctx.config )
@@ -12,6 +12,14 @@ class Wco::Lead
12
12
  index({ email: -1 }, { unique: true })
13
13
 
14
14
  field :name
15
+ def name
16
+ if !self[:name].present?
17
+ _name = (email[/\A[a-zA-Z]+/] || 'associate').capitalize
18
+ update_attributes( name: _name )
19
+ end
20
+ self[:name]
21
+ end
22
+
15
23
  field :phone
16
24
  field :address
17
25
  field :comment ## _TODO: replace with log?
@@ -80,6 +88,7 @@ class Wco::Lead
80
88
  end
81
89
  self[:unsubscribe_token]
82
90
  end
91
+ field :unsubscribed_at
83
92
 
84
93
  def to_s
85
94
  # "`#{name}` <#{email}>"
@@ -33,7 +33,7 @@ class Wco::OfficeActionTemplate
33
33
  # has_and_belongs_to_many :email_filters, class_name: WcoEmail::EmailFilter
34
34
  has_many :email_filters, class_name: '::WcoEmail::EmailFilter', inverse_of: :office_action_template
35
35
 
36
- has_many :ajects, inverse_of: :aject ## email action object
36
+ has_many :ajects, class_name: '::WcoEmail::EmailFilterAction', inverse_of: :aject ## email action object
37
37
 
38
38
  def to_s
39
39
  "#{slug}"
@@ -10,9 +10,12 @@ class Wco::Photo
10
10
  include Wco::Utils
11
11
  store_in collection: 'photos'
12
12
 
13
- belongs_to :email_message, class_name: 'WcoEmail::Message', optional: true
14
- belongs_to :gallery, class_name: 'Wco::Gallery', optional: true
15
- belongs_to :lead, class_name: 'Wco::Lead', optional: true
13
+ belongs_to :email_message, class_name: 'WcoEmail::Message', optional: true
14
+
15
+ belongs_to :gallery, class_name: 'Wco::Gallery', optional: true
16
+ belongs_to :lead, class_name: 'Wco::Lead', optional: true
17
+
18
+ has_many :email_templates, class_name: 'WcoEmail::EmailTemplate'
16
19
  # belongs_to :newsitem, :optional => true
17
20
 
18
21
  field :name
@@ -53,6 +53,7 @@ class WcoEmail::Context
53
53
  end
54
54
 
55
55
  field :subject
56
+ field :rendered_subject
56
57
  def subject
57
58
  self[:subject].presence || tmpl&.subject
58
59
  end
@@ -15,7 +15,7 @@ class WcoEmail::EmailActionTemplate
15
15
 
16
16
  belongs_to :email_template, class_name: 'EmailTemplate'
17
17
 
18
- has_many :ajects, inverse_of: :aject ## email action object
18
+ has_many :ajects, class_name: '::WcoEmail::EmailFilterAction', inverse_of: :aject ## email action object
19
19
 
20
20
  has_many :email_actions, class_name: 'EmailAction'
21
21
 
@@ -127,7 +127,9 @@ class WcoEmail::EmailTemplate
127
127
  has_many :email_contexts, class_name: '::WcoEmail::Context'
128
128
  has_many :email_filters, class_name: '::WcoEmail::EmailFilter'
129
129
  has_many :unsubscribes, class_name: '::WcoEmail::Unsubscribe'
130
- has_many :ajects, inverse_of: :aject ## email action object
130
+ has_many :ajects, class_name: '::WcoEmail::EmailFilterAction', inverse_of: :aject ## email action object
131
+
132
+ belongs_to :photo, class_name: '::Wco::Photo', optional: true # , dependent: :destroy, inverse_of: :email_template
131
133
 
132
134
  belongs_to :tag, class_name: '::Wco::Tag', inverse_of: :email_templates, optional: true
133
135
 
@@ -0,0 +1,9 @@
1
+
2
+
3
+ .unsubscribes-error
4
+ %h2.text-center
5
+ Could not unsubscribe:
6
+ = flash[:error]
7
+
8
+ %p Please submit a manual unsubscribe request at #{link_to 'wasya.co/unsubscribe', 'https://wasyaco.com/unsubscribe' }.
9
+
@@ -0,0 +1,10 @@
1
+
2
+ .unsubscribes--new{ style: "font-size: 2em;" }
3
+ %h5.text-center
4
+ Unsubscribe from WasyaCo emails
5
+
6
+ = form_tag do
7
+ %label email
8
+ = text_field_tag :email, params[:email], style: "min-width: 300px; padding: 1em;"
9
+ = submit_tag 'Unsubscribe'
10
+
@@ -0,0 +1,5 @@
1
+
2
+ .unsubscribes-success
3
+ %h5.text-center
4
+ You have been unsubscribed!
5
+
@@ -18,3 +18,8 @@
18
18
  .mini{ style: "font-size: 0.7em; color: gray; text-align: right" } Your previous message is shown below.
19
19
  %hr
20
20
  = raw @ctx.reply_to_message.part_html_sanitized
21
+
22
+ %br
23
+ = link_to 'unsubscribe', wco.unsubscribe_by_token_url( token: @ctx.lead.unsubscribe_token, email: @ctx.lead.email ), style: "color: #999;"
24
+ %br
25
+ .div{ style: "color: #999;" } WasyaCo 201 W 5th St 11th Floor, Austin, TX 78701
data/config/routes.rb CHANGED
@@ -105,7 +105,9 @@ Wco::Engine.routes.draw do
105
105
  resources :tags
106
106
 
107
107
  ## In order to have unsubscribes_url , unsubscribes must be in wco .
108
- get 'unsubscribes/analytics', to: 'unsubscribes#analytics'
108
+ get 'unsubscribes/analytics', to: 'unsubscribes#analytics'
109
+ get 'api/unsubscribes/by-token/:token', to: 'unsubscribes#new', as: :unsubscribe_by_token
110
+ post 'api/unsubscribes/by-token/:token', to: 'unsubscribes#do_unsubscribe'
109
111
  resources :unsubscribes
110
112
 
111
113
  resources :videos
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.251
4
+ version: 3.1.0.252
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-04-03 00:00:00.000000000 Z
11
+ date: 2026-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey
@@ -716,6 +716,9 @@ files:
716
716
  - app/views/wco/tags/show.haml
717
717
  - app/views/wco/unsubscribes/_header.haml
718
718
  - app/views/wco/unsubscribes/_table.haml
719
+ - app/views/wco/unsubscribes/error.haml
720
+ - app/views/wco/unsubscribes/new.haml
721
+ - app/views/wco/unsubscribes/success.haml
719
722
  - app/views/wco/videos/_form.haml
720
723
  - app/views/wco/videos/_header.haml
721
724
  - app/views/wco/videos/_index.haml