-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Routine Bugfixes and enhancements (#979)
- Fix slack scopes - Docs for authentication Fixes: #704 , #973
- Loading branch information
1 parent
0aab717
commit 4f83d54
Showing
32 changed files
with
254 additions
and
147 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
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
2 changes: 1 addition & 1 deletion
2
app/javascript/dashboard/routes/dashboard/settings/labels/validations.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
####################################### | ||
# To create an external channel reply service | ||
# - Inherit this as the base class. | ||
# - Implement `channel_class` method in your child class. | ||
# - Implement `perform_reply` method in your child class. | ||
# - Implement additional custom logic for your `perform_reply` method. | ||
# - When required override the validation_methods. | ||
# - Use Childclass.new.perform. | ||
###################################### | ||
class Base::SendOnChannelService | ||
pattr_initialize [:message!] | ||
|
||
def perform | ||
validate_target_channel | ||
return unless outgoing_message? | ||
return if invalid_message? | ||
|
||
perform_reply | ||
end | ||
|
||
private | ||
|
||
delegate :conversation, to: :message | ||
delegate :contact, :contact_inbox, :inbox, to: :conversation | ||
delegate :channel, to: :inbox | ||
|
||
def channel_class | ||
raise 'Overwrite this method in child class' | ||
end | ||
|
||
def perform_reply | ||
raise 'Overwrite this method in child class' | ||
end | ||
|
||
def outgoing_message_originated_from_channel? | ||
# TODO: we need to refactor this logic as more integrations comes by | ||
# chatwoot messages won't have source id at the moment | ||
# outgoing messages may be created in slack which should be send to the channel | ||
message.source_id.present? && !message.source_id.starts_with?('slack_') | ||
end | ||
|
||
def outgoing_message? | ||
message.outgoing? || message.template? | ||
end | ||
|
||
def invalid_message? | ||
# private notes aren't send to the channels | ||
# we should also avoid the case of message loops, when outgoing messages are created from channel | ||
message.private? || outgoing_message_originated_from_channel? | ||
end | ||
|
||
def validate_target_channel | ||
raise 'Invalid channel service was called' if inbox.channel.class != channel_class | ||
end | ||
end |
33 changes: 5 additions & 28 deletions
33
app/services/facebook/send_reply_service.rb → ...ices/facebook/send_on_facebook_service.rb
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: 6 additions & 13 deletions
19
...rvices/twilio/outgoing_message_service.rb → ...services/twilio/send_on_twilio_service.rb
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
Oops, something went wrong.