wco_email 0.1.1.12 → 0.1.1.13

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: 12cf9a51987708d2c99caa370d30c2fe09466831e570e76b6ec3d4f43b6e8747
4
- data.tar.gz: 681fee4ecf20113fb5ef901042326b030de4fa4a08016f9cc31fb5ad1e2e6acd
3
+ metadata.gz: 798f3bc1093d02b7405855d74532bc6e1258a37b113795dd76f81da72c269893
4
+ data.tar.gz: '089b867ad73eeb50b96d9a7ab499b6709c6db1c01122411236a6b6cd2d095bad'
5
5
  SHA512:
6
- metadata.gz: 27452f09a3756eb4622b51fdd165baa5843bf045fc3f1de1e9b06f66e5954cb321a1dcbe6eebb0a63881809597053906035d05c8dabb20c2c05d2382cb024429
7
- data.tar.gz: 04c4c2b58ae84f428ff0885630b18e21cda3bbb702e661dd29cd0b2424a67987ba8e1f10daed09375ccdf4ccb859761a96fcdbc59917695041f31bd8f66743fb
6
+ metadata.gz: 2b00bb00175f132d174fbf6ed0da9a9263ef53b1b3cd77238d7acee7d47c567c3edbe94f97982df845084933c3a8577e19abfe0394f6c108151f4b22dc6793d3
7
+ data.tar.gz: f82f3473ed65ed5815997cef819c71555db9e5f980735d86255f6f4e5a274f908f6ed42bd4e97bd137646f30bad5a0a526f04c09e8350a61a9f609e67f355632
data/README.txt CHANGED
@@ -1,129 +1,4 @@
1
- curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{
2
- "model": "gpt-3.5-turbo",
3
- "messages": [
4
- {
5
- "role": "system",
6
- "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
7
- },
8
- {
9
- "role": "user",
10
- "content": "Compose a poem that explains the concept of recursion in programming."
11
- }
12
- ]
13
- }'
14
1
 
15
- curl --include \
16
- --request POST \
17
- --user admin:$pi_passwd \
18
- --header 'Content-type: application/hal+json' \
19
- http://pi.local/node?_format=hal_json \
20
- --data-binary '{
21
- "_links": {
22
- "type":{"href":"http://pi.local/rest/type/node/article"}
23
- },
24
- "title":[{"value":"Test Tree #1" }],
25
- "body":[{"value": "<h1>Hello, world!</h1><img src='http://ish-drupal-prod.s3.amazonaws.com/public/2023-09/200x200%20piousbox%20favicon.png?VersionId=6QVFTwCGApZMbrkmP_MlEhaCB2_5J1DG' alt='' />", "format": "full_html" }],
26
- "type":[{"target_id":"article"}],
27
- "field_image_thumb_url":[{"value": "http://ish-drupal-prod.s3.amazonaws.com/public/2023-09/200x200%20piousbox%20favicon.png?VersionId=6QVFTwCGApZMbrkmP_MlEhaCB2_5J1DG" }],
28
- "status": [{"value": 1}],
29
- "_embedded": {
30
- "http://pi.local/rest/relation/node/article/field_issue": [
31
- { "uuid": [{ "value": "56229a95-d675-43e1-99b1-f9e11b5579c5" }] }
32
- ],
33
- "http://pi.local/rest/relation/node/article/field_tags": [
34
- { "uuid": [{ "value": "45646a7d-1a16-42e8-b758-f6e1c8d976f7" }] },
35
- { "uuid": [{ "value": "834e34e2-05ae-498d-b876-453798872ce1" }] }
36
- ]
37
- }
38
- }'
39
2
 
40
-
41
- curl --include \
42
- --request POST \
43
- --user admin:$pi_passwd \
44
- --header 'Content-type: application/hal+json' \
45
- http://pi.local/entity/file?_format=hal_json \
46
- --data-binary '{
47
- "_links": { "type": { "href": "http://pi.local/rest/type/file/image" } },
48
- "filename": [
49
- {
50
- "value": "favicon-32x32.png"
51
- }
52
- ],
53
- "filemime": [
54
- {
55
- "value": "image/png"
56
- }
57
- ],
58
- "type":[{"target_id":"image"}],
59
- "data": [
60
- {
61
- "value": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBAUEBAYFBQUGBgYHCQ4JCQgICRINDQoOFRIWFhUSFBQXGiEcFxgfGRQUHScdHyIjJSUlFhwpLCgkKyEkJST/2wBDAQYGBgkICREJCREkGBQYJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCT/wgARCAAyADIDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAQADAgX/xAAWAQEBAQAAAAAAAAAAAAAAAAAAAQX/2gAMAwEAAhADEAAAAfTEysMEAeVqjURARQQKjUhIRYgrmNipAqgpSo//xAAUEAEAAAAAAAAAAAAAAAAAAABQ/9oACAEBAAEFAkf/xAAUEQEAAAAAAAAAAAAAAAAAAABA/9oACAEDAQE/AQf/xAAUEQEAAAAAAAAAAAAAAAAAAABA/9oACAECAQE/AQf/xAAUEAEAAAAAAAAAAAAAAAAAAABQ/9oACAEBAAY/Akf/xAAZEAACAwEAAAAAAAAAAAAAAAAAARARIED/2gAIAQEAAT8hy8PvssY4Y5//2gAMAwEAAgADAAAAEBDRANssv3ci/wCOOAP/xAAVEQEBAAAAAAAAAAAAAAAAAAABQP/aAAgBAwEBPxAg/8QAFhEAAwAAAAAAAAAAAAAAAAAAABEw/9oACAECAQE/EBX/AP/EABoQAQEBAQADAAAAAAAAAAAAAAEAERAgITH/2gAIAQEAAT8QZmeLjzEpM22y2y2y22yzPuWbJbdm2WbJllllnzAfnP/Z"
62
- }
63
- ]
64
- }'
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
- curl --include \
75
- --request POST \
76
- --user admin:$pi_passwd \
77
- --header 'Content-type: application/hal+json' \
78
- http://pi.local/entity/file?_format=hal_json \
79
- --data-binary '{
80
- "_links": {
81
- "type": {
82
- "href": "http://pi.local/rest/type/file/image"
83
- }
84
- },
85
- "filename": [
86
- {
87
- "value": "favicon-32x32.png"
88
- }
89
- ],
90
- "filemime": [
91
- {
92
- "value": "image/png"
93
- }
94
- ],
95
- "filesize": [
96
- {
97
- "value": "488"
98
- }
99
- ],
100
- "type": [
101
- {
102
- "target_id": "image"
103
- }
104
- ],
105
- "data": [
106
- {
107
- "value": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAkUExURUxpcSOq4SOq4SOq4SOq4SOq4SOq4SOq4SOq4SOq4SOq4SOq4U0m8UcAAAAMdFJOUwD/EvAm2qhTPMRrkl4CMYAAAAE1SURBVCjPXZG/S8NQEMePR7Ehnb48khC7BEFFnYJD6/aWOLilVBy6WBVc648/oCii1KlFKDrFwV2tqH+edy9Rk7zh8e7Dfe++944oP5dUO59RDQyPqrFK/WqKCzxUwA30oJyymervlVK8PsVBOd85hh6pyflfhwXg024cjguwBqCjhsCsSOAn+k4MBGpUWAB6Tb6W1VxAgv+MfcPgWUBgazjxoYwlQLrsmBa6MhbH3hep2yu6QJuowWL9Yfs1U4QRSbWOjRts0DMCdEbqjl8s1kYkPqmX7YGRfgy4aJe2IB+0wZJI2s7ojEGbWtJejL1aL55h+wGDVWTWix47+cAug6kAycjs+LkkjFzku0h6dC3D01KxCmdOLrt7pyQ0+Z/tRXT/eEr0dvL7y6zkrbhPtYVPrOAHKZQ53IyepQMAAAAASUVORK5CYII="
108
- }
109
- ]
110
- }'
111
-
112
-
113
-
114
-
115
- curl --include \
116
- --request POST \
117
- --user admin:$pi_passwd \
118
- --header 'Content-type: application/hal+json' \
119
- http://wco.local:8088/node?_format=hal_json \
120
- --data-binary '{
121
- "_links": {
122
- "type":{"href":"http://wco.local:8088/rest/type/node/article"}
123
- },
124
- "title":[{"value":"Test Tree #1" }],
125
- "body":[{"value": "<h1>Hello, world!</h1><img src='http://ish-drupal-prod.s3.amazonaws.com/public/2023-09/200x200%20piousbox%20favicon.png?VersionId=6QVFTwCGApZMbrkmP_MlEhaCB2_5J1DG' alt='' />", "format": "full_html" }],
126
- "type":[{"target_id":"article"}],
127
- "field_image_thumb_url":[{"value": "http://ish-drupal-prod.s3.amazonaws.com/public/2023-09/200x200%20piousbox%20favicon.png?VersionId=6QVFTwCGApZMbrkmP_MlEhaCB2_5J1DG" }],
128
- "status": [{"value": 1}]
129
- }'
3
+ cd test/dummy
4
+ be sidekiq -q wco_email_rb_mailers -q wco_email_rb_default -q wco_email_rb
@@ -6,60 +6,62 @@ class WcoEmail::EmailActionTemplatesController < WcoEmail::ApplicationController
6
6
  ## Alphabetized : )
7
7
 
8
8
  def destroy
9
- @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
10
- authorize! :delete, @act
11
- @act.update_attributes({ deleted_at: Time.now })
9
+ @tmpl = WcoEmail::EmailActionTemplate.find( params[:id] )
10
+ authorize! :delete, @tmpl
11
+ @tmpl.delete
12
12
  flash_notice 'Probably success'
13
13
  redirect_to action: :index
14
14
  end
15
15
 
16
16
  def edit
17
- @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
18
- # @act.ties.push WcoEmail::EmailActionTie.new( next_email_action_id: nil )
19
- authorize! :edit, @act
17
+ @tmpl = WcoEmail::EmailActionTemplate.find( params[:id] )
18
+ @tmpl.ties.push WcoEmail::EmailActionTemplateTie.new( next_tmpl_id: nil )
19
+ authorize! :edit, @tmpl
20
20
  end
21
21
 
22
22
  def index
23
- @email_actions = WcoEmail::EmailAction.where({ :deleted_at => nil })
23
+ @tmpls = WcoEmail::EmailActionTemplate.all
24
24
 
25
- authorize! :index, @new_email_action
25
+ authorize! :index, @new_tmpl
26
26
  end
27
27
 
28
28
  def new
29
- authorize! :new, @new_email_action
29
+ authorize! :new, @new_tmpl
30
30
  end
31
31
 
32
32
  def show
33
- @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
34
- authorize! :show, @act
33
+ @tmpl = WcoEmail::EmailActionTemplate.find( params[:id] )
34
+ authorize! :show, @tmpl
35
35
  end
36
36
 
37
- def update
37
+ def update # or create
38
+ puts! params, 'params'
39
+
38
40
  if params[:id]
39
- @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
41
+ @tmpl = WcoEmail::EmailActionTemplate.find( params[:id] )
40
42
  else
41
- @act = @email_action = WcoEmail::EmailAction.new
43
+ @tmpl = WcoEmail::EmailActionTemplate.new
42
44
  end
43
- authorize! :upsert, @act
45
+ authorize! :upsert, @tmpl
44
46
 
45
- if params[:email_action][:ties_attributes]
46
- params[:email_action][:ties_attributes].each do |k, v|
47
- if !v[:next_email_action_id].present?
48
- params[:email_action][:ties_attributes].delete( k )
47
+ if params[:tmpl][:ties_attributes]
48
+ params[:tmpl][:ties_attributes].each do |k, v|
49
+ if !v[:next_tmpl_id].present?
50
+ params[:tmpl][:ties_attributes].delete( k )
49
51
  end
50
52
  if v[:to_delete] == "1"
51
- EActie.find( v[:id] ).delete
52
- params[:email_action][:ties_attributes].delete( k )
53
+ WcoEmail::EmailActionTemplateTie.find( v[:id] ).delete
54
+ params[:tmpl][:ties_attributes].delete( k )
53
55
  end
54
56
  end
55
57
  end
56
58
 
57
- flag = @act.update_attributes( params[:email_action].permit! )
59
+ flag = @tmpl.update_attributes( params[:tmpl].permit! )
58
60
  if flag
59
61
  flash[:notice] = 'Success'
60
62
  redirect_to action: 'index'
61
63
  else
62
- flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}. #{@act.ties.map { |t| t.errors.full_messages.join(', ') }.join(' | ') }"
64
+ flash[:alert] = "No luck: #{@tmpl.errors.full_messages.join(', ')}. #{@tmpl.ties.map { |t| t.errors.full_messages.join(', ') }.join(' | ') }"
63
65
  render action: 'edit'
64
66
  end
65
67
 
@@ -71,7 +73,9 @@ class WcoEmail::EmailActionTemplatesController < WcoEmail::ApplicationController
71
73
  private
72
74
 
73
75
  def set_lists
74
- @new_email_action = WcoEmail::EmailAction.new
76
+ @email_action_templates_list = WcoEmail::EmailActionTemplate.list
77
+ @email_templates_list = WcoEmail::EmailTemplate.list
78
+ @new_tmpl = WcoEmail::EmailActionTemplate.new
75
79
  end
76
80
 
77
81
  end
@@ -6,7 +6,7 @@ class WcoEmail::EmailActionsController < WcoEmail::ApplicationController
6
6
  before_action :set_lists
7
7
 
8
8
  def create
9
- @sch = Sch.new( params[:sch].permit! )
9
+ @sch = Sch.new( params[:email_action].permit! )
10
10
  authorize! :create, @sch
11
11
 
12
12
  flag = @sch.save
@@ -29,7 +29,7 @@ class WcoEmail::EmailActionsController < WcoEmail::ApplicationController
29
29
  end
30
30
 
31
31
  def new
32
- @sch = Sch.new
32
+ @email_action = WcoEmail::EmailAction.new
33
33
  authorize! :new, @sch
34
34
  end
35
35
 
@@ -42,7 +42,7 @@ class WcoEmail::EmailActionsController < WcoEmail::ApplicationController
42
42
  def update
43
43
  @sch = Sch.find params[:id]
44
44
  authorize! :update, @sch
45
- flag = @sch.update_attributes( params[:sch].permit! )
45
+ flag = @sch.update_attributes( params[:email_action].permit! )
46
46
  if flag
47
47
  flash[:notice] = "Success."
48
48
  else
@@ -51,5 +51,15 @@ class WcoEmail::EmailActionsController < WcoEmail::ApplicationController
51
51
  render action: 'edit'
52
52
  end
53
53
 
54
+ ##
55
+ ## private
56
+ ##
57
+ private
58
+
59
+ def set_lists
60
+ @email_action_templates_list = WcoEmail::EmailActionTemplate.list
61
+ @leads_list = Wco::Lead.list
62
+ end
63
+
54
64
  end
55
65
 
@@ -33,7 +33,7 @@ class WcoEmail::MessageIntakeJob
33
33
  puts "+++ +++ Performing WcoEmail::MessageIntakeJob for object_key `#{stub.object_key}`."
34
34
 
35
35
  if [ WcoEmail::MessageStub::STATUS_PROCESSED, WcoEmail::MessageStub::STATUS_FAILED ].include?( stub.status )
36
- raise "This stub has already been processed: #{stub.id.to_s}."
36
+ raise "This stub has already been processed, or errored out: #{stub.id.to_s}."
37
37
  return
38
38
  end
39
39
 
@@ -1,25 +1,21 @@
1
1
 
2
- - eact = email_action
3
- - url = email_action.new_record? ? email_actions_path : email_action_path( email_action )
2
+ .email-action-templates--form
4
3
 
5
- .email-actions--form
6
-
7
- = form_for email_action, url: url, as: :email_action, :html => { :multipart => true } do |f|
8
- .row
9
- .col-sm-6
10
- = f.submit :submit
4
+ = form_for tmpl, as: :tmpl, :html => { :multipart => true } do |f|
5
+ .a
6
+ = f.submit :submit
11
7
 
12
8
  .row
13
9
  .col-md-6
14
10
  .field
15
11
  %label Slug
16
12
  = f.text_field :slug
17
- -# .field
18
- -# %label Descr
19
- -# = f.text_area :descr
20
- .field.flex-row
13
+ .field
14
+ %label from_email
15
+ = f.select :from_email, options_for_select( WcoEmail::EmailTemplate::FROM_EMAILS_2, selected: tmpl.from_email ), {}, { class: 'select2' }
16
+ .field
21
17
  %label Template
22
- = f.select :email_template_id, options_for_select( @email_templates_list, selected: eact.email_template_id ), {}, class: 'select2'
18
+ = f.select :email_template_id, options_for_select( @email_templates_list, selected: tmpl.email_template_id ), {}, class: 'select2'
23
19
 
24
20
  .col-md-6
25
21
  .field
@@ -30,12 +26,12 @@
30
26
 
31
27
  = f.fields_for :ties do |next_f|
32
28
  .flex-row.field
33
- = next_f.label :next_at_exe
34
- = next_f.text_field :next_at_exe, class: 'flex-grow'
29
+ %label next_at_exe
30
+ = next_f.text_field :next_at_exe, class: 'flex-grow-1 w-100'
35
31
  .flex-row.field
36
32
  = next_f.label :to_delete
37
33
  = next_f.check_box :to_delete
38
- = next_f.select :next_email_action_id, options_for_select( @email_actions_list, selected: next_f.object.next_email_action_id ), { }, { class: 'select2' }
34
+ = next_f.select :next_tmpl_id, options_for_select( @email_action_templates_list, selected: next_f.object.next_tmpl_id ), { }, { class: 'select2' }
39
35
  %br
40
36
 
41
37
  .row
@@ -0,0 +1,7 @@
1
+
2
+ = link_to '[~]', edit_email_action_template_path( tmpl )
3
+ = link_to tmpl.slug, email_action_template_path( tmpl )
4
+ -# %br
5
+ -# <b>from_email:</b> #{tmpl.from_email}
6
+ -# %br
7
+ -# <b>subject:</b> #{tmpl.subject}
@@ -1,7 +1,7 @@
1
1
 
2
2
  .email-actions-edit.padded
3
3
  .header
4
- %h2.title Edit Email Action
4
+ %h5.title Edit Email Action Template
5
5
 
6
- = render 'form', email_action: @act
6
+ = render 'form', tmpl: @tmpl
7
7
 
@@ -1,36 +1,45 @@
1
1
 
2
- .email-actions-index.padded
2
+ .email-action-templates-index.padded
3
3
 
4
4
  .header
5
5
  %h2.title
6
- Email Actions (#{@email_actions.length})
7
- = link_to '[+]', new_email_action_path
6
+ Email Action Templates (#{@tmpls.length})
7
+ = link_to '[+]', new_email_action_template_path
8
8
 
9
9
  %table.bordered
10
10
  %tr
11
- %th= check_box_tag 'abba'
12
- %th
13
- %th slug
11
+ %th= check_box_tag 'hmm'
12
+ %th &nbsp;
13
+ %th Slug
14
+ %th From
15
+ %th Tmpl
14
16
  %th next actions
15
- - @email_actions.each do |eact|
17
+ - @tmpls.each_with_index do |tmpl, idx|
16
18
  %tr
17
- %td= check_box_tag 'abba'
18
- %td.flex-row
19
-
20
- = link_to '[~]', edit_email_action_path( eact )
21
- = button_to '[x]', email_action_path( eact ), data: { confirm: 'Are you sure?' }, method: :delete
19
+ %td
20
+ .gray= idx+1
21
+ = check_box_tag 'hmm'
22
+ %td
23
+ .flex-row
24
+ = link_to '[~]', edit_email_action_template_path( tmpl )
25
+ = button_to '[x]', email_action_template_path( tmpl ), data: { confirm: 'Are you sure?' }, method: :delete
22
26
 
23
27
  %td
24
- -# = link_to eact.slug, email_action_path( eact )
25
- = eact.slug
26
- .em.small= eact.descr
28
+ = tmpl.slug
29
+ %td
30
+ = tmpl.from_email
31
+ %td.tmpl
32
+ = render '/wco_email/email_templates/show_cell', tmpl: tmpl.email_template
33
+
27
34
  %td
35
+ - if tmpl.ties.blank?
36
+ No ties
28
37
  %ul
29
- - eact.ties.map do |next_a|
38
+ - tmpl.ties.map do |tie|
30
39
  %li
31
- .a= next_a.next_at_exe
40
+ .a= tie.next_at_exe
32
41
  .a
33
- - if next_a.next_email_action.slug == eact.slug
42
+ - if tie.next_tmpl.slug == tmpl.slug
34
43
  (same)
35
- = next_a.next_email_action.slug
44
+ = tie.next_tmpl.slug
36
45
 
@@ -1,9 +1,7 @@
1
1
 
2
- -# padded b/c eval(next_time_at) is long
3
-
4
- .email-actions-new.padded
2
+ .email-action-templates-new.maxwidth
5
3
  .header
6
4
  %h2.title
7
- New Email Action
5
+ New Email Action Template
8
6
 
9
- = render 'form', email_action: @new_email_action
7
+ = render 'form', tmpl: @new_tmpl
@@ -1,11 +1,10 @@
1
1
 
2
2
  .email-actions-show.maxwidth
3
3
  .header
4
- .title Email Action #{@act.id}
4
+ %h5.title Email Action Template `#{@tmpl}`
5
5
 
6
6
  %ul
7
- - @act.ties.map do |next_a|
7
+ - @tmpl.ties.map do |tie|
8
8
  %li
9
- .a <b>Next act:</b> #{"(same)" if next_a.next_email_action.slug == @act.slug} #{next_a.next_email_action.slug}
10
- .a <b>Next at exe:</b> #{next_a.next_at_exe}
11
- .a <b>Eval'ed:</b> #{eval( next_a.next_at_exe )}
9
+ .a <b>Next tmpl:</b> #{"(same)" if tie.next_tmpl.slug == @tmpl.slug} #{tie.next_tmpl.slug}
10
+ .a <b>Next at exe:</b> #{tie.next_at_exe} <b>Eval'ed:</b> #{eval( tie.next_at_exe )}
@@ -1,24 +1,20 @@
1
1
 
2
- - sch_a = scheduled_email_action
3
- - url = sch_a.new_record? ? scheduled_email_actions_path : scheduled_email_action_path(sch_a.id)
4
-
5
- .scheduled-email-actions--form
6
- = form_for scheduled_email_action, url: url, as: :sch do |f|
2
+ .email-actions--form
3
+ = form_for email_action do |f|
7
4
  .header
8
- %h5.title Schedule an email action
5
+ %h5.title Schedule an Email Action
9
6
 
10
7
  .flex-row
11
- = f.label :lead
12
- = f.select :lead_id, options_for_select(@leads_list, selected: sch_a[:lead_id]||params[:lead_id] ), {}, class: 'select2'
13
- .flex-row
14
- %label State
15
- = f.select :state, options_for_select(::Office::ScheduledEmailAction::STATES, selected: sch_a.state )
8
+ %label Status
9
+ = f.select :status, options_for_select(WcoEmail::EmailAction::STATUSES, selected: email_action.status )
10
+
16
11
  .flex-row
17
- = f.label :email_action
18
- = f.select :email_action, options_for_select( @email_actions_list, selected: sch_a[:email_action_id] ), {}, class: 'select2'
12
+ = f.label :lead
13
+ = f.select :lead_id, options_for_select(@leads_list, selected: email_action[:lead_id]||params[:lead_id] ), {}, class: 'select2'
14
+ = f.label :email_action_template
15
+ = f.select :email_action_template, options_for_select( @email_action_templates_list, selected: email_action[:email_action_template_id] ), {}, class: 'select2'
16
+
19
17
  .flex-row
20
18
  = f.label :perform_at
21
- = f.text_field :perform_at, value: sch_a.new_record? ? Time.now : sch_a.perform_at
22
-
23
- .actions
19
+ = f.text_field :perform_at, value: email_action.new_record? ? Time.now : email_action.perform_at, class: 'flex-grow-1'
24
20
  = submit_tag 'Schedule'
@@ -1,4 +1,4 @@
1
1
 
2
2
  .scheduled-email-actions-edit.maxwidth
3
3
 
4
- = render 'form', scheduled_email_action: @sch
4
+ = render 'form', email_action: @sch
@@ -11,18 +11,21 @@
11
11
  %tr
12
12
  %td
13
13
  %td Active?
14
- %td From
15
- %td To
16
- %td Tmpl
14
+ %td Email Action Template
15
+ %td To <br />(Lead)
16
+ %td.tmpl Email Template
17
17
  %td Perform at
18
18
  %tbody
19
19
  - @schs.each do |sch|
20
20
  %tr
21
21
  %td= link_to '[~]', edit_email_action_path(sch)
22
22
  %td= sch.status == 'active' ? 'Y' : '-'
23
- %td= sch.tmpl.from_email
24
- %td= link_to sch.lead.email, lead_path(sch.lead)
25
- %td= link_to sch.tmpl.email_template.slug, email_template_path(sch.tmpl.email_template)
23
+ %td.email_action_template
24
+ = render '/wco_email/email_action_templates/show_cell', tmpl: sch.tmpl
25
+ %td.to
26
+ = link_to sch.lead.email, wco.lead_path(sch.lead)
27
+ %td.tmpl
28
+ = render '/wco_email/email_templates/show_cell', tmpl: sch.tmpl.email_template
26
29
  %td= sch.perform_at.in_time_zone
27
30
 
28
31
 
@@ -1,4 +1,4 @@
1
1
 
2
- .scheduled-email-actions-new.maxwidth
2
+ .email-actions-new.maxwidth
3
3
 
4
- = render 'form', scheduled_email_action: @scheduled_email_action
4
+ = render 'form', email_action: @email_action
@@ -0,0 +1,6 @@
1
+ = link_to '[~]', edit_email_template_path(tmpl)
2
+ = link_to tmpl.slug, email_template_path(tmpl)
3
+ %br
4
+ <b>From:</b> #{tmpl.from_email}
5
+ %br
6
+ <b>Subject:</b> #{tmpl.subject}
data/config/routes.rb CHANGED
@@ -17,6 +17,7 @@ WcoEmail::Engine.routes.draw do
17
17
  post 'conversations/rmtag/:slug', to: 'conversations#rmtag'
18
18
  resources :conversations
19
19
 
20
+ post 'email_action_templates', to: 'email_action_templates#update'
20
21
  resources :email_action_templates
21
22
  resources :email_actions
22
23
  resources :email_campaigns
@@ -6,6 +6,7 @@ namespace :wco_email do
6
6
  ##
7
7
  desc 'churn_n_stubs n=<num> [tagname=<some-new-slug>] [process_images=<false|true>] [status=<status>]'
8
8
  task churn_n_stubs: :environment do
9
+ puts! ENV, 'ENV'
9
10
 
10
11
  ## Usage
11
12
  if !ENV['n']
@@ -27,7 +28,7 @@ namespace :wco_email do
27
28
  status ||= WcoEmail::MessageStub::STATUS_PENDING
28
29
 
29
30
  n = ENV['n'].to_i
30
- stubs = WcoEmail::MessageStub.where( status: status ).limit n
31
+ stubs = WcoEmail::MessageStub.where( status: status ).limit(n)
31
32
  stubs.each_with_index do |stub, idx|
32
33
  puts "+++ +++ churning ##{idx+1} object_key: #{stub.object_key}"
33
34
 
@@ -39,6 +40,37 @@ namespace :wco_email do
39
40
  end
40
41
  end
41
42
 
43
+ ##
44
+ ## 2024-01-10
45
+ ## WcoEmail::MessageStub.all.update_all({ bucket: 'ish-ses-2024' })
46
+ ## WcoEmail::MessageIntakeJob.perform_sync( stub.id.to_s )
47
+ ##
48
+ desc 'import objectkey list'
49
+ task import_objectkey_list: :environment do
50
+
51
+ # bucket = 'ish-ses'
52
+ bucket = 'ish-test-2024'
53
+ client ||= Aws::S3::Client.new({
54
+ region: ::S3_CREDENTIALS[:region_ses],
55
+ access_key_id: ::S3_CREDENTIALS[:access_key_id_ses],
56
+ secret_access_key: ::S3_CREDENTIALS[:secret_access_key_ses],
57
+ })
58
+
59
+ # lines = File.read( './data/20240110_ish-ses_objectkeys' )
60
+ lines = File.read( './data/out_head' )
61
+ lines.split("\n").each_with_index do |line, idx|
62
+
63
+ object_key = line.split.last
64
+ stub = WcoEmail::MessageStub.create( object_key: object_key, bucket: bucket )
65
+ if stub.persisted?
66
+ print "#{idx+1}."
67
+ else
68
+ puts! stub.errors.full_messages.join(", ")
69
+ end
70
+
71
+ end
72
+ end
73
+
42
74
  desc "Usage: wco_email:mbox_info mbox_path=<filepath> "
43
75
  task mbox_info: :environment do
44
76
 
@@ -89,34 +121,54 @@ namespace :wco_email do
89
121
  end
90
122
  end
91
123
 
92
- ##
93
- ## 2024-01-10
94
- ## WcoEmail::MessageStub.all.update_all({ bucket: 'ish-ses-2024' })
95
- ## WcoEmail::MessageIntakeJob.perform_sync( stub.id.to_s )
96
- ##
97
- desc 'import objectkey list'
98
- task import_objectkey_list: :environment do
124
+ desc 'email actions, send and roll'
125
+ task run_email_actions: :environment do
126
+ while true do
99
127
 
100
- # bucket = 'ish-ses'
101
- bucket = 'ish-test-2024'
102
- client ||= Aws::S3::Client.new({
103
- region: ::S3_CREDENTIALS[:region_ses],
104
- access_key_id: ::S3_CREDENTIALS[:access_key_id_ses],
105
- secret_access_key: ::S3_CREDENTIALS[:secret_access_key_ses],
106
- })
128
+ WcoEmail::EmailAction.active.where({ :perform_at.lte => Time.now }).each do |sch|
129
+ sch.send_and_roll
130
+ print '^'
131
+ end
107
132
 
108
- # lines = File.read( './data/20240110_ish-ses_objectkeys' )
109
- lines = File.read( './data/out_head' )
110
- lines.split("\n").each_with_index do |line, idx|
133
+ duration = Rails.env.production? ? 120 : 15 # 2 minutes or 15 seconds
134
+ sleep duration
135
+ print '.'
111
136
 
112
- object_key = line.split.last
113
- stub = WcoEmail::MessageStub.create( object_key: object_key, bucket: bucket )
114
- if stub.persisted?
115
- print "#{idx+1}."
137
+ end
138
+ end
139
+
140
+ desc 'send contexts'
141
+ task send_contexts: :environment do
142
+ while true do
143
+
144
+ ctxs = WcoEmail::Context.scheduled.notsent
145
+ ctxs.map do |ctx|
146
+
147
+ unsub = WcoEmail::Unsubscribe.where({ lead_id: ctx.lead_id, template_id: ctx.email_template_id }).first
148
+ if unsub
149
+ puts! 'This user is unsubscribed; the context cannot be sent.' if DEBUG
150
+ # Office::AdminMessage.create({ message: "Lead `#{ctx.lead.full_name}` [mailto:#{ctx.lead.email}] has already unsubscribed from template `#{Ish::EmailTemplate.find( ctx.email_template_id ).slug}` ." })
151
+ email_action_template_ids = WcoEmail::EmailActionTemplate.where({ email_template_id: ctx.email_template_id }).map(&:id)
152
+ schs = WcoEmail::EmailAction.active.where({
153
+ lead_id: ctx.lead_id,
154
+ :email_action_template_id.in => email_action_template_ids,
155
+ })
156
+ schs.update({ status: WcoEmail::EmailAction::STATUS_UNSUBSCRIBED })
157
+ ctx.update({
158
+ unsubscribed_at: Time.now.to_s,
159
+ })
116
160
  else
117
- puts! stub.errors.full_messages.join(", ")
161
+ out = WcoEmail::ApplicationMailer.send_context_email( ctx[:id].to_s )
162
+ Rails.env.production? ? out.deliver_later : out.deliver_now
118
163
  end
119
164
 
165
+ print '^'
166
+ end
167
+
168
+ duration = Rails.env.production? ? 120 : 15 # 2 minutes or 15 seconds
169
+ sleep duration
170
+ print '.'
171
+
120
172
  end
121
173
  end
122
174
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.12
4
+ version: 0.1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-12 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -377,6 +377,7 @@ files:
377
377
  - app/views/wco_email/conversations/show.haml
378
378
  - app/views/wco_email/email_action_templates/_form.haml
379
379
  - app/views/wco_email/email_action_templates/_header.haml
380
+ - app/views/wco_email/email_action_templates/_show_cell.haml
380
381
  - app/views/wco_email/email_action_templates/edit.haml
381
382
  - app/views/wco_email/email_action_templates/index.haml
382
383
  - app/views/wco_email/email_action_templates/new.haml
@@ -426,6 +427,7 @@ files:
426
427
  - app/views/wco_email/email_templates/_piousbox_social.html.erb
427
428
  - app/views/wco_email/email_templates/_plain.haml
428
429
  - app/views/wco_email/email_templates/_rec_resume_shared_with_you.html.erb
430
+ - app/views/wco_email/email_templates/_show_cell.haml
429
431
  - app/views/wco_email/email_templates/_slug-1.html.erb
430
432
  - app/views/wco_email/email_templates/_slug-2.html.erb
431
433
  - app/views/wco_email/email_templates/_slug-3.html.erb