wco_email 0.1.1.12 → 0.1.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.txt +2 -127
- data/app/controllers/wco_email/email_action_templates_controller.rb +28 -24
- data/app/controllers/wco_email/email_actions_controller.rb +13 -3
- data/app/jobs/wco_email/message_intake_job.rb +1 -1
- data/app/views/wco_email/email_action_templates/_form.haml +11 -15
- data/app/views/wco_email/email_action_templates/_show_cell.haml +7 -0
- data/app/views/wco_email/email_action_templates/edit.haml +2 -2
- data/app/views/wco_email/email_action_templates/index.haml +28 -19
- data/app/views/wco_email/email_action_templates/new.haml +3 -5
- data/app/views/wco_email/email_action_templates/show.haml +4 -5
- data/app/views/wco_email/email_actions/_form.haml +12 -16
- data/app/views/wco_email/email_actions/edit.haml +1 -1
- data/app/views/wco_email/email_actions/index.haml +9 -6
- data/app/views/wco_email/email_actions/new.haml +2 -2
- data/app/views/wco_email/email_templates/_show_cell.haml +6 -0
- data/config/routes.rb +1 -0
- data/lib/tasks/wco_email_tasks.rake +75 -23
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38dd6949cfd54cf62dc22d578f5c92d1b15901828e817ca200a7bff21744a9e0
|
4
|
+
data.tar.gz: 1d34eebffc81223a0f39fecee5446b40d1218c658406400550499ab3e45cc21e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7687dd90c43ef617b71aa6dcfe42d41ba2454636f94c964d42f78ff749091295fcfd497380e09b6c78b4c7e06d290506b8b6bdeab4fa6e95eeb829ef4ba7e066
|
7
|
+
data.tar.gz: 26db851105b6b38d5d2c0cee3a8e750473f04d98085794490116f182e124e013f591f9f0f71d0f55ad78e704e91735226afc0803d0c820b1a7ee7e0b4851e15a
|
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
|
-
|
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
|
-
@
|
10
|
-
authorize! :delete, @
|
11
|
-
@
|
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
|
-
@
|
18
|
-
|
19
|
-
authorize! :edit, @
|
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
|
-
@
|
23
|
+
@tmpls = WcoEmail::EmailActionTemplate.all
|
24
24
|
|
25
|
-
authorize! :index, @
|
25
|
+
authorize! :index, @new_tmpl
|
26
26
|
end
|
27
27
|
|
28
28
|
def new
|
29
|
-
authorize! :new, @
|
29
|
+
authorize! :new, @new_tmpl
|
30
30
|
end
|
31
31
|
|
32
32
|
def show
|
33
|
-
@
|
34
|
-
authorize! :show, @
|
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
|
-
@
|
41
|
+
@tmpl = WcoEmail::EmailActionTemplate.find( params[:id] )
|
40
42
|
else
|
41
|
-
@
|
43
|
+
@tmpl = WcoEmail::EmailActionTemplate.new
|
42
44
|
end
|
43
|
-
authorize! :upsert, @
|
45
|
+
authorize! :upsert, @tmpl
|
44
46
|
|
45
|
-
if params[:
|
46
|
-
params[:
|
47
|
-
if !v[:
|
48
|
-
params[:
|
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
|
-
|
52
|
-
params[:
|
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 = @
|
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: #{@
|
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
|
-
@
|
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[:
|
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
|
-
@
|
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[:
|
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,13 +1,9 @@
|
|
1
1
|
|
2
|
-
-
|
3
|
-
- url = email_action.new_record? ? email_actions_path : email_action_path( email_action )
|
2
|
+
.email-action-templates--form
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
@@ -15,11 +11,11 @@
|
|
15
11
|
%label Slug
|
16
12
|
= f.text_field :slug
|
17
13
|
-# .field
|
18
|
-
-# %label
|
19
|
-
-# = f.
|
20
|
-
.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:
|
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
|
-
|
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 :
|
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
|
@@ -1,36 +1,45 @@
|
|
1
1
|
|
2
|
-
.email-
|
2
|
+
.email-action-templates-index.padded
|
3
3
|
|
4
4
|
.header
|
5
5
|
%h2.title
|
6
|
-
Email
|
7
|
-
= link_to '[+]',
|
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 '
|
12
|
-
%th
|
13
|
-
%th
|
11
|
+
%th= check_box_tag 'hmm'
|
12
|
+
%th
|
13
|
+
%th Slug
|
14
|
+
%th From
|
15
|
+
%th Tmpl
|
14
16
|
%th next actions
|
15
|
-
- @
|
17
|
+
- @tmpls.each_with_index do |tmpl, idx|
|
16
18
|
%tr
|
17
|
-
%td
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
-
|
38
|
+
- tmpl.ties.map do |tie|
|
30
39
|
%li
|
31
|
-
.a=
|
40
|
+
.a= tie.next_at_exe
|
32
41
|
.a
|
33
|
-
- if
|
42
|
+
- if tie.next_tmpl.slug == tmpl.slug
|
34
43
|
(same)
|
35
|
-
=
|
44
|
+
= tie.next_tmpl.slug
|
36
45
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
|
2
|
-
|
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',
|
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
|
4
|
+
%h5.title Email Action Template `#{@tmpl}`
|
5
5
|
|
6
6
|
%ul
|
7
|
-
- @
|
7
|
+
- @tmpl.ties.map do |tie|
|
8
8
|
%li
|
9
|
-
.a <b>Next
|
10
|
-
.a <b>Next at exe:</b> #{
|
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
|
-
-
|
3
|
-
|
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
|
5
|
+
%h5.title Schedule an Email Action
|
9
6
|
|
10
7
|
.flex-row
|
11
|
-
|
12
|
-
= f.select :
|
13
|
-
|
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 :
|
18
|
-
= f.select :
|
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:
|
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'
|
@@ -11,18 +11,21 @@
|
|
11
11
|
%tr
|
12
12
|
%td
|
13
13
|
%td Active?
|
14
|
-
%td
|
15
|
-
%td To
|
16
|
-
%td
|
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
|
24
|
-
|
25
|
-
%td
|
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
|
|
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
|
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
|
-
|
94
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
133
|
+
duration = Rails.env.production? ? 120 : 15 # 2 minutes or 15 seconds
|
134
|
+
sleep duration
|
135
|
+
print '.'
|
111
136
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.1.1.14
|
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-
|
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
|