wco_email 0.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/README.txt +129 -0
  3. data/Rakefile +5 -0
  4. data/app/assets/config/wco_email_manifest.js +7 -0
  5. data/app/assets/javascript/vendor-trash/jquery-ui.min.js +13 -0
  6. data/app/assets/javascript/vendor-trash/jquery.fileupload.js +1482 -0
  7. data/app/assets/javascript/vendor-trash/jquery.iframe-transport.js +224 -0
  8. data/app/assets/javascript/vendor-trash/jquery.ui.widget.js +572 -0
  9. data/app/assets/javascript/vendor-trash/summernote-bs4.min.js +3 -0
  10. data/app/assets/javascript/wco_email/application.js +11 -0
  11. data/app/assets/javascript/wco_email/contexts.js +19 -0
  12. data/app/assets/javascript/wco_email/conversations.js +177 -0
  13. data/app/assets/javascript/wco_email/file_upload.js-trash +32 -0
  14. data/app/assets/javascript/wco_email/shared.js +22 -0
  15. data/app/assets/stylesheets/wco_email/application.scss +29 -0
  16. data/app/assets/stylesheets/wco_email/contexts.scss +63 -0
  17. data/app/assets/stylesheets/wco_email/conversations.scss +16 -0
  18. data/app/assets/stylesheets/wco_email/tags.scss +6 -0
  19. data/app/controllers/wco_email/application_controller.rb +16 -0
  20. data/app/controllers/wco_email/contexts_controller.rb +156 -0
  21. data/app/controllers/wco_email/conversations_controller.rb +129 -0
  22. data/app/controllers/wco_email/email_action_templates_controller.rb +77 -0
  23. data/app/controllers/wco_email/email_actions_controller.rb +55 -0
  24. data/app/controllers/wco_email/email_campaigns_controller.rb +73 -0
  25. data/app/controllers/wco_email/email_filters_controller.rb +72 -0
  26. data/app/controllers/wco_email/email_layouts_controller.rb +13 -0
  27. data/app/controllers/wco_email/email_templates_controller.rb +124 -0
  28. data/app/controllers/wco_email/message_stubs_controller.rb +14 -0
  29. data/app/controllers/wco_email/messages_controller.rb +28 -0
  30. data/app/controllers/wco_email/obfuscated_redirects_controller.rb +20 -0
  31. data/app/controllers/wco_email/sessions_controller.rb +19 -0
  32. data/app/controllers/wco_email/unsubscribes_controller.rb +40 -0
  33. data/app/helpers/wco_email/application_helper.rb +20 -0
  34. data/app/jobs/wco_email/message_intake_job.rb +54 -0
  35. data/app/mailers/wco_email/application_mailer.rb +98 -0
  36. data/app/views/202212 Mailchimp Templates/202212 1col fixed-width.html +863 -0
  37. data/app/views/202212 Mailchimp Templates/202212 1col full-width.html +906 -0
  38. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width 2.html +1003 -0
  39. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width.html +1082 -0
  40. data/app/views/202212 Mailchimp Templates/202212 2col full-width 2.html +1053 -0
  41. data/app/views/202212 Mailchimp Templates/202212 2col full-width.html +1147 -0
  42. data/app/views/202212 Mailchimp Templates/202212 3col fixed-width.html +1087 -0
  43. data/app/views/202212 Mailchimp Templates/202212 3col full-width.html +1136 -0
  44. data/app/views/202212 Mailchimp Templates/202212 catalog various-colors-1.html +1223 -0
  45. data/app/views/202212 Mailchimp Templates/202212 educate.html +1080 -0
  46. data/app/views/202212 Mailchimp Templates/202212 follow up.html +1001 -0
  47. data/app/views/202212 Mailchimp Templates/202212 make an announcement.html +1048 -0
  48. data/app/views/202212 Mailchimp Templates/202212 sell-a-product.html +977 -0
  49. data/app/views/202212 Mailchimp Templates/202212 tell a story.html +1168 -0
  50. data/app/views/202212 Mailchimp Templates/202212 theme art-newsletter.html +1612 -0
  51. data/app/views/202212 Mailchimp Templates/202212 theme caribou-xmas.html +856 -0
  52. data/app/views/202212 Mailchimp Templates/202212 theme colorbox.html +1027 -0
  53. data/app/views/202212 Mailchimp Templates/202212 theme competition-invitation.html +918 -0
  54. data/app/views/202212 Mailchimp Templates/202212 theme event-veerle.html +1132 -0
  55. data/app/views/202212 Mailchimp Templates/202212 theme fall-colors.html +1407 -0
  56. data/app/views/202212 Mailchimp Templates/202212 theme gift-giving.html +787 -0
  57. data/app/views/202212 Mailchimp Templates/202212 theme giftgiving-snowmen.html +731 -0
  58. data/app/views/202212 Mailchimp Templates/202212 theme heart-of-flowers.html +795 -0
  59. data/app/views/202212 Mailchimp Templates/202212 theme hero-card.html +915 -0
  60. data/app/views/202212 Mailchimp Templates/202212 theme hero-image.html +1148 -0
  61. data/app/views/202212 Mailchimp Templates/202212 theme monthly-contest.html +967 -0
  62. data/app/views/202212 Mailchimp Templates/202212 theme multiple-event.html +1189 -0
  63. data/app/views/202212 Mailchimp Templates/202212 theme postcard.html +914 -0
  64. data/app/views/202212 Mailchimp Templates/202212 theme snowy-fields.html +733 -0
  65. data/app/views/202212 Mailchimp Templates/202212 theme soft.html +849 -0
  66. data/app/views/202212 Mailchimp Templates/202212 theme sophisticated.html +1079 -0
  67. data/app/views/202212 Mailchimp Templates/202212 theme subtle.html +1218 -0
  68. data/app/views/202212 Mailchimp Templates/202212 theme ticket.html +1015 -0
  69. data/app/views/202212 Mailchimp Templates/202212 theme whale.html +888 -0
  70. data/app/views/202310 Email Templates/_acknowledgement_of_document_receipt.html.erb +23 -0
  71. data/app/views/202310 Email Templates/_support_ticket_created.html.erb +26 -0
  72. data/app/views/layouts/wco_email/application.haml +64 -0
  73. data/app/views/layouts/wco_email/mailbox.haml-trash +62 -0
  74. data/app/views/wco_email/_analytics.erb +16 -0
  75. data/app/views/wco_email/_main_header.haml +31 -0
  76. data/app/views/wco_email/_sidebar.haml +10 -0
  77. data/app/views/wco_email/application_mailer/_footer_unsubscribe.html.erb +24 -0
  78. data/app/views/wco_email/application_mailer/_header_logo.html.erb +12 -0
  79. data/app/views/wco_email/application_mailer/forwarder_notify.html.erb +17 -0
  80. data/app/views/wco_email/contexts/_form.haml +59 -0
  81. data/app/views/wco_email/contexts/_form_reply.haml +27 -0
  82. data/app/views/wco_email/contexts/_header.haml +22 -0
  83. data/app/views/wco_email/contexts/_index.haml +8 -0
  84. data/app/views/wco_email/contexts/edit.haml +8 -0
  85. data/app/views/wco_email/contexts/iframe_src.haml +3 -0
  86. data/app/views/wco_email/contexts/index.haml +51 -0
  87. data/app/views/wco_email/contexts/new.haml +5 -0
  88. data/app/views/wco_email/contexts/show.haml +34 -0
  89. data/app/views/wco_email/contexts/summary.csv.erb +4 -0
  90. data/app/views/wco_email/contexts/summary.haml +16 -0
  91. data/app/views/wco_email/conversations/_actions.haml +21 -0
  92. data/app/views/wco_email/conversations/_search.haml +14 -0
  93. data/app/views/wco_email/conversations/index.haml +43 -0
  94. data/app/views/wco_email/conversations/show.haml +27 -0
  95. data/app/views/wco_email/email_action_templates/_form.haml +45 -0
  96. data/app/views/wco_email/email_action_templates/_header.haml +8 -0
  97. data/app/views/wco_email/email_action_templates/edit.haml +7 -0
  98. data/app/views/wco_email/email_action_templates/index.haml +36 -0
  99. data/app/views/wco_email/email_action_templates/new.haml +9 -0
  100. data/app/views/wco_email/email_action_templates/show.haml +11 -0
  101. data/app/views/wco_email/email_actions/_form.haml +24 -0
  102. data/app/views/wco_email/email_actions/_form_mini.haml-trash +28 -0
  103. data/app/views/wco_email/email_actions/_header.haml +8 -0
  104. data/app/views/wco_email/email_actions/edit.haml +4 -0
  105. data/app/views/wco_email/email_actions/index.haml +31 -0
  106. data/app/views/wco_email/email_actions/new.haml +4 -0
  107. data/app/views/wco_email/email_actions/show.haml +0 -0
  108. data/app/views/wco_email/email_campaigns/_form.haml +33 -0
  109. data/app/views/wco_email/email_campaigns/_header.haml +5 -0
  110. data/app/views/wco_email/email_campaigns/edit.haml +5 -0
  111. data/app/views/wco_email/email_campaigns/index.haml +14 -0
  112. data/app/views/wco_email/email_campaigns/new.haml +5 -0
  113. data/app/views/wco_email/email_campaigns/show.haml +17 -0
  114. data/app/views/wco_email/email_filters/_form.haml +40 -0
  115. data/app/views/wco_email/email_filters/_header.haml +5 -0
  116. data/app/views/wco_email/email_filters/edit.haml +5 -0
  117. data/app/views/wco_email/email_filters/index.haml +48 -0
  118. data/app/views/wco_email/email_filters/new.haml +5 -0
  119. data/app/views/wco_email/email_templates/_form.haml +48 -0
  120. data/app/views/wco_email/email_templates/_form_mini.haml +9 -0
  121. data/app/views/wco_email/email_templates/_form_reply_mini.haml +8 -0
  122. data/app/views/wco_email/email_templates/_form_schedule_mini.haml +11 -0
  123. data/app/views/wco_email/email_templates/_header.haml +6 -0
  124. data/app/views/wco_email/email_templates/_index.haml +26 -0
  125. data/app/views/wco_email/email_templates/_index_expanded.haml +13 -0
  126. data/app/views/wco_email/email_templates/_m20221201react.html.erb +1202 -0
  127. data/app/views/wco_email/email_templates/_m20221222merryxmas.html.erb +766 -0
  128. data/app/views/wco_email/email_templates/_m202309_feedback.html.erb +1161 -0
  129. data/app/views/wco_email/email_templates/_m202309_ror4.html.erb +1068 -0
  130. data/app/views/wco_email/email_templates/_marketing_node_1.html.erb +984 -0
  131. data/app/views/wco_email/email_templates/_marketing_react_1.html +0 -0
  132. data/app/views/wco_email/email_templates/_marketing_react_2.html.erb +749 -0
  133. data/app/views/wco_email/email_templates/_marketing_react_3.html.erb +628 -0
  134. data/app/views/wco_email/email_templates/_marketing_ror_1.html +751 -0
  135. data/app/views/wco_email/email_templates/_marketing_ror_2.html.erb +755 -0
  136. data/app/views/wco_email/email_templates/_marketing_ror_3.html.erb +25 -0
  137. data/app/views/wco_email/email_templates/_marketing_ror_4.html.erb +25 -0
  138. data/app/views/wco_email/email_templates/_marketing_ror_5.html.erb +17 -0
  139. data/app/views/wco_email/email_templates/_marketing_wordpress_1.html +0 -0
  140. data/app/views/wco_email/email_templates/_marketing_wordpress_2.html +0 -0
  141. data/app/views/wco_email/email_templates/_meta.haml +6 -0
  142. data/app/views/wco_email/email_templates/_piousbox_roundborders.html.erb +1007 -0
  143. data/app/views/wco_email/email_templates/_piousbox_social.html.erb +181 -0
  144. data/app/views/wco_email/email_templates/_plain.haml +15 -0
  145. data/app/views/wco_email/email_templates/_rec_resume_shared_with_you.html.erb +39 -0
  146. data/app/views/wco_email/email_templates/_slug-1.html.erb +0 -0
  147. data/app/views/wco_email/email_templates/_slug-2.html.erb +0 -0
  148. data/app/views/wco_email/email_templates/_slug-3.html.erb +0 -0
  149. data/app/views/wco_email/email_templates/_tracking_footer.html.erb +13 -0
  150. data/app/views/wco_email/email_templates/_wasyaco_roundborders.html.erb +686 -0
  151. data/app/views/wco_email/email_templates/_wasyaco_social.html.erb +181 -0
  152. data/app/views/wco_email/email_templates/edit.haml +6 -0
  153. data/app/views/wco_email/email_templates/new.haml +6 -0
  154. data/app/views/wco_email/email_templates/show.haml +11 -0
  155. data/app/views/wco_email/email_templates/show_iframe.haml +2 -0
  156. data/app/views/wco_email/lead_action_templates/_header.haml +7 -0
  157. data/app/views/wco_email/lead_actions/_header.haml +8 -0
  158. data/app/views/wco_email/message_stubs/_index.haml +10 -0
  159. data/app/views/wco_email/messages/_form_reply.haml-trash +17 -0
  160. data/app/views/wco_email/messages/_meta.haml +30 -0
  161. data/app/views/wco_email/messages/show.haml +13 -0
  162. data/app/views/wco_email/messages/show_iframe.haml +5 -0
  163. data/app/views/wco_email/sessions/new.html.erb +4 -0
  164. data/app/views/wco_email/unsubscribes/_header.haml +4 -0
  165. data/app/views/wco_email/unsubscribes/_table.haml +22 -0
  166. data/config/initializers/assets.rb +10 -0
  167. data/config/routes.rb +49 -0
  168. data/lib/tasks/bjjcollective/sitemap.rb +50 -0
  169. data/lib/tasks/db_tasks.rake +12 -0
  170. data/lib/tasks/direct_mail_tasks.rake +35 -0
  171. data/lib/tasks/infinite_shelter/sitemap.rb +25 -0
  172. data/lib/tasks/piousbox/sitemap.rb +80 -0
  173. data/lib/tasks/publish2_wordpress_tasks.rake +54 -0
  174. data/lib/tasks/scrape_reddit_tasks.rake-bk +23 -0
  175. data/lib/tasks/trash/email_tasks.rake-trash +126 -0
  176. data/lib/tasks/trash/sitemap_tasks.rake-trash +146 -0
  177. data/lib/tasks/wasya_co/sitemap.rb +281 -0
  178. data/lib/tasks/wco_email_tasks.rake +117 -0
  179. data/lib/wco_email/README_email_actions.rb +7 -0
  180. data/lib/wco_email/README_email_contexts.rb +7 -0
  181. data/lib/wco_email/engine.rb +8 -0
  182. data/lib/wco_email.rb +19 -0
  183. metadata +493 -0
@@ -0,0 +1,77 @@
1
+
2
+ class WcoEmail::EmailActionTemplatesController < WcoEmail::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ ## Alphabetized : )
7
+
8
+ def destroy
9
+ @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
10
+ authorize! :delete, @act
11
+ @act.update_attributes({ deleted_at: Time.now })
12
+ flash_notice 'Probably success'
13
+ redirect_to action: :index
14
+ end
15
+
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
20
+ end
21
+
22
+ def index
23
+ @email_actions = WcoEmail::EmailAction.where({ :deleted_at => nil })
24
+
25
+ authorize! :index, @new_email_action
26
+ end
27
+
28
+ def new
29
+ authorize! :new, @new_email_action
30
+ end
31
+
32
+ def show
33
+ @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
34
+ authorize! :show, @act
35
+ end
36
+
37
+ def update
38
+ if params[:id]
39
+ @act = @email_action = WcoEmail::EmailAction.find( params[:id] )
40
+ else
41
+ @act = @email_action = WcoEmail::EmailAction.new
42
+ end
43
+ authorize! :upsert, @act
44
+
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 )
49
+ end
50
+ if v[:to_delete] == "1"
51
+ EActie.find( v[:id] ).delete
52
+ params[:email_action][:ties_attributes].delete( k )
53
+ end
54
+ end
55
+ end
56
+
57
+ flag = @act.update_attributes( params[:email_action].permit! )
58
+ if flag
59
+ flash[:notice] = 'Success'
60
+ redirect_to action: 'index'
61
+ else
62
+ flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}. #{@act.ties.map { |t| t.errors.full_messages.join(', ') }.join(' | ') }"
63
+ render action: 'edit'
64
+ end
65
+
66
+ end
67
+
68
+ ##
69
+ ## private
70
+ ##
71
+ private
72
+
73
+ def set_lists
74
+ @new_email_action = WcoEmail::EmailAction.new
75
+ end
76
+
77
+ end
@@ -0,0 +1,55 @@
1
+
2
+ Sch = WcoEmail::EmailAction
3
+
4
+ class WcoEmail::EmailActionsController < WcoEmail::ApplicationController
5
+
6
+ before_action :set_lists
7
+
8
+ def create
9
+ @sch = Sch.new( params[:sch].permit! )
10
+ authorize! :create, @sch
11
+
12
+ flag = @sch.save
13
+ if flag
14
+ flash[:notice] = 'Success'
15
+ else
16
+ flash[:alert] = "No luck: #{@sch.errors.full_messages.join(', ')}"
17
+ end
18
+ redirect_to request.referrer ? request.referrer : leadsets_path
19
+ end
20
+
21
+ def edit
22
+ @sch = Sch.find params[:id]
23
+ authorize! :edit, @sch
24
+ end
25
+
26
+ def index
27
+ @schs = Sch.all
28
+ authorize! :index, @schs
29
+ end
30
+
31
+ def new
32
+ @sch = Sch.new
33
+ authorize! :new, @sch
34
+ end
35
+
36
+ def show
37
+ @sch = Sch.find params[:id]
38
+ authorize! :show, @sch
39
+ redirect_to action: 'edit'
40
+ end
41
+
42
+ def update
43
+ @sch = Sch.find params[:id]
44
+ authorize! :update, @sch
45
+ flag = @sch.update_attributes( params[:sch].permit! )
46
+ if flag
47
+ flash[:notice] = "Success."
48
+ else
49
+ flash[:alert] = "No luck: #{@sch.errors.full_messages.join(',')}."
50
+ end
51
+ render action: 'edit'
52
+ end
53
+
54
+ end
55
+
@@ -0,0 +1,73 @@
1
+
2
+ EmailCampaign = WcoEmail::Campaign
3
+
4
+ ##
5
+ ## Campaigns send individual contexts to leads.
6
+ ##
7
+ class WcoEmail::EmailCampaignsController < WcoEmail::ApplicationController
8
+
9
+ before_action :set_lists
10
+
11
+ def create
12
+ @campaign = EmailCampaign.new params[:campaign].permit!
13
+ authorize! :create, @campaign
14
+ if @campaign.save
15
+ flash[:notice] = "created campaign"
16
+ else
17
+ flash[:alert] = "Cannot create campaign: #{@campaign.errors.messages}"
18
+ end
19
+ redirect_to :action => 'index'
20
+ end
21
+
22
+ def do_send
23
+ @campaign = EmailCampaign.find params[:id]
24
+ authorize! :send, @campaign
25
+ @campaign.do_send
26
+ end
27
+
28
+ def edit
29
+ @campaign = EmailCampaign.find params[:id]
30
+ authorize! :edit, @campaign
31
+ end
32
+
33
+ def index
34
+ authorize! :index, EmailCampaign
35
+ @campaigns = EmailCampaign.all
36
+ end
37
+
38
+ def new
39
+ @campaign = EmailCampaign.new
40
+ authorize! :new, @campaign
41
+ end
42
+
43
+ def show
44
+ @campaign = EmailCampaign.find params[:id]
45
+ authorize! :show, @campaign
46
+ @leads = @campaign.leads
47
+ if params[:q].present?
48
+ @leads = @leads.where(" email LIKE ? ", "%#{params[:q]}%" )
49
+ end
50
+ @leads = @leads.page( params[:leads_page ] ).per( current_profile.per_page )
51
+ end
52
+
53
+ def update
54
+ @campaign = EmailCampaign.find params[:id]
55
+ authorize! :update, @campaign
56
+ if @campaign.update_attributes params[:campaign].permit!
57
+ flash[:notice] = 'Successfully updated campaign.'
58
+ else
59
+ flash[:alert] = "Cannot update campaign: #{@campaign.errors.messages}"
60
+ end
61
+ redirect_to :action => 'index'
62
+ end
63
+
64
+ ##
65
+ ## private
66
+ ##
67
+ private
68
+
69
+ def set_lists
70
+ @email_templates_list = WcoEmail::EmailTemplate.list
71
+ end
72
+
73
+ end
@@ -0,0 +1,72 @@
1
+
2
+ class WcoEmail::EmailFiltersController < WcoEmail::ApplicationController
3
+
4
+ before_action :set_lists
5
+
6
+ def create
7
+ authorize! :create, WcoEmail::EmailFilter
8
+ @email_filter = WcoEmail::EmailFilter.create params[:email_filter].permit!
9
+ if @email_filter.persisted?
10
+ flash[:notice] = 'Success'
11
+ else
12
+ flash[:alert] = "No luck: #{@email_filter.errors.full_messages.join(', ')}."
13
+ end
14
+ redirect_to action: 'index'
15
+ end
16
+
17
+ def destroy
18
+ @email_filter = WcoEmail::EmailFilter.find params[:id]
19
+ authorize! :destroy, @email_filter
20
+ flag = @email_filter.destroy
21
+ if flag
22
+ flash[:notice] = 'Success'
23
+ else
24
+ flash[:alert] = 'Error'
25
+ end
26
+ redirect_to action: 'index'
27
+ end
28
+
29
+ def edit
30
+ @email_filter = WcoEmail::EmailFilter.find params[:id]
31
+ authorize! :edit, @email_filter
32
+ end
33
+
34
+ def index
35
+ authorize! :index, WcoEmail::EmailFilter.new
36
+ @email_filter = WcoEmail::EmailFilter.new
37
+ @email_filters = WcoEmail::EmailFilter.active
38
+ end
39
+
40
+ def new
41
+ @email_filter = WcoEmail::EmailFilter.new
42
+ authorize! :new, @email_filter
43
+ end
44
+
45
+ def update
46
+ @email_filter = WcoEmail::EmailFilter.find params[:id]
47
+ authorize! :update, @email_filter
48
+ flag = @email_filter.update_attributes( params[:email_filter].permit! )
49
+ if flag
50
+ flash[:notice] = 'Success'
51
+ else
52
+ flash[:alert] = "No luck: #{@email_filter.errors.full_messages.join(', ')}."
53
+ end
54
+ redirect_to action: 'index'
55
+ end
56
+
57
+ ##
58
+ ## private
59
+ ##
60
+ private
61
+
62
+ def set_lists
63
+ super
64
+ @email_templates_list = WcoEmail::EmailTemplate.list
65
+ @email_actions_list = WcoEmail::EmailAction.list
66
+ @email_action_templates_list = WcoEmail::EmailActionTemplate.list
67
+ end
68
+
69
+
70
+
71
+ end
72
+
@@ -0,0 +1,13 @@
1
+
2
+
3
+ class WcoEmail::EmailLayoutsController < WcoEmail::ApplicationController
4
+
5
+ def index
6
+ end
7
+
8
+ def show
9
+ end
10
+
11
+ end
12
+
13
+
@@ -0,0 +1,124 @@
1
+
2
+
3
+ class WcoEmail::EmailTemplatesController < WcoEmail::ApplicationController
4
+
5
+ # before_action :set_lists, only: %i| new |
6
+
7
+ def create
8
+ authorize! :create, WcoEmail::EmailTemplate
9
+ @template = WcoEmail::EmailTemplate.create params[:template].permit!
10
+ if @template.persisted?
11
+ flash[:notice] = 'Success.'
12
+ else
13
+ flash[:alert] = "Could not create an email template: #{@template.errors.full_messages.join(', ')}."
14
+ end
15
+ redirect_to action: :index
16
+ end
17
+
18
+ def destroy
19
+ authorize! :destroy, WcoEmail::EmailTemplate
20
+ @template = WcoEmail::EmailTemplate.where({ id: params[:id] }).first || WcoEmail::EmailTemplate.find_by({ slug: params[:id] })
21
+ if @template.destroy
22
+ flash[:notice] = 'Success.'
23
+ else
24
+ flash[:alert] = 'Cannot destroy this template.'
25
+ end
26
+ redirect_to action: :index
27
+ end
28
+
29
+ def edit
30
+ @tmpl = @email_template = WcoEmail::EmailTemplate.where({ id: params[:id] }).first
31
+ authorize! :edit, @tmpl
32
+ end
33
+
34
+ def iframe_src
35
+ @tmpl = @email_template = WcoEmail::EmailTemplate.where({ id: params[:id] }).first ||
36
+ WcoEmail::EmailTemplate.find_by({ slug: params[:id] })
37
+ authorize! :iframe_src, @email_template
38
+
39
+ @lead = Lead.find_by({ email: 'poxlovi@gmail.com' })
40
+ @ctx = Ctx.new({ email_template: @tmpl, lead_id: @lead.id })
41
+ @tmpl_config = OpenStruct.new JSON.parse( @ctx.tmpl[:config_json] )
42
+
43
+ @utm_tracking_str = {
44
+ 'cid' => @ctx.lead_id,
45
+ 'utm_campaign' => @ctx.tmpl.slug,
46
+ 'utm_medium' => 'email',
47
+ 'utm_source' => @ctx.tmpl.slug,
48
+ }.map { |k, v| "#{k}=#{v}" }.join("&")
49
+
50
+ @unsubscribe_url = WcoEmail::Engine.routes.url_helpers.unsubscribes_url({
51
+ template_id: @ctx.tmpl.id,
52
+ lead_id: @lead.id,
53
+ token: @lead.unsubscribe_token,
54
+ })
55
+
56
+ render layout: false
57
+ end
58
+
59
+ def index
60
+ authorize! :index, WcoEmail::EmailTemplate
61
+ @templates = WcoEmail::EmailTemplate.all.order_by( slug: :asc
62
+ ).page( params[:templates_page]
63
+ ).per( current_profile.per_page
64
+ )
65
+ render params[:template] || '_index'
66
+ end
67
+
68
+ def new
69
+ @new_email_template = WcoEmail::EmailTemplate.new
70
+ authorize! :new, WcoEmail::EmailTemplate
71
+ end
72
+
73
+ def show
74
+ @tmpl = WcoEmail::EmailTemplate.where({ id: params[:id] }).first
75
+ @tmpl ||= WcoEmail::EmailTemplate.find_by({ slug: params[:id] })
76
+ authorize! :show, @tmpl
77
+
78
+ @ctx = @email_context = WcoEmail::Context.new
79
+ end
80
+
81
+ def show_iframe
82
+ @tmpl = WcoEmail::EmailTemplate.where({ id: params[:id] }).first
83
+ @tmpl ||= WcoEmail::EmailTemplate.find_by({ slug: params[:id] })
84
+ authorize! :show, @tmpl
85
+
86
+ @lead = Wco::Lead.find_by({ email: 'poxlovi@gmail.com' })
87
+ @ctx = WcoEmail::Context.new({ email_template: @tmpl, lead: @lead, body: "Lorem Ipsum..." })
88
+ @tmpl_config = OpenStruct.new JSON.parse( @ctx.tmpl[:config_json] )
89
+
90
+ @utm_tracking_str = {
91
+ 'cid' => @ctx.lead_id,
92
+ 'utm_campaign' => @ctx.tmpl.slug,
93
+ 'utm_medium' => 'email',
94
+ 'utm_source' => @ctx.tmpl.slug,
95
+ }.map { |k, v| "#{k}=#{v}" }.join("&")
96
+
97
+ @unsubscribe_url = WcoEmail::Engine.routes.url_helpers.unsubscribes_url({
98
+ template_id: @ctx.tmpl.id,
99
+ lead_id: @lead.id,
100
+ token: @lead.unsubscribe_token,
101
+ host: Rails.application.routes.default_url_options[:host],
102
+ })
103
+
104
+ render layout: false
105
+ end
106
+
107
+ def update
108
+ @template = WcoEmail::EmailTemplate.where({ id: params[:id] }).first
109
+ authorize! :update, @template
110
+ flag = @template.update_attributes( params[:template].permit! )
111
+ if flag
112
+ flash[:notice] = 'Success.'
113
+ else
114
+ flash[:alert] = "No luck. #{@template.errors.full_messages.join(', ')}"
115
+ end
116
+ redirect_to action: :edit
117
+ end
118
+
119
+ ##
120
+ ## private
121
+ ##
122
+ private
123
+
124
+ end
@@ -0,0 +1,14 @@
1
+
2
+ class WcoEmail::MessageStubsController < WcoEmail::ApplicationController
3
+
4
+ def churn
5
+ @stub = WcoEmail::MessageStub.find params[:id]
6
+ authorize! :churn, @stub
7
+ WcoEmail::MessageIntakeJob.perform_async( @stub.id.to_s )
8
+ flash_notice "Schedueld to churn 1 stub."
9
+ redirect_to request.referrer
10
+ end
11
+
12
+
13
+ end
14
+
@@ -0,0 +1,28 @@
1
+
2
+ class WcoEmail::MessagesController < WcoEmail::ApplicationController
3
+
4
+ before_action :set_lists, except: %i| show_iframe |
5
+
6
+ def show
7
+ @message = WcoEmail::Message.find params[:id]
8
+ authorize! :show, @message
9
+ end
10
+
11
+ def show_iframe
12
+ @message = WcoEmail::Message.find params[:id]
13
+ authorize! :show, @message
14
+ render layout: false
15
+ end
16
+
17
+ ##
18
+ ## private
19
+ ##
20
+ private
21
+
22
+ def set_lists
23
+ @email_templates_list = WcoEmail::EmailTemplate.list
24
+ @leads_list = Wco::Lead.list
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,20 @@
1
+
2
+
3
+ class WcoEmail::ObfuscatedRedirectsController < WcoEmail::ApplicationController
4
+
5
+ def show
6
+ @obf = Office::ObfuscatedRedirect.find params[:id]
7
+ # puts! @obf, '@obf'
8
+ authorize! :show, @obf
9
+ visit_time = Time.now
10
+ @obf.update_attributes({
11
+ visited_at: visit_time,
12
+ visits: @obf.visits + [ visit_time ],
13
+ })
14
+ # render and return if DEBUG
15
+ redirect_to @obf.to
16
+ end
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,19 @@
1
+
2
+ class WcoEmail::SessionsController < Wco::ApplicationController
3
+
4
+ skip_before_action :verify_authenticity_token, only: :create
5
+
6
+ def new
7
+ render :new
8
+ end
9
+
10
+ def create
11
+ puts! params, '#create'
12
+
13
+ user_info = request.env['omniauth.auth']
14
+ puts! user_info, 'user_info'
15
+
16
+ render json: { status: :ok }
17
+ end
18
+
19
+ end
@@ -0,0 +1,40 @@
1
+
2
+
3
+ class WcoEmail::UnsubscribesController < WcoEmail::ApplicationController
4
+
5
+ def create
6
+ authorize! :open_permission, Wco
7
+ @lead = Wco::Lead.find params[:lead_id]
8
+
9
+ if( !params[:token] ||
10
+ @lead.unsubscribe_token != params[:token] )
11
+ render code: 400, message: "We're sorry, but something went wrong. Please try again later."
12
+ return
13
+ end
14
+
15
+ @unsubscribe = WcoEmail::Unsubscribe.find_or_create_by({
16
+ lead_id: params[:lead_id],
17
+ template_id: params[:template_id],
18
+ campaign_id: params[:campaign_id],
19
+ })
20
+ flag = @unsubscribe.update_attributes({
21
+ unsubscribed_at: Time.now,
22
+ })
23
+ if flag
24
+ flash_notice "You have been unsubscribed."
25
+ else
26
+ flash_alert "We're sorry, but something went wrong. Please try again later."
27
+ end
28
+
29
+ render layout: false
30
+ end
31
+
32
+ def index
33
+ authorize! :index, WcoEmail::Unsubscribe
34
+ @unsubscribes = WcoEmail::Unsubscribe.all
35
+
36
+ render '_table'
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,20 @@
1
+
2
+ module WcoEmail::ApplicationHelper
3
+
4
+ def pretty_date date
5
+ # date.to_s[0, 10]
6
+ date&.strftime('%Y-%m-%d')
7
+ end
8
+ def pp_date a; pretty_date a; end
9
+
10
+ def pp_datetime date
11
+ date&.strftime('%Y-%m-%d %l:%M%P %z')
12
+ end
13
+
14
+ def pp_time date
15
+ return nil if !date
16
+ # return date.strftime('%l:%M%P %z')
17
+ return date.in_time_zone( Rails.application.config.time_zone ).strftime('%l:%M%P')
18
+ end
19
+
20
+ end
@@ -0,0 +1,54 @@
1
+
2
+ require 'aws-sdk-s3'
3
+ require 'mail'
4
+ require 'sidekiq'
5
+
6
+ ##
7
+ ## 2023-02-26 _vp_ Let's go
8
+ ## 2023-03-07 _vp_ Continue
9
+ ## 2023-12-28 _vp_ Continue
10
+ ##
11
+ ## class_name EIJ
12
+ ##
13
+ class WcoEmail::MessageIntakeJob
14
+ include Sidekiq::Job
15
+ # include Sidekiq::Util
16
+
17
+ sidekiq_options queue: 'wco_email_rb'
18
+
19
+ =begin
20
+
21
+ ## Mongo::Error::MaxBSONSize: The document exceeds maximum allowed BSON object size after serialization (on 10.138.2.145)
22
+ object_key = 'k9n9qo03fii2in3ocj977nac0vj5djn07e110bg1'
23
+
24
+ object_key = 'hlbg24s1ov5k7irgmqsrjp0kl95vpik8t1esvs81'
25
+ MsgStub.where({ object_key: object_key }).delete
26
+
27
+ stub = MsgStub.create!({ object_key: object_key })
28
+ id = stub.id
29
+
30
+ Ishapi::EmailMessageIntakeJob.perform_now( stub.id.to_s )
31
+
32
+ =end
33
+ def perform id
34
+ stub = WcoEmail::MessageStub.find id
35
+ puts "+++ +++ Performing WcoEmail::MessageIntakeJob for object_key `#{stub.object_key}`."
36
+
37
+ if stub.status != WcoEmail::MessageStub::STATUS_PENDING
38
+ raise "This stub has already been processed: #{stub.id.to_s}."
39
+ return
40
+ end
41
+
42
+ begin
43
+ stub.do_process
44
+ rescue => err
45
+ puts! err, "WcoEmail::MessageIntakeJob error"
46
+ ExceptionNotifier.notify_exception(
47
+ err,
48
+ data: { stub: stub }
49
+ )
50
+ end
51
+
52
+ end
53
+ end
54
+ EIJ = WcoEmail::MessageIntakeJob