mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
chore: Sidebar icons for new inboxes (#3016)
- Sidebar icons for line and telegram inboxes - Sentry fix for contact IP lookup job
This commit is contained in:
@@ -148,6 +148,14 @@ class Messages::Facebook::MessageBuilder
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def process_contact_params_result(result)
|
||||||
|
{
|
||||||
|
name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}",
|
||||||
|
account_id: @inbox.account_id,
|
||||||
|
remote_avatar_url: result['profile_pic'] || ''
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def contact_params
|
def contact_params
|
||||||
begin
|
begin
|
||||||
k = Koala::Facebook::API.new(@inbox.channel.page_access_token) if @inbox.facebook?
|
k = Koala::Facebook::API.new(@inbox.channel.page_access_token) if @inbox.facebook?
|
||||||
@@ -155,14 +163,15 @@ class Messages::Facebook::MessageBuilder
|
|||||||
rescue Koala::Facebook::AuthenticationError
|
rescue Koala::Facebook::AuthenticationError
|
||||||
@inbox.channel.authorization_error!
|
@inbox.channel.authorization_error!
|
||||||
raise
|
raise
|
||||||
|
rescue Koala::Facebook::ClientError => e
|
||||||
|
result = {}
|
||||||
|
# OAuthException, code: 100, error_subcode: 2018218, message: (#100) No profile available for this user
|
||||||
|
# We don't need to capture this error as we don't care about contact params in case of echo messages
|
||||||
|
Sentry.capture_exception(e) unless outgoing_echo?
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
result = {}
|
result = {}
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
{
|
process_contact_params_result(result)
|
||||||
name: "#{result['first_name'] || 'John'} #{result['last_name'] || 'Doe'}",
|
|
||||||
account_id: @inbox.account_id,
|
|
||||||
remote_avatar_url: result['profile_pic'] || ''
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<a href="#" :class="computedChildClass(child)">
|
<a href="#" :class="computedChildClass(child)">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<i
|
<i
|
||||||
v-if="computedInboxClass(child)"
|
v-if="menuItem.key === 'inbox'"
|
||||||
class="inbox-icon"
|
class="inbox-icon"
|
||||||
:class="computedInboxClass(child)"
|
:class="computedInboxClass(child)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ export const getInboxClassByType = (type, phoneNumber) => {
|
|||||||
case INBOX_TYPES.EMAIL:
|
case INBOX_TYPES.EMAIL:
|
||||||
return 'ion-ios-email';
|
return 'ion-ios-email';
|
||||||
|
|
||||||
|
case INBOX_TYPES.TELEGRAM:
|
||||||
|
return 'ion-ios-navigate';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return '';
|
return 'ion-ios-chatbubble';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const INBOX_TYPES = {
|
|||||||
TWILIO: 'Channel::TwilioSms',
|
TWILIO: 'Channel::TwilioSms',
|
||||||
API: 'Channel::Api',
|
API: 'Channel::Api',
|
||||||
EMAIL: 'Channel::Email',
|
EMAIL: 'Channel::Email',
|
||||||
|
TELEGRAM: 'Channel::Telegram',
|
||||||
LINE: 'Channel::Line',
|
LINE: 'Channel::Line',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class ContactIpLookupJob < ApplicationJob
|
|||||||
geocoder_result = Geocoder.search(ip).first
|
geocoder_result = Geocoder.search(ip).first
|
||||||
return unless geocoder_result
|
return unless geocoder_result
|
||||||
|
|
||||||
|
contact.additional_attributes ||= {}
|
||||||
contact.additional_attributes['city'] = geocoder_result.city
|
contact.additional_attributes['city'] = geocoder_result.city
|
||||||
contact.additional_attributes['country'] = geocoder_result.country
|
contact.additional_attributes['country'] = geocoder_result.country
|
||||||
contact.additional_attributes['country_code'] = geocoder_result.country_code
|
contact.additional_attributes['country_code'] = geocoder_result.country_code
|
||||||
@@ -34,7 +35,7 @@ class ContactIpLookupJob < ApplicationJob
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_contact_ip(contact)
|
def get_contact_ip(contact)
|
||||||
contact.additional_attributes['updated_at_ip'] || contact.additional_attributes['created_at_ip']
|
contact.additional_attributes&.dig('updated_at_ip') || contact.additional_attributes&.dig('created_at_ip')
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_look_up_db
|
def ensure_look_up_db
|
||||||
|
|||||||
@@ -54,13 +54,19 @@ class Rack::Attack
|
|||||||
|
|
||||||
# ref: https://github.com/rack/rack-attack/issues/399
|
# ref: https://github.com/rack/rack-attack/issues/399
|
||||||
throttle('login/email', limit: 20, period: 5.minutes) do |req|
|
throttle('login/email', limit: 20, period: 5.minutes) do |req|
|
||||||
email = req.params['email'].presence || ActionDispatch::Request.new(req.env).params['email'].presence
|
if req.path == '/auth/sign_in' && req.post?
|
||||||
email.to_s.downcase.gsub(/\s+/, '') if req.path == '/auth/sign_in' && req.post?
|
# NOTE: This line used to throw ArgumentError /rails/action_mailbox/sendgrid/inbound_emails : invalid byte sequence in UTF-8
|
||||||
|
# Hence placed in the if block
|
||||||
|
email = req.params['email'].presence || ActionDispatch::Request.new(req.env).params['email'].presence
|
||||||
|
email.to_s.downcase.gsub(/\s+/, '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
throttle('reset_password/email', limit: 5, period: 1.hour) do |req|
|
throttle('reset_password/email', limit: 5, period: 1.hour) do |req|
|
||||||
email = req.params['email'].presence || ActionDispatch::Request.new(req.env).params['email'].presence
|
if req.path == '/auth/password' && req.post?
|
||||||
email.to_s.downcase.gsub(/\s+/, '') if req.path == '/auth/password' && req.post?
|
email = req.params['email'].presence || ActionDispatch::Request.new(req.env).params['email'].presence
|
||||||
|
email.to_s.downcase.gsub(/\s+/, '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,18 @@ class Integrations::Dialogflow::ProcessorService
|
|||||||
return unless processable_message?(message)
|
return unless processable_message?(message)
|
||||||
return unless message.conversation.pending?
|
return unless message.conversation.pending?
|
||||||
|
|
||||||
response = get_dialogflow_response(message.conversation.contact_inbox.source_id, message_content(message))
|
content = message_content(message)
|
||||||
process_response(message, response)
|
response = get_dialogflow_response(message.conversation.contact_inbox.source_id, content) if content.present?
|
||||||
|
process_response(message, response) if response.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def message_content(message)
|
def message_content(message)
|
||||||
return message.content_attributes['submitted_values'].first['value'] if event_name == 'message.updated'
|
# TODO: might needs to change this to a way that we fetch the updated value from event data instead
|
||||||
|
# cause the message.updated event could be that that the message was deleted
|
||||||
|
|
||||||
|
return message.content_attributes['submitted_values']&.dig 'value' if event_name == 'message.updated'
|
||||||
|
|
||||||
message.content
|
message.content
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def send_message
|
def send_message
|
||||||
|
return if message_content.blank?
|
||||||
|
|
||||||
@slack_message = slack_client.chat_postMessage(
|
@slack_message = slack_client.chat_postMessage(
|
||||||
channel: hook.reference_id,
|
channel: hook.reference_id,
|
||||||
text: message_content,
|
text: message_content,
|
||||||
|
|||||||
Reference in New Issue
Block a user