Add Decidim Twilio SMS configuration setup
This commit is contained in:
parent
c9af05aeb0
commit
9be07a4626
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.23.5-210408",
|
||||
"version": "0.23.5-210416",
|
||||
"meta": {
|
||||
"title": "Decidim",
|
||||
"desc-cs": "Platforma pro účast občanů",
|
||||
@ -8,7 +8,7 @@
|
||||
},
|
||||
"containers": {
|
||||
"decidim": {
|
||||
"image": "decidim_0.23.5-210408",
|
||||
"image": "decidim_0.23.5-210416",
|
||||
"depends": [
|
||||
"decidim-postgres"
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
IMAGE decidim_0.23.5-210408
|
||||
IMAGE decidim_0.23.5-210416
|
||||
FROM decidim-nginx_1.18.0-210106
|
||||
|
||||
# https://github.com/Platoniq/decidim-install/blob/master/decidim-bionic.md
|
||||
|
@ -38,6 +38,7 @@ group :production do
|
||||
gem "passenger"
|
||||
gem "delayed_job_active_record"
|
||||
gem "daemons"
|
||||
gem "twilio-ruby"
|
||||
end
|
||||
|
||||
# Modules
|
||||
|
@ -4,4 +4,8 @@ SMTP_USERNAME: "admin@example.com"
|
||||
SMTP_PASSWORD: ""
|
||||
SMTP_ADDRESS: "decidim-smtp"
|
||||
SMTP_DOMAIN: "example.com"
|
||||
HERE_API_KEY: ""
|
||||
TWILIO_ACCOUNT_SID: ""
|
||||
TWILIO_AUTH_TOKEN: ""
|
||||
TWILIO_SENDER_NUMBER: ""
|
||||
RAILS_LOG_TO_STDOUT: "1"
|
||||
|
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "twilio-ruby"
|
||||
|
||||
Decidim.configure do |config|
|
||||
# The name of the application
|
||||
config.application_name = "Decidim"
|
||||
@ -33,10 +35,12 @@ Decidim.configure do |config|
|
||||
# config.force_ssl = true
|
||||
|
||||
# Geocoder configuration
|
||||
# config.geocoder = {
|
||||
# static_map_url: "https://image.maps.ls.hereapi.com/mia/1.6/mapview",
|
||||
# here_api_key: Rails.application.secrets.geocoder[:here_api_key]
|
||||
# }
|
||||
if !ENV["HERE_API_KEY"].to_s.empty?
|
||||
config.geocoder = {
|
||||
static_map_url: "https://image.maps.ls.hereapi.com/mia/1.6/mapview",
|
||||
here_api_key: ENV["HERE_API_KEY"]
|
||||
}
|
||||
end
|
||||
|
||||
# Custom resource reference generator method. Check the docs for more info.
|
||||
# config.reference_generator = lambda do |resource, component|
|
||||
@ -126,7 +130,32 @@ Decidim.configure do |config|
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# config.sms_gateway_service = "MySMSGatewayService"
|
||||
|
||||
class TwilioSMSGatewayService
|
||||
attr_reader :mobile_phone_number, :code
|
||||
|
||||
def initialize(mobile_phone_number, code)
|
||||
@mobile_phone_number = mobile_phone_number
|
||||
@code = code
|
||||
end
|
||||
|
||||
def deliver_code
|
||||
Rails.logger.debug("Twilio SMS gateway service, verification code is: #{code}, should have been delivered to #{mobile_phone_number}")
|
||||
client.messages.create(
|
||||
from: ENV["TWILIO_SENDER_NUMBER"],
|
||||
to: mobile_phone_number,
|
||||
body: code
|
||||
)
|
||||
end
|
||||
|
||||
def client
|
||||
::Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]
|
||||
end
|
||||
end
|
||||
|
||||
if !ENV["TWILIO_ACCOUNT_SID"].to_s.empty?
|
||||
config.sms_gateway_service = "TwilioSMSGatewayService"
|
||||
end
|
||||
|
||||
# Timestamp service configuration
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user