mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
Revert "Feat: Fetch whatsapp templates till next cursor (#6835)"
This reverts commit 138afd9af6.
This commit is contained in:
@@ -24,12 +24,7 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
|
|||||||
|
|
||||||
def sync_templates
|
def sync_templates
|
||||||
response = HTTParty.get("#{business_account_path}/message_templates?access_token=#{whatsapp_channel.provider_config['api_key']}")
|
response = HTTParty.get("#{business_account_path}/message_templates?access_token=#{whatsapp_channel.provider_config['api_key']}")
|
||||||
|
whatsapp_channel.update(message_templates: response['data'], message_templates_last_updated: Time.now.utc) if response.success?
|
||||||
return unless response.success?
|
|
||||||
|
|
||||||
@templates = response['data']
|
|
||||||
fetch_next_templates(response)
|
|
||||||
save_templates
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_provider_config?
|
def validate_provider_config?
|
||||||
@@ -45,25 +40,8 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
|
|||||||
"#{api_base_path}/v13.0/#{media_id}"
|
"#{api_base_path}/v13.0/#{media_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_next_templates(response)
|
|
||||||
loop do
|
|
||||||
break unless response['paging'] && response['paging']['next']
|
|
||||||
|
|
||||||
response = HTTParty.get(response['paging']['next'])
|
|
||||||
push_templates(response)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def push_templates(response)
|
|
||||||
@templates << response['data'] if response.success? && response['data'].any?
|
|
||||||
end
|
|
||||||
|
|
||||||
def save_templates
|
|
||||||
whatsapp_channel.update(message_templates: @templates, message_templates_last_updated: Time.now.utc)
|
|
||||||
end
|
|
||||||
|
|
||||||
def api_base_path
|
def api_base_path
|
||||||
ENV.fetch('WHATSAPP_CLOUD_BASE_URL', 'https://graph.facebook.com')
|
ENV.fetch('WHATSAPP_CLOUD_BASE_URL', 'https://graph.facebook.com')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user