diff --git a/app/models/concerns/smooch_team_bot_installation.rb b/app/models/concerns/smooch_team_bot_installation.rb index 643eb61ddb..f629f0473b 100644 --- a/app/models/concerns/smooch_team_bot_installation.rb +++ b/app/models/concerns/smooch_team_bot_installation.rb @@ -16,10 +16,14 @@ module ClassMethods end end - # Save Twitter/Facebook token and authorization URL after_create do if self.bot_user&.identifier == 'smooch' + # Save Twitter/Facebook token and authorization URL self.reset_smooch_authorization_token + + # Bump to v2 + self.set_smooch_version = 'v2' + self.save! end end diff --git a/db/migrate/20230914152816_mark_tipline_bot_as_default.rb b/db/migrate/20230914152816_mark_tipline_bot_as_default.rb new file mode 100644 index 0000000000..8a9faee0d2 --- /dev/null +++ b/db/migrate/20230914152816_mark_tipline_bot_as_default.rb @@ -0,0 +1,9 @@ +class MarkTiplineBotAsDefault < ActiveRecord::Migration[6.1] + def change + tb = BotUser.smooch_user + unless tb.nil? + tb.default = true + tb.save! + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5241df2737..40e1696ac6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_09_06_160303) do +ActiveRecord::Schema.define(version: 2023_09_14_152816) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/test/test_helper.rb b/test/test_helper.rb index cf8dfbf4c2..9a001988d7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -985,6 +985,7 @@ def setup_smooch_bot(menu = false, extra_settings = {}) }) end @installation = create_team_bot_installation user_id: @bot.id, settings: @settings.merge(extra_settings), team_id: @team.id + @installation.set_smooch_version = 'v1' ; @installation.save! create_team_bot_installation user_id: @bot.id, settings: {}, team_id: create_team.id Bot::Smooch.get_installation('smooch_webhook_secret', 'test') @media_url = 'https://smooch.com/image/test.jpeg'