lib/bobot/configuration.rb in bobot-2.5.0 vs lib/bobot/configuration.rb in bobot-2.6.0

- old
+ new

@@ -1,8 +1,8 @@ module Bobot class Configuration - attr_accessor :app_id, :app_secret, :verify_token, :debug_log, :async, :pages + attr_accessor :app_id, :app_secret, :verify_token, :domains, :debug_log, :async, :pages def domains=(rhs) return unless rhs.present? if rhs.respond_to?(:to_str) @domains = rhs.split(",").map(&:strip) @@ -69,11 +69,11 @@ raise Bobot::InvalidParameter.new(:access_token) unless page_access_token.present? greeting_texts = [] if language.nil? # Default text greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: I18n.default_locale, default: nil) - greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present? + greeting_texts << { locale: ‘default’, text: greeting_text } if greeting_text.present? # Each languages I18n.available_locales.each do |locale| greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: locale, default: nil) next unless greeting_text.present? facebook_locales = I18n.t("bobot.#{slug}.config.facebook_locales", locale: locale, default: nil) @@ -81,19 +81,17 @@ greeting_texts << { locale: locale_long, text: greeting_text } end end else greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: language, default: nil) - greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present? + greeting_texts << { locale: ‘default’, text: greeting_text } if greeting_text.present? end if greeting_texts.present? Bobot::Profile.set( body: { greeting: greeting_texts }, query: { access_token: page_access_token }, ) - else - unset_greeting_text! end end def unset_greeting_text! raise Bobot::InvalidParameter.new(:access_token) unless page_access_token.present? @@ -106,24 +104,19 @@ ## == Set bot whitelist domains (only displayed on first time) == ## == Some features like Messenger Extensions and Checkbox Plugin require == ## == a page to specify a domain whitelist. == def set_whitelist_domains! raise Bobot::InvalidParameter.new(:access_token) unless page_access_token.present? - raise Bobot::InvalidParameter.new(:domains) unless domains.present? - if domains.present? - Bobot::Profile.set( - body: { whitelisted_domains: domains }, - query: { access_token: page_access_token }, - ) - else - unset_whitelist_domains! - end + raise Bobot::InvalidParameter.new(:domains) unless Bobot.config.domains.present? + Bobot::Profile.set( + body: { whitelisted_domains: Bobot.config.domains }, + query: { access_token: page_access_token }, + ) end def unset_whitelist_domains! raise Bobot::InvalidParameter.new(:access_token) unless page_access_token.present? - raise Bobot::InvalidParameter.new(:domains) unless domains.present? Bobot::Profile.unset( body: { fields: ["whitelisted_domains"] }, query: { access_token: page_access_token }, ) end @@ -157,11 +150,11 @@ # Default text if language.nil? persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: I18n.default_locale, default: nil) if persistent_menu.present? persistent_menus << { - locale: 'default', + locale: ‘default’, composer_input_disabled: persistent_menu[:composer_input_disabled], call_to_actions: persistent_menu[:call_to_actions], } end # Each languages @@ -179,23 +172,21 @@ end else persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: language, default: nil) if persistent_menu.present? persistent_menus << { - locale: 'default', + locale: ‘default’, composer_input_disabled: persistent_menu[:composer_input_disabled], call_to_actions: persistent_menu[:call_to_actions], } end end if persistent_menus.present? Bobot::Profile.set( body: { persistent_menu: persistent_menus }, query: { access_token: page_access_token }, ) - else - unset_persistent_menu! end end def unset_persistent_menu! raise Bobot::InvalidParameter.new(:access_token) unless page_access_token.present? @@ -204,6 +195,6 @@ query: { access_token: page_access_token }, ) end end end -end +end \ No newline at end of file