-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a GraphQL mutation to send a custom message to a tipline user
* New Smooch Bot class method to send a custom message to a tipline user (uses template for WhatsApp) * Expose that method as a GraphQL mutation * Permission check * Functional tests * Rake task to add a new tipline setting field for the new WhatsApp template Reference: CV2-3677.
- Loading branch information
Showing
9 changed files
with
276 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module TiplineMessageMutations | ||
class Send < Mutations::BaseMutation | ||
argument :uid, GraphQL::Types::ID, required: true | ||
argument :message, GraphQL::Types::String, required: true | ||
argument :timestamp, GraphQL::Types::Int, required: true | ||
argument :language, GraphQL::Types::String, required: true | ||
|
||
field :success, GraphQL::Types::Boolean, null: true | ||
|
||
def resolve(uid: nil, message: nil, timestamp: nil, language: nil) | ||
ability = context[:ability] || Ability.new | ||
success = false | ||
if Team.current&.id && User.current&.id && ability.can?(:send, TiplineMessage.new(team: Team.current)) | ||
success = Bot::Smooch.send_custom_message_to_user(Team.current, uid, timestamp, message, language) | ||
end | ||
{ success: success } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/tasks/migrate/20230925210911_add_custom_message_template_name_to_smooch_bot.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace :check do | ||
namespace :migrate do | ||
task add_custom_message_template_name_to_smooch_bot: :environment do |_t, _args| | ||
tb = BotUser.smooch_user | ||
unless tb.nil? | ||
settings = tb.get_settings.clone || [] | ||
# Add new template setting for custom message | ||
settings << { | ||
name: 'smooch_template_name_for_custom_message', | ||
label: "Template name for template 'custom_message'", | ||
type: 'string', | ||
default: '' | ||
} | ||
tb.set_settings(settings) | ||
tb.save! | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters