Skip to content

Commit

Permalink
update to v3.13.6 (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
nestordavalos authored Sep 24, 2024
2 parents 7116767 + c5edaf8 commit 84b353e
Show file tree
Hide file tree
Showing 30 changed files with 315 additions and 192 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ GEM
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (6.0.0)
puma (6.4.2)
puma (6.4.3)
nio4r (~> 2.0)
pundit (2.3.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -823,7 +823,7 @@ GEM
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default {
icon="call"
/>
<p class="text-green-500 m-0">{{ $t('WEBPHONE.VOICE_CALL') }}</p>
<p class="text-green-500 m-0">-</p>
<p class="text-green-500 m-0">-</p>{{ $t('WEBPHONE.CALLING') }}
<p
v-if="callStatusMessage"
class="text-slate-800 dark:text-slate-100 m-0 text-center"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<script>
import countries from 'shared/constants/countries.js';
import parsePhoneNumber from 'libphonenumber-js';
import {
getActiveCountryCode,
getActiveDialCode,
} from 'shared/components/PhoneInput/helper';
export default {
props: {
Expand Down Expand Up @@ -30,8 +34,8 @@ export default {
selectedIndex: -1,
showDropdown: false,
searchCountry: '',
activeCountryCode: '',
activeDialCode: '',
activeCountryCode: getActiveCountryCode(),
activeDialCode: getActiveDialCode(),
phoneNumber: this.value,
};
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/dashboard/i18n/locale/pt/inboxMgmt.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"INBOX_MGMT": {
"HEADER": "Inboxes",
"HEADER": "Caixas de Entrada",
"DESCRIPTION": "A channel is the mode of communication your customer chooses to interact with you. An inbox is where you manage interactions for a specific channel. It can include communications from various sources such as email, live chat, and social media.",
"LEARN_MORE": "Learn more about inboxes",
"RECONNECTION_REQUIRED": "Your inbox is disconnected. You won't receive new messages until you reauthorize it.",
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/dashboard/i18n/locale/pt/labelsMgmt.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"LABEL_MGMT": {
"HEADER": "Labels",
"HEADER_BTN_TXT": "Add label",
"LOADING": "Fetching labels",
"HEADER": "Etiquetas",
"HEADER_BTN_TXT": "Adicionar Etiqueta",
"LOADING": "Buscando etiquetas",
"DESCRIPTION": "As etiquetas ajudam a categorizar e priorizar conversas e leads. Pode atribuir uma etiqueta a uma conversa ou contacto usando o painel lateral.",
"LEARN_MORE": "Learn more about labels",
"SEARCH_404": "Não existem itens que correspondam a esta consulta",
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/dashboard/i18n/locale/pt/macros.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"DESCRIPTION": "Uma macro é um conjunto de ações guardadas que ajudam os agentes de atendimento ao cliente a completar tarefas facilmente. Os agentes podem definir um conjunto de ações como etiquetar uma conversa com um rótulo, enviar uma transcrição por e-mail, atualizar um atributo personalizado, etc., e podem executar essas ações com um único clique.",
"LEARN_MORE": "Saiba mais sobre macros",
"HEADER_BTN_TXT": "Adicionar uma nova macro",
"HEADER_BTN_TXT_SAVE": "Guardar macro",
"LOADING": "A buscar macros",
"HEADER_BTN_TXT_SAVE": "Salvar macro",
"LOADING": "Procurando macros",
"ERROR": "Algo correu mal. Por favor, tente novamente",
"ORDER_INFO": "As macros serão executadas na ordem em que adicionar as suas ações. Pode reorganizá-las arrastando-as pela alça ao lado de cada nó.",
"ADD": {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/dashboard/i18n/locale/pt/webphone.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"WEBPHONE": {
"CALL": "Chamada",
"CALL": "Chamar",
"TERMINATE": "Terminada",
"ACCEPT_ELSEWHERE": "Aceite por outro utilizador",
"REJECT_ELSEWHERE": "Rejeitado por outro utilizador",
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/dashboard/i18n/locale/pt_BR/labelsMgmt.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"LABEL_MGMT": {
"HEADER": "Labels",
"HEADER_BTN_TXT": "Add label",
"LOADING": "Fetching labels",
"HEADER": "Marcadores",
"HEADER_BTN_TXT": "Adicionar marcador",
"LOADING": "Buscando marcadores",
"DESCRIPTION": "Os rótulos ajudam você a categorizar e priorizar conversas e leads. Você pode atribuir um rótulo a uma conversa ou contato usando o painel lateral.",
"LEARN_MORE": "Learn more about labels",
"SEARCH_404": "Não há itens correspondentes a esta consulta",
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/dashboard/i18n/locale/pt_BR/webphone.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"WEBPHONE": {
"CALL": "Call",
"TERMINATE": "Terminated",
"ACCEPT_ELSEWHERE": "Accepted by another user",
"REJECT_ELSEWHERE": "Rejected by another user",
"CALL": "Chamada",
"TERMINATE": "Terminado",
"ACCEPT_ELSEWHERE": "Aceite por outro utilizador",
"REJECT_ELSEWHERE": "Rejeitado por outro utilizador",
"CONNECT_CALLING": "Conectando",
"CALLING": "Chamando",
"VOICE_CALL": "Chamada de voz",
Expand All @@ -28,4 +28,4 @@
"CONNECTION_FAILED": "Conexão falhou",
"REJECTED": "Rejeitado"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
style="flex: 0 0 auto; margin-right: 10px;"
/>
{{ $t('INBOX_MGMT.ADD.WHATSAPP.SEND_AGENT_NAME.LABEL') }}
<span v-if="v$.url.$error" class="message">
<span v-if="v$.sendAgentName.$error" class="message">
{{ $t('INBOX_MGMT.ADD.WHATSAPP.SEND_AGENT_NAME.ERROR') }}
</span>
</label>
Expand Down Expand Up @@ -122,6 +122,11 @@
:loading="uiFlags.isCreating"
:button-text="$t('INBOX_MGMT.ADD.WHATSAPP.SUBMIT_BUTTON')"
/>
<woot-submit-button
:loading="uiFlags.isUpdating"
:button-text="$t('INBOX_MGMT.ADD.WHATSAPP.GENERATE_API_KEY.LABEL')"
@click="generateToken"
/>
</div>
</form>
</template>
Expand Down
13 changes: 13 additions & 0 deletions app/javascript/shared/components/PhoneInput/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getPhoneCodeByTimezone } from 'timezone-phone-codes';
import ct from 'countries-and-timezones';

const getTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;

export const getActiveDialCode = () => {
return getPhoneCodeByTimezone(getTimezone()) || '';
};

export const getActiveCountryCode = () => {
const country = ct.getCountryForTimezone(getTimezone()) || {};
return country.id || '';
};
9 changes: 7 additions & 2 deletions app/javascript/widget/components/Form/PhoneInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import countries from 'shared/constants/countries.js';
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
import FormulateInputMixin from '@braid/vue-formulate/src/FormulateInputMixin';
import { useDarkMode } from 'widget/composables/useDarkMode';
import {
getActiveCountryCode,
getActiveDialCode,
} from 'shared/components/PhoneInput/helper';
export default {
components: {
Expand All @@ -28,8 +32,8 @@ export default {
selectedIndex: -1,
showDropdown: false,
searchCountry: '',
activeCountryCode: '',
activeDialCode: '',
activeCountryCode: getActiveCountryCode(),
activeDialCode: getActiveDialCode(),
phoneNumber: '',
};
},
Expand Down Expand Up @@ -322,6 +326,7 @@ export default {
<style lang="scss" scoped>
@import '~widget/assets/scss/variables.scss';
.phone-input--wrap {
.phone-input {
height: 2.8rem;
Expand Down
15 changes: 13 additions & 2 deletions app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# id :bigint not null, primary key
# content :text
# description :text
# locale :string default("en"), not null
# meta :jsonb
# position :integer
# slug :string not null
Expand Down Expand Up @@ -55,12 +56,14 @@ class Article < ApplicationRecord

# ensuring that the position is always set correctly
before_create :add_position_to_article
before_create :add_locale_to_article
after_save :category_id_changed_action, if: :saved_change_to_category_id?

enum status: { draft: 0, published: 1, archived: 2 }

scope :search_by_category_slug, ->(category_slug) { where(categories: { slug: category_slug }) if category_slug.present? }
scope :search_by_category_locale, ->(locale) { where(categories: { locale: locale }) if locale.present? }
scope :search_by_locale, ->(locale) { where(locale: locale) if locale.present? }
scope :search_by_author, ->(author_id) { where(author_id: author_id) if author_id.present? }
scope :search_by_status, ->(status) { where(status: status) if status.present? }
scope :order_by_updated_at, -> { reorder(updated_at: :desc) }
Expand All @@ -83,11 +86,11 @@ class Article < ApplicationRecord
)

def self.search(params)
records = joins(
records = left_outer_joins(
:category
).search_by_category_slug(
params[:category_slug]
).search_by_category_locale(params[:locale]).search_by_author(params[:author_id]).search_by_status(params[:status])
).search_by_locale(params[:locale]).search_by_author(params[:author_id]).search_by_status(params[:status])

records = records.text_search(params[:query]) if params[:query].present?
records
Expand Down Expand Up @@ -140,6 +143,14 @@ def category_id_changed_action
update_article_position_in_category
end

def add_locale_to_article
self.locale = if category.present?
category.locale
else
portal.default_locale
end
end

def add_position_to_article
# on creation if a position is already present, ignore it
return if position.present?
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/avatarable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def acceptable_avatar

errors.add(:avatar, 'is too big') if avatar.byte_size > 15.megabytes

acceptable_types = ['image/jpeg', 'image/png', 'image/gif'].freeze
acceptable_types = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
errors.add(:avatar, 'filetype not supported') unless acceptable_types.include?(avatar.content_type)
end
end
4 changes: 2 additions & 2 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def dispatch_destroy_event
end

def create_label_also
prev_labels = Label.where(name: self.label_list)
prev_labels = Label.where(name: label_list)

new_labels = self.label_list - prev_labels
new_labels = label_list - prev_labels

new_labels.each do |label|
Label.create!(name: label)
Expand Down
3 changes: 2 additions & 1 deletion app/services/whatsapp/incoming_message_base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def set_contact
contact_params = @processed_params[:contacts]&.first
return if contact_params.blank?

waid = processed_waid(contact_params[:wa_id])
waid = brazil_phone_number?(contact_params[:wa_id]) ? normalised_brazil_mobile_number(contact_params[:wa_id]) : contact_params[:wa_id]
waid = processed_waid(waid)

contact_inbox = ::ContactInboxWithContactBuilder.new(
source_id: waid,
Expand Down
68 changes: 38 additions & 30 deletions app/services/whatsapp/unoapi_webhook_setup_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ def perform(whatsapp_channel)
whatsapp_channel.provider_config.delete('disconnect')
return disconnect(whatsapp_channel)
end
return unless whatsapp_channel.provider_config['connect']
whatsapp_channel.provider_config.delete('connect')
whatsapp_channel.provider_config.delete('disconnect')
connect(whatsapp_channel)
return true unless whatsapp_channel.provider_config['connect']

whatsapp_channel.provider_config.delete('connect')
whatsapp_channel.provider_config.delete('disconnect')
connect(whatsapp_channel)
end

private
Expand All @@ -28,30 +28,10 @@ def disconnect(whatsapp_channel)

def connect(whatsapp_channel)
phone_number = whatsapp_channel.provider_config['business_account_id']
Rails.logger.debug { "Connecting #{phone_number} from unoapi" }
body = {
ignoreGroupMessages: whatsapp_channel.provider_config['ignore_group_messages'],
ignoreBroadcastStatuses: whatsapp_channel.provider_config['ignore_broadcast_statuses'],
ignoreBroadcastMessages: whatsapp_channel.provider_config['ignore_broadcast_messages'],
ignoreHistoryMessages: whatsapp_channel.provider_config['ignore_history_messages'],
ignoreOwnMessages: whatsapp_channel.provider_config['ignore_own_messages'],
ignoreYourselfMessages: whatsapp_channel.provider_config['ignore_yourself_messages'],
sendConnectionStatus: whatsapp_channel.provider_config['send_connection_status'],
notifyFailedMessages: whatsapp_channel.provider_config['notify_failed_messages'],
composingMessage: whatsapp_channel.provider_config['composing_message'],
rejectCalls: whatsapp_channel.provider_config['reject_calls'],
messageCallsWebhook: whatsapp_channel.provider_config['message_calls_webhook'],
webhooks: [
sendNewMessages: whatsapp_channel.provider_config['webhook_send_new_messages'],
id: 'default',
urlAbsolute: "#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/whatsapp/#{phone_number}",
token: whatsapp_channel.provider_config['webhook_verify_token'],
header: :Authorization
],
sendReactionAsReply: whatsapp_channel.provider_config['send_reaction_as_reply'],
authToken: whatsapp_channel.provider_config['api_key']
}
response = HTTParty.post("#{url(whatsapp_channel)}/register", headers: headers(whatsapp_channel), body: body.to_json)
url = url(whatsapp_channel)
Rails.logger.debug { "Connecting #{phone_number} from unoapi with url #{url}" }
body = params(whatsapp_channel.provider_config, phone_number)
response = HTTParty.post("#{url}/register", headers: headers(whatsapp_channel), body: body.to_json)
Rails.logger.debug { "Response #{response}" }
return send_message(whatsapp_channel) if response.success?

Expand Down Expand Up @@ -85,8 +65,36 @@ def url(whatsapp_channel)

def headers(whatsapp_channel)
{
Authorization: GlobalConfigService.load('UNOAPI_AUTH_TOKEN', whatsapp_channel.provider_config['api_key']),
Authorization: ENV.fetch('UNOAPI_AUTH_TOKEN', whatsapp_channel.provider_config['api_key']),
'Content-Type': 'application/json'
}
end

# rubocop:disable Metrics/MethodLength
def params(provider_config, phone_number)
{
ignoreGroupMessages: provider_config['ignore_group_messages'],
ignoreBroadcastStatuses: provider_config['ignore_broadcast_statuses'],
ignoreBroadcastMessages: provider_config['ignore_broadcast_messages'],
ignoreHistoryMessages: provider_config['ignore_history_messages'],
ignoreOwnMessages: provider_config['ignore_own_messages'],
ignoreYourselfMessages: provider_config['ignore_yourself_messages'],
sendConnectionStatus: provider_config['send_connection_status'],
notifyFailedMessages: provider_config['notify_failed_messages'],
composingMessage: provider_config['composing_message'],
rejectCalls: provider_config['reject_calls'],
messageCallsWebhook: provider_config['message_calls_webhook'],
webhooks: [
sendNewMessages: provider_config['webhook_send_new_messages'],
id: 'default',
urlAbsolute: "#{ENV.fetch('FRONTEND_URL', nil)}/webhooks/whatsapp/#{phone_number}",
token: provider_config['webhook_verify_token'],
header: :Authorization
],
sendReactionAsReply: provider_config['send_reaction_as_reply'],
sendProfilePicture: provider_config['send_profile_picture'],
authToken: provider_config['api_key']
}
end
# rubocop:enable Metrics/MethodLength
end
2 changes: 1 addition & 1 deletion config/app.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shared: &shared
version: '3.13.5'
version: '3.13.6'

development:
<<: *shared
Expand Down
1 change: 1 addition & 0 deletions config/locales/devise.pt_BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ pt_BR:
not_saved:
one: "1 erro impediu este %{resource} de ser salvo:"
other: "%{count} erros impediram este %{resource} de ser salvo:"
record_invalid: "Registro inválido"
Loading

0 comments on commit 84b353e

Please sign in to comment.