Whatsapp send and Zammad autologin fixes
This commit is contained in:
parent
a3d6b786e1
commit
9e68be7225
15 changed files with 153 additions and 100 deletions
|
|
@ -1,8 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Channel
|
||||
class Driver
|
||||
class CdrWhatsapp
|
||||
class Channel::Driver::CdrWhatsapp
|
||||
def fetchable?(_channel)
|
||||
false
|
||||
end
|
||||
|
|
@ -24,7 +22,7 @@ class Channel
|
|||
#
|
||||
|
||||
def send(options, article, _notification = false)
|
||||
# return if we run import mode
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
|
||||
options = check_external_credential(options)
|
||||
|
|
@ -50,6 +48,4 @@ class Channel
|
|||
end
|
||||
options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,3 +29,4 @@ module Ticket::Article::EnqueueCommunicateCdrSignalJob
|
|||
CommunicateCdrSignalJob.perform_later(id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ module Ticket::Article::EnqueueCommunicateCdrWhatsappJob
|
|||
return true unless type_id
|
||||
|
||||
type = Ticket::Article::Type.lookup(id: type_id)
|
||||
return true unless type.name.match?(/\Acdr_whatspp/i)
|
||||
return true unless type.name.match?(/\Acdr_whatsapp/i)
|
||||
|
||||
CommunicateCdrWhatsappJob.perform_later(id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
# Ticket::Article.add_observer Observer::Ticket::Article::CommunicateCdrSignal.instance
|
||||
Rails.application.config.after_initialize do
|
||||
class Ticket::Article
|
||||
include Ticket::Article::EnqueueCommunicateCdrSignalJob
|
||||
end
|
||||
|
||||
icon = File.read('public/assets/images/icons/cdr_signal.svg')
|
||||
doc = File.open('public/assets/images/icons.svg') { |f| Nokogiri::XML(f) }
|
||||
|
|
@ -13,3 +15,4 @@ Rails.application.config.after_initialize do
|
|||
end
|
||||
File.write('public/assets/images/icons.svg', doc.to_xml)
|
||||
end
|
||||
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
# Ticket::Article.add_observer Observer::Ticket::Article::CommunicateCdrWhatsapp.instance
|
||||
|
||||
|
||||
class Ticket::Article
|
||||
include Ticket::Article::EnqueueCommunicateCdrWhatsappJob
|
||||
end
|
||||
|
||||
icon = File.read('public/assets/images/icons/cdr_whatsapp.svg')
|
||||
doc = File.open('public/assets/images/icons.svg') { |f| Nokogiri::XML(f) }
|
||||
if !doc.at_css('#icon-cdr-whatsapp')
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class CdrSignal
|
|||
#
|
||||
|
||||
def self.check_token(api_url, token)
|
||||
api = CdrSignalAPI.new(api_url, token)
|
||||
api = CdrSignalApi.new(api_url, token)
|
||||
begin
|
||||
bot = api.fetch_self
|
||||
rescue StandardError => e
|
||||
|
|
@ -128,7 +128,7 @@ class CdrSignal
|
|||
def initialize(api_url, token)
|
||||
@token = token
|
||||
@api_url = api_url
|
||||
@api = CdrSignalAPI.new(api_url, token)
|
||||
@api = CdrSignalApi.new(api_url, token)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@ require 'json'
|
|||
require 'net/http'
|
||||
require 'net/https'
|
||||
require 'uri'
|
||||
require 'rest-client'
|
||||
|
||||
class CdrSignalAPI
|
||||
class CdrSignalApi
|
||||
def initialize(api_url, token)
|
||||
@token = token
|
||||
@last_update = 0
|
||||
@api = api_url
|
||||
@api_url = api_url
|
||||
end
|
||||
|
||||
def parse_hash(hash)
|
||||
|
|
@ -22,13 +21,13 @@ class CdrSignalAPI
|
|||
end
|
||||
|
||||
def get(api)
|
||||
url = "#{@api}/bots/#{@token}/#{api}"
|
||||
JSON.parse(RestClient.get(url, { accept: :json }).body)
|
||||
url = "#{@api_url}/bots/#{@token}/#{api}"
|
||||
JSON.parse(Faraday.get(url, { Accept: "application/json" }).body)
|
||||
end
|
||||
|
||||
def post(api, params = {})
|
||||
url = "#{@api}/bots/#{@token}/#{api}"
|
||||
JSON.parse(RestClient.post(url, params, { accept: :json }).body)
|
||||
url = "#{@api_url}/bots/#{@token}/#{api}"
|
||||
JSON.parse(Faraday.post(url, params.to_json, { "Content-Type": "application/json", Accept: "application/json" }).body)
|
||||
end
|
||||
|
||||
def fetch_self
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class CdrWhatsapp
|
|||
#
|
||||
|
||||
def self.check_token(api_url, token)
|
||||
api = CdrWhatsappAPI.new(api_url, token)
|
||||
api = CdrWhatsappApi.new(api_url, token)
|
||||
begin
|
||||
bot = api.fetch_self
|
||||
rescue StandardError => e
|
||||
|
|
@ -128,7 +128,7 @@ class CdrWhatsapp
|
|||
def initialize(api_url, token)
|
||||
@token = token
|
||||
@api_url = api_url
|
||||
@api = CdrWhatsappAPI.new(api_url, token)
|
||||
@api = CdrWhatsappApi.new(api_url, token)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ require 'json'
|
|||
require 'net/http'
|
||||
require 'net/https'
|
||||
require 'uri'
|
||||
require 'rest-client'
|
||||
|
||||
class CdrWhatsappAPI
|
||||
class CdrWhatsappApi
|
||||
def initialize(api_url, token)
|
||||
@token = token
|
||||
@last_update = 0
|
||||
|
|
@ -20,15 +19,15 @@ class CdrWhatsappAPI
|
|||
end
|
||||
ret
|
||||
end
|
||||
|
||||
|
||||
def get(api)
|
||||
url = "#{@api_url}/bots/#{@token}/#{api}"
|
||||
JSON.parse(RestClient.get(url, { accept: :json }).body)
|
||||
JSON.parse(Faraday.get(url, { Accept: "application/json" }).body)
|
||||
end
|
||||
|
||||
def post(api, params = {})
|
||||
url = "#{@api_url}/bots/#{@token}/#{api}"
|
||||
JSON.parse(RestClient.post(url, params, { accept: :json }).body)
|
||||
JSON.parse(Faraday.post(url, params.to_json, { "Content-Type": "application/json", Accept: "application/json" }).body)
|
||||
end
|
||||
|
||||
def fetch_self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue