Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically install tipline in v2 when workspace is created. #1656

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/concerns/smooch_team_bot_installation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20230914152816_mark_tipline_bot_as_default.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a typo, it's for the v1 tests.

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'
Expand Down
Loading