From 9984edd3ef357af8df8d61357910cdc02b2af477 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Thu, 16 Dec 2021 00:24:50 +0530 Subject: [PATCH] Feat: Manage conversation for tweets based on the tweet flag (#3353) Add tweet conversation only if tweets are enabled. Fixes #1961 --- .../api/v1/accounts/inboxes_controller.rb | 15 +----------- .../dashboard/i18n/locale/en/inboxMgmt.json | 5 +++- .../dashboard/settings/inbox/Settings.vue | 11 +++++++++ app/models/channel/twitter_profile.rb | 3 +++ app/models/inbox.rb | 4 ++++ app/services/twitter/tweet_parser_service.rb | 7 +++++- app/views/api/v1/models/_inbox.json.jbuilder | 2 ++ ...d_tweet_enabled_flag_to_twitter_channel.rb | 5 ++++ db/schema.rb | 1 + lib/webhooks/twitter.rb | 1 + .../v1/accounts/inboxes_controller_spec.rb | 13 +++++++++++ spec/lib/webhooks/twitter_spec.rb | 23 ++++++++++++++++++- 12 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20211109143122_add_tweet_enabled_flag_to_twitter_channel.rb diff --git a/app/controllers/api/v1/accounts/inboxes_controller.rb b/app/controllers/api/v1/accounts/inboxes_controller.rb index 0c80d9983..463a08bfb 100644 --- a/app/controllers/api/v1/accounts/inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/inboxes_controller.rb @@ -124,19 +124,6 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController end def get_channel_attributes(channel_type) - case channel_type - when 'Channel::WebWidget' - Channel::WebWidget::EDITABLE_ATTRS - when 'Channel::Api' - Channel::Api::EDITABLE_ATTRS - when 'Channel::Email' - Channel::Email::EDITABLE_ATTRS - when 'Channel::Telegram' - Channel::Telegram::EDITABLE_ATTRS - when 'Channel::Line' - Channel::Line::EDITABLE_ATTRS - else - [] - end + channel_type.constantize::EDITABLE_ATTRS.presence || [] end end diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index 774c8160d..b64362027 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -47,7 +47,10 @@ }, "TWITTER": { "HELP": "To add your Twitter profile as a channel, you need to authenticate your Twitter Profile by clicking on 'Sign in with Twitter' ", - "ERROR_MESSAGE": "There was an error connecting to Twitter, please try again" + "ERROR_MESSAGE": "There was an error connecting to Twitter, please try again", + "TWEETS": { + "ENABLE": "Create conversations from mentioned Tweets" + } }, "WEBSITE_CHANNEL": { "TITLE": "Website channel", diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue index 7c8db94d5..ac54dac85 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue @@ -32,6 +32,14 @@ :label="inboxNameLabel" :placeholder="inboxNamePlaceHolder" /> +