Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/support-multiline-quick-replies
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjona99 authored May 17, 2023
2 parents 292d377 + 175e720 commit 0c25247
Show file tree
Hide file tree
Showing 153 changed files with 3,234 additions and 409 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ gem 'sentry-sidekiq', require: false

##-- background job processing --##
gem 'sidekiq'
gem 'sidekiq_alive'

# We want cron jobs
gem 'sidekiq-cron'

Expand Down Expand Up @@ -177,6 +179,7 @@ group :development do
gem 'annotate'
gem 'bullet'
gem 'letter_opener'
gem 'scss_lint', require: false
gem 'web-console'

# used in swagger build
Expand Down
23 changes: 22 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ GEM
google-cloud-translate-v3 (0.6.0)
gapic-common (>= 0.17.1, < 2.a)
google-cloud-errors (~> 1.0)
google-protobuf (3.22.3)
google-protobuf (3.22.3-arm64-darwin)
google-protobuf (3.22.3-x86_64-darwin)
google-protobuf (3.22.3-x86_64-linux)
Expand Down Expand Up @@ -398,6 +399,8 @@ GEM
launchy (>= 2.2, < 3)
libdatadog (2.0.0.1.0)
libdatadog (2.0.0.1.0-x86_64-linux)
libddwaf (1.8.2.0.0)
ffi (~> 1.0)
libddwaf (1.8.2.0.0-arm64-darwin)
ffi (~> 1.0)
libddwaf (1.8.2.0.0-x86_64-darwin)
Expand Down Expand Up @@ -435,6 +438,7 @@ GEM
mime-types-data (3.2023.0218.1)
mini_magick (4.12.0)
mini_mime (1.1.2)
mini_portile2 (2.8.2)
minitest (5.18.0)
mock_redis (0.36.0)
ruby2_keywords
Expand All @@ -459,6 +463,9 @@ GEM
sidekiq
newrelic_rpm (8.16.0)
nio4r (2.5.9)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.14.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-darwin)
Expand Down Expand Up @@ -637,6 +644,11 @@ GEM
sexp_processor (~> 4.6)
ruby_parser (3.20.0)
sexp_processor (~> 4.16)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
Expand All @@ -647,6 +659,8 @@ GEM
tilt
scout_apm (5.3.3)
parser
scss_lint (0.60.0)
sass (~> 3.5, >= 3.5.5)
seed_dump (3.3.1)
activerecord (>= 4)
activesupport (>= 4)
Expand All @@ -672,6 +686,10 @@ GEM
fugit (~> 1.8)
globalid (>= 1.0.1)
sidekiq (>= 6)
sidekiq_alive (2.2.0)
rack (< 3)
sidekiq (>= 5, < 8)
webrick (>= 1, < 2)
signet (0.17.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
Expand Down Expand Up @@ -773,6 +791,7 @@ PLATFORMS
arm64-darwin-20
arm64-darwin-21
arm64-darwin-22
ruby
x86_64-darwin-18
x86_64-darwin-20
x86_64-darwin-21
Expand Down Expand Up @@ -869,13 +888,15 @@ DEPENDENCIES
rubocop-rails
rubocop-rspec
scout_apm
scss_lint
seed_dump
sentry-rails
sentry-ruby
sentry-sidekiq
shoulda-matchers
sidekiq
sidekiq-cron
sidekiq_alive
simplecov (= 0.17.1)
slack-ruby-client (~> 2.0.0)
spring
Expand All @@ -899,7 +920,7 @@ DEPENDENCIES
working_hours

RUBY VERSION
ruby 3.1.3p185
ruby 3.2.2p53

BUNDLED WITH
2.4.10
12 changes: 6 additions & 6 deletions app/builders/messages/instagram/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def contact
end

def conversation
@conversation ||= Conversation.find_by(conversation_params) || build_conversation
@conversation ||= Conversation.where(
"additional_attributes ->> 'type' = 'instagram_direct_message'"
).find_by(conversation_params) || build_conversation
end

def message_content
Expand Down Expand Up @@ -95,18 +97,16 @@ def save_story_id
def build_conversation
@contact_inbox ||= contact.contact_inboxes.find_by!(source_id: message_source_id)
Conversation.create!(conversation_params.merge(
contact_inbox_id: @contact_inbox.id
contact_inbox_id: @contact_inbox.id,
additional_attributes: { type: 'instagram_direct_message' }
))
end

def conversation_params
{
account_id: @inbox.account_id,
inbox_id: @inbox.id,
contact_id: contact.id,
additional_attributes: {
type: 'instagram_direct_message'
}
contact_id: contact.id
}
end

Expand Down
4 changes: 4 additions & 0 deletions app/controllers/api/v1/accounts/conversations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def search
@conversations_count = result[:count]
end

def attachments
@attachments = @conversation.attachments
end

def create
ActiveRecord::Base.transaction do
@conversation = ConversationBuilder.new(params: params, contact_inbox: @contact_inbox).perform
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/accounts/portals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def update
ActiveRecord::Base.transaction do
@portal.update!(portal_params) if params[:portal].present?
# @portal.custom_domain = parsed_custom_domain
process_attached_logo
process_attached_logo if params[:blob_id].present?
rescue StandardError => e
Rails.logger.error e
render json: { error: @portal.errors.messages }.to_json, status: :unprocessable_entity
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/api/v1/widget/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def set_conversation
def message_finder_params
{
filter_internal_messages: true,
before: permitted_params[:before]
before: permitted_params[:before],
after: permitted_params[:after]
}
end

Expand All @@ -62,7 +63,7 @@ def message_update_params

def permitted_params
# timestamp parameter is used in create conversation method
params.permit(:id, :before, :website_token, contact: [:name, :email], message: [:content, :referer_url, :timestamp, :echo_id])
params.permit(:id, :before, :after, :website_token, contact: [:name, :email], message: [:content, :referer_url, :timestamp, :echo_id])
end

def set_message
Expand Down
15 changes: 0 additions & 15 deletions app/controllers/sidekiq_health_check_controller.rb

This file was deleted.

23 changes: 19 additions & 4 deletions app/finders/conversation_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class ConversationFinder
SORT_OPTIONS = {
latest: 'latest',
sort_on_created_at: 'sort_on_created_at',
last_user_message_at: 'last_user_message_at'
last_user_message_at: 'last_user_message_at',
sort_on_priority: 'sort_on_priority'
}.with_indifferent_access

# assumptions
Expand Down Expand Up @@ -53,9 +54,10 @@ def set_up

find_all_conversations
filter_by_status unless params[:q]
filter_by_team if @team
filter_by_labels if params[:labels]
filter_by_query if params[:q]
filter_by_team
filter_by_labels
filter_by_query
filter_by_source_id
end

def set_inboxes
Expand Down Expand Up @@ -106,6 +108,8 @@ def filter_by_conversation_type
end

def filter_by_query
return unless params[:q]

allowed_message_types = [Message.message_types[:incoming], Message.message_types[:outgoing]]
@conversations = conversations.joins(:messages).where('messages.content ILIKE :search', search: "%#{params[:q]}%")
.where(messages: { message_type: allowed_message_types }).includes(:messages)
Expand All @@ -120,13 +124,24 @@ def filter_by_status
end

def filter_by_team
return unless @team

@conversations = @conversations.where(team: @team)
end

def filter_by_labels
return unless params[:labels]

@conversations = @conversations.tagged_with(params[:labels], any: true)
end

def filter_by_source_id
return unless params[:source_id]

@conversations = @conversations.joins(:contact_inbox)
@conversations = @conversations.where(contact_inboxes: { source_id: params[:source_id] })
end

def set_count_for_all_conversations
[
@conversations.assigned_to(current_user).count,
Expand Down
20 changes: 14 additions & 6 deletions app/javascript/dashboard/api/integrations/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ class OpenAIAPI extends ApiClient {
super('integrations', { accountScoped: true });
}

processEvent({ name = 'rephrase', content, tone, hookId }) {
processEvent({ type = 'rephrase', content, tone, conversationId, hookId }) {
let data = {
tone,
content,
};

if (type === 'reply_suggestion' || type === 'summarize') {
data = {
conversation_display_id: conversationId,
};
}

return axios.post(`${this.url}/hooks/${hookId}/process_event`, {
event: {
name: name,
data: {
tone,
content,
},
name: type,
data,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ $button-sizes: (tiny: var(--font-size-micro),
default: var(--font-size-small),
large: var(--font-size-medium));
$button-palette: $foundation-palette;
$button-opacity-disabled: 0.25;
$button-opacity-disabled: 0.4;
$button-background-hover-lightness: -20%;
$button-hollow-hover-lightness: -50%;
$button-transition: background-color 0.25s ease-out,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const settings = accountId => ({
hasSubMenu: false,
toState: frontendURL(`accounts/${accountId}/settings/audit-log/list`),
toStateName: 'auditlogs_list',
featureFlag: FEATURE_FLAGS.AUDIT_LOGS,
beta: true,
},
],
Expand Down
14 changes: 13 additions & 1 deletion app/javascript/dashboard/components/ui/WootButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
:disabled="isDisabled || isLoading"
@click="handleClick"
>
<spinner v-if="isLoading" size="small" />
<spinner
v-if="isLoading"
size="small"
:color-scheme="showDarkSpinner ? 'dark' : ''"
/>
<emoji-or-icon
v-else-if="icon || emoji"
class="icon"
Expand Down Expand Up @@ -108,6 +112,14 @@ export default {
return 16;
}
},
showDarkSpinner() {
return (
this.colorScheme === 'secondary' ||
this.variant === 'clear' ||
this.variant === 'link' ||
this.variant === 'hollow'
);
},
},
methods: {
handleClick(evt) {
Expand Down
Loading

0 comments on commit 0c25247

Please sign in to comment.