talktome 1.0.0 → 1.1.0

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: d6ec4ba471da7a770b79a04a0f30cd58514f0d43b72d66b15074f2fa984887bd
4
- data.tar.gz: 8a58f1a1e7af3440a8066e11b2fa44e4aa606c595c5b9d9e6952dd0b22d6fb97
3
+ metadata.gz: a01f2b1e8706384a106f6418060f2d17a87c4d76e415e5cdd3235714c40339de
4
+ data.tar.gz: 87032bc365971d322428d0245cc9d1eced6644d19f8253eacd6f061ec891e684
5
5
  SHA512:
6
- metadata.gz: 7340d04e04977b3d1a4a5def53d02b141a108e67514886f57d0d22dc87dfe340fe3a52d8f4552e7bd074229ba841256bb8006bfc900485b48cd8f0aa86522b39
7
- data.tar.gz: 961f6e4931782c5b0f0e732c9ab3a5ea0578efe76e0346bbd8782f3b21a3a8ecd58731b51e3d3dd2e32ccb0c2d9ef48f3081f1e2f810722fbb6320348deef796
6
+ metadata.gz: 6484f97e7455db0484cd296be7ea5184f333897cdb953fac3d9ffe98dbcbdb7299779db00683bdfaf0ee970d223bb9f58e140a26732dea5543d700c621cfddc6
7
+ data.tar.gz: be7f825012c0bdaa44b10939c3a29be70f9249a65b5156de065dbf6cfee7ae44e97aa5fb15ab9963e18947c889a332829b2497d696a0a9619689f48d44a027bf
data/README.md CHANGED
@@ -94,6 +94,9 @@ TALKTOME_EMAIL_DEFAULT_FROM default From: to use for email sending
94
94
  TALKTOME_EMAIL_DEFAULT_REPLYTO default Reply-To: to use for email sending
95
95
  TALKTOME_EMAIL_DEFAULT_TO default To: to use for email sending
96
96
 
97
+ TALKTOME_EMAIL_SUBJECT Set the subject of the default "contact us" email
98
+ TALKTOME_EMAIL_FOOTER Set the footer of the default "contact us" email
99
+
97
100
  TALKTOME_SMTP_ADDRESS host address for smtp sending
98
101
  TALKTOME_SMTP_PORT port of smtp server to use
99
102
  TALKTOME_SMTP_DOMAIN sending domain
data/lib/talktome/app.rb CHANGED
@@ -27,7 +27,11 @@ module Talktome
27
27
 
28
28
  post %r{/([a-z-]+)/} do |action|
29
29
  begin
30
- TALKTOME.talktome(action, {}, info, [:email]){|email|
30
+ as_array = info.map{|k,v| {'key' => k.capitalize, 'value' => v}}
31
+ subject = Talktome.env('TALKTOME_EMAIL_SUBJECT', 'Someone wants to reach you!')
32
+ footer = Talktome.env('TALKTOME_EMAIL_FOOTER', "Truly yours,\n
33
+ Sent by [Enspirit.be](https://enspirit.be/), contact us if you need help with any IT task.")
34
+ TALKTOME.talktome(action, {}, info.merge(allvars: as_array, subject: subject, footer: footer), [:email]){|email|
31
35
  email.reply_to = info[:reply_to] if info.has_key?(:reply_to)
32
36
  }
33
37
  [ 200, { "Content-Type" => "text/plain"}, ["Ok"] ]
@@ -1,7 +1,7 @@
1
1
  module Talktome
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
5
5
  TINY = 0
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
data/spec/app/test_app.rb CHANGED
@@ -19,13 +19,31 @@ module Talktome
19
19
  it 'works' do
20
20
  post "/contact-us/", {
21
21
  reply_to: 'hello@visitor.com',
22
- message: 'Hello from visitor'
22
+ message: 'Hello from visitor',
23
+ key: 'value',
23
24
  }.to_json, { "CONTENT_TYPE" => "application/json" }
24
25
  expect(last_response).to be_ok
25
26
  expect(Mail::TestMailer.deliveries.length).to eql(1)
26
27
  expect(Mail::TestMailer.deliveries.first.to).to eql(["to@talktome.com"])
27
28
  expect(Mail::TestMailer.deliveries.first.from).to eql(["from@talktome.com"])
28
29
  expect(Mail::TestMailer.deliveries.first.subject).to eql("Someone wants to reach you!")
30
+ expect(Mail::TestMailer.deliveries.first.html_part.body).to include("<li>Key: value</li>")
31
+ expect(Mail::TestMailer.deliveries.first.html_part.body).to include("Truly yours")
32
+ end
33
+
34
+ it 'allows to use environment variable to tune the subject and the footer' do
35
+ Talktome.set_env('TALKTOME_EMAIL_SUBJECT', "Subject from environment") do
36
+ Talktome.set_env('TALKTOME_EMAIL_FOOTER', "Footer from environment") do
37
+ post "/contact-us/", {
38
+ reply_to: 'info@domain.com',
39
+ message: 'This is the message.'
40
+ }.to_json, { "CONTENT_TYPE" => "application/json" }
41
+ expect(last_response).to be_ok
42
+ expect(Mail::TestMailer.deliveries.length).to eql(1)
43
+ expect(Mail::TestMailer.deliveries.first.subject).to eql("Subject from environment")
44
+ expect(Mail::TestMailer.deliveries.first.html_part.body).to include("Footer from environment")
45
+ end
46
+ end
29
47
  end
30
48
 
31
49
  it 'detects invalid emails' do
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talktome
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-04-30 00:00:00.000000000 Z
@@ -199,7 +199,7 @@ homepage: http://github.com/enspirit/talktome
199
199
  licenses:
200
200
  - MIT
201
201
  metadata: {}
202
- post_install_message:
202
+ post_install_message:
203
203
  rdoc_options: []
204
204
  require_paths:
205
205
  - lib
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.0.8
218
- signing_key:
217
+ rubygems_version: 3.1.2
218
+ signing_key:
219
219
  specification_version: 4
220
220
  summary: Talktome helps you talk to users by email, messaging, sms, etc.
221
221
  test_files: []