Restructure omni services and add Chatwoot research snapshot

This commit is contained in:
Ruslan Bakiev
2026-02-21 11:11:27 +07:00
parent edea7a0034
commit b73babbbf6
7732 changed files with 978203 additions and 32 deletions

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/contact', formats: [:json], resource: @base_contact

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -0,0 +1,3 @@
json.array! @agent_bots do |agent_bot|
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(agent_bot)
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent_bot', formats: [:json], resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent', formats: [:json], resource: @agent

View File

@@ -0,0 +1,3 @@
json.array! @agents do |agent|
json.partial! 'api/v1/models/agent', formats: [:json], resource: agent
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/agent', formats: [:json], resource: @agent

View File

@@ -0,0 +1,33 @@
json.id article.id
json.slug article.slug
json.title article.title
json.content article.content
json.description article.description
json.status article.status
json.position article.position
json.account_id article.account_id
json.updated_at article.updated_at.to_i
json.meta article.meta
json.category do
json.id article.category_id
json.name article.category&.name
json.slug article.category&.slug
json.locale article.category&.locale
end
json.views article.views
if article.author.present?
json.author do
json.partial! 'api/v1/models/agent', formats: [:json], resource: article.author
end
end
json.associated_articles do
if article.associated_articles.any?
json.array! article.associated_articles.each do |associated_article|
json.partial! 'api/v1/accounts/articles/associated_article', formats: [:json], article: associated_article
end
end
end

View File

@@ -0,0 +1,21 @@
json.id article.id
json.category_id article.category_id
json.title article.title
json.content article.content
json.description article.description
json.status article.status
json.account_id article.account_id
if article.portal.present?
json.portal do
json.partial! 'api/v1/accounts/portals/portal', formats: [:json], portal: article.portal, articles: []
end
end
json.views article.views
if article.author.present?
json.author do
json.partial! 'api/v1/models/agent', formats: [:json], resource: article.author
end
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'article', article: @article
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'article', article: @article
end

View File

@@ -0,0 +1,13 @@
json.payload do
json.array! @articles, partial: 'article', as: :article
end
json.meta do
json.all_articles_count @portal_articles.size
json.archived_articles_count @archived_articles_count
json.articles_count @articles_count
json.current_page @current_page
json.draft_articles_count @draft_articles_count
json.mine_articles_count @mine_articles_count
json.published_count @published_articles_count
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'article', article: @article
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'article', article: @article
end

View File

@@ -0,0 +1,5 @@
json.payload do
json.array! @assignable_agents do |agent|
json.partial! 'api/v1/models/agent', formats: [:json], resource: agent
end
end

View File

@@ -0,0 +1,11 @@
json.id assignment_policy.id
json.name assignment_policy.name
json.description assignment_policy.description
json.assignment_order assignment_policy.assignment_order
json.conversation_priority assignment_policy.conversation_priority
json.fair_distribution_limit assignment_policy.fair_distribution_limit
json.fair_distribution_window assignment_policy.fair_distribution_window
json.enabled assignment_policy.enabled
json.assigned_inbox_count assignment_policy.inboxes.count
json.created_at assignment_policy.created_at.to_i
json.updated_at assignment_policy.updated_at.to_i

View File

@@ -0,0 +1 @@
json.partial! 'assignment_policy', assignment_policy: @assignment_policy

View File

@@ -0,0 +1,5 @@
json.id @inbox_assignment_policy.id
json.inbox_id @inbox_assignment_policy.inbox_id
json.assignment_policy_id @inbox_assignment_policy.assignment_policy_id
json.created_at @inbox_assignment_policy.created_at.to_i
json.updated_at @inbox_assignment_policy.updated_at.to_i

View File

@@ -0,0 +1,3 @@
json.inboxes @inboxes do |inbox|
json.partial! 'api/v1/models/inbox', formats: [:json], resource: inbox
end

View File

@@ -0,0 +1,3 @@
json.array! @assignment_policies do |assignment_policy|
json.partial! 'assignment_policy', assignment_policy: assignment_policy
end

View File

@@ -0,0 +1 @@
json.partial! 'assignment_policy', assignment_policy: @assignment_policy

View File

@@ -0,0 +1 @@
json.partial! 'assignment_policy', assignment_policy: @assignment_policy

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/accounts/automation_rules/partials/automation_rule', formats: [:json], automation_rule: @automation_rule
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/accounts/automation_rules/partials/automation_rule', formats: [:json], automation_rule: @automation_rule

View File

@@ -0,0 +1,5 @@
json.payload do
json.array! @automation_rules do |automation_rule|
json.partial! 'api/v1/accounts/automation_rules/partials/automation_rule', formats: [:json], automation_rule: automation_rule
end
end

View File

@@ -0,0 +1,10 @@
json.id automation_rule.id
json.account_id automation_rule.account_id
json.name automation_rule.name
json.description automation_rule.description
json.event_name automation_rule.event_name
json.conditions automation_rule.conditions
json.actions automation_rule.actions
json.created_on automation_rule.created_at.to_i
json.active automation_rule.active?
json.files automation_rule.file_base_data if automation_rule.files.any?

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/accounts/automation_rules/partials/automation_rule', formats: [:json], automation_rule: @automation_rule
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/accounts/automation_rules/partials/automation_rule', formats: [:json], automation_rule: @automation_rule
end

View File

@@ -0,0 +1,4 @@
json.data do
json.page_details @page_details
json.user_access_token @user_access_token
end

View File

@@ -0,0 +1,3 @@
json.data do
json.partial! 'api/v1/models/inbox', formats: [:json], resource: @inbox
end

View File

@@ -0,0 +1,7 @@
json.id @facebook_inbox.id
json.channel_id @facebook_inbox.channel_id
json.name @facebook_inbox.name
json.channel_type @facebook_inbox.channel_type
json.avatar_url @facebook_inbox.try(:avatar_url)
json.page_id @facebook_inbox.channel.try(:page_id)
json.enable_auto_assignment @facebook_inbox.enable_auto_assignment

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/campaign', formats: [:json], resource: @campaign

View File

@@ -0,0 +1,3 @@
json.array! @campaigns do |campaign|
json.partial! 'api/v1/models/campaign', formats: [:json], resource: campaign
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/campaign', formats: [:json], resource: @campaign

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/campaign', formats: [:json], resource: @campaign

View File

@@ -0,0 +1,7 @@
json.id category.id
json.name category.name
json.slug category.slug
json.locale category.locale
json.description category.description
json.position category.position
json.account_id category.account_id

View File

@@ -0,0 +1,32 @@
json.id category.id
json.name category.name
json.slug category.slug
json.locale category.locale
json.description category.description
json.position category.position
json.account_id category.account_id
json.icon category.icon
json.related_categories do
if category.related_categories.any?
json.array! category.related_categories.each do |related_category|
json.partial! 'api/v1/accounts/categories/associated_category', formats: [:json], category: related_category
end
end
end
if category.parent_category.present?
json.parent_category do
json.partial! 'api/v1/accounts/categories/associated_category', formats: [:json], category: category.parent_category
end
end
if category.root_category.present?
json.root_category do
json.partial! 'api/v1/accounts/categories/associated_category', formats: [:json], category: category.root_category
end
end
json.meta do
json.articles_count category.articles.search(locale: @current_locale).size
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'category', category: @category
end

View File

@@ -0,0 +1,8 @@
json.payload do
json.array! @categories, partial: 'category', as: :category
end
json.meta do
json.current_page @current_page
json.categories_count @categories.size
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'category', category: @category
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'category', category: @category
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/inbox', formats: [:json], resource: @inbox

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: true

View File

@@ -0,0 +1,10 @@
json.meta do
json.count @contacts_count
json.current_page @current_page
end
json.payload do
json.array! @contacts do |contact|
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
end
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: false
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/contact_inbox', formats: [:json], resource: @contact_inbox

View File

@@ -0,0 +1,8 @@
json.payload do
json.array! @contactable_inboxes do |contactable_inbox|
json.inbox do
json.partial! 'api/v1/models/inbox_slim', formats: [:json], resource: contactable_inbox[:inbox]
end
json.source_id contactable_inbox[:source_id]
end
end

View File

@@ -0,0 +1,5 @@
json.payload do
json.array! @conversations do |conversation|
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: conversation
end
end

View File

@@ -0,0 +1,9 @@
json.payload do
json.contact do
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: true
end
json.contact_inbox do
json.inbox @contact_inbox&.inbox
json.source_id @contact_inbox&.source_id
end
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: true
end

View File

@@ -0,0 +1,10 @@
json.meta do
json.count @contacts_count
json.current_page @current_page
end
json.payload do
json.array! @contacts do |contact|
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
end
end

View File

@@ -0,0 +1,10 @@
json.meta do
json.count @contacts_count
json.current_page @current_page
end
json.payload do
json.array! @contacts do |contact|
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
end
end

View File

@@ -0,0 +1 @@
json.payload @labels

View File

@@ -0,0 +1 @@
json.payload @labels

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/note', formats: [:json], resource: @note

View File

@@ -0,0 +1,3 @@
json.array! @notes do |note|
json.partial! 'api/v1/models/note', formats: [:json], resource: note
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/note', formats: [:json], resource: @note

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/note', formats: [:json], resource: @note

View File

@@ -0,0 +1,11 @@
json.meta do
json.count @contacts_count
json.current_page @current_page
json.has_more @has_more
end
json.payload do
json.array! @contacts do |contact|
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
end
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: @include_contact_inboxes
end

View File

@@ -0,0 +1,3 @@
json.payload do
json.partial! 'api/v1/models/contact', formats: [:json], resource: @contact, with_contact_inboxes: @include_contact_inboxes
end

View File

@@ -0,0 +1,16 @@
json.meta do
json.total_count @attachments_count
end
json.payload @attachments do |attachment|
json.message_id attachment.push_event_data[:message_id]
json.thumb_url attachment.push_event_data[:thumb_url]
json.data_url attachment.push_event_data[:data_url]
json.file_size attachment.push_event_data[:file_size]
json.file_type attachment.push_event_data[:file_type]
json.extension attachment.push_event_data[:extension]
json.width attachment.push_event_data[:width]
json.height attachment.push_event_data[:height]
json.created_at attachment.message.created_at.to_i
json.sender attachment.message.sender.push_event_data if attachment.message.sender
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: @conversation

View File

@@ -0,0 +1 @@
json.custom_attributes @conversation.custom_attributes

View File

@@ -0,0 +1,10 @@
json.meta do
json.mine_count @conversations_count[:mine_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end
json.payload do
json.array! @conversations do |conversation|
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: conversation
end
end

View File

@@ -0,0 +1,13 @@
json.data do
json.meta do
json.mine_count @conversations_count[:mine_count]
json.assigned_count @conversations_count[:assigned_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end
json.payload do
json.array! @conversations do |conversation|
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: conversation
end
end
end

View File

@@ -0,0 +1 @@
json.payload @labels

View File

@@ -0,0 +1 @@
json.payload @labels

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/message', message: @message

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/message', message: @message

View File

@@ -0,0 +1,14 @@
json.meta do
json.labels @conversation.cached_label_list_array
json.additional_attributes @conversation.additional_attributes
json.contact @conversation.contact.push_event_data
json.assignee @conversation.assignee.push_event_data if @conversation.assignee.present?
json.agent_last_seen_at @conversation.agent_last_seen_at
json.assignee_last_seen_at @conversation.assignee_last_seen_at
end
json.payload do
json.array! @messages do |message|
json.partial! 'api/v1/models/message', message: message
end
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/message', message: @message

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/message', message: @message

View File

@@ -0,0 +1,6 @@
json.meta do
json.mine_count @conversations_count[:mine_count]
json.assigned_count @conversations_count[:assigned_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end

View File

@@ -0,0 +1,3 @@
json.array! @participants do |participant|
json.partial! 'api/v1/models/agent', format: :json, resource: participant.user
end

View File

@@ -0,0 +1,3 @@
json.array! @participants do |participant|
json.partial! 'api/v1/models/agent', format: :json, resource: participant.user
end

View File

@@ -0,0 +1,10 @@
json.meta do
json.mine_count @conversations_count[:mine_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end
json.payload do
json.array! @conversations do |conversation|
json.partial! 'api/v1/models/conversation', formats: [:json], conversation: conversation
end
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: @conversation

View File

@@ -0,0 +1,9 @@
json.meta do
end
json.payload do
json.success @status
json.conversation_id @conversation.display_id
json.current_status @conversation.status
json.snoozed_until @conversation.snoozed_until
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: @conversation

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: @conversation

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/conversations/partials/conversation', formats: [:json], conversation: @conversation

View File

@@ -0,0 +1,25 @@
json.data do
json.id resource.id
json.provider resource.provider
json.uid resource.uid
json.name resource.name
json.display_name resource.display_name
json.email resource.email
json.account_id @account.id
json.created_at resource.created_at
json.pubsub_token resource.pubsub_token
json.role resource.active_account_user&.role
json.inviter_id resource.active_account_user&.inviter_id
json.confirmed resource.confirmed?
json.avatar_url resource.avatar_url
json.access_token resource.access_token.token
json.accounts do
json.array! resource.account_users do |account_user|
json.id account_user.account_id
json.name account_user.account.name
json.active_at account_user.active_at
json.role account_user.role
json.locale account_user.account.locale
end
end
end

View File

@@ -0,0 +1,42 @@
<%
headers = [
I18n.t('reports.csat.headers.agent_name'),
I18n.t('reports.csat.headers.rating'),
I18n.t('reports.csat.headers.feedback'),
I18n.t('reports.csat.headers.contact_name'),
I18n.t('reports.csat.headers.contact_email_address'),
I18n.t('reports.csat.headers.contact_phone_number'),
I18n.t('reports.csat.headers.link_to_the_conversation'),
I18n.t('reports.csat.headers.recorded_at')
]
headers << I18n.t('reports.csat.headers.review_notes') if ChatwootApp.enterprise?
-%>
<%= CSV.generate_line(headers) -%>
<% @csat_survey_responses.each do |csat_response| %>
<% assigned_agent = csat_response.assigned_agent %>
<% contact = csat_response.contact %>
<% conversation = csat_response.conversation %>
<%
row = [
assigned_agent ? "#{assigned_agent.name} (#{assigned_agent.email})" : nil,
csat_response.rating,
csat_response.feedback_message.presence,
contact&.name.presence,
contact&.email.presence,
contact&.phone_number.presence,
conversation ? app_account_conversation_url(account_id: Current.account.id, id: conversation.display_id) : nil,
csat_response.created_at
]
row << csat_response.csat_review_notes if ChatwootApp.enterprise?
-%>
<%= CSV.generate_line(row).html_safe -%>
<% end %>
<%=
CSV.generate_line([
I18n.t(
'reports.period',
since: Date.strptime(params[:since], '%s'),
until: Date.strptime(params[:until], '%s')
)
])
-%>

View File

@@ -0,0 +1,3 @@
json.array! @csat_survey_responses do |csat_survey_response|
json.partial! 'api/v1/models/csat_survey_response', formats: [:json], resource: csat_survey_response
end

View File

@@ -0,0 +1,3 @@
json.total_count @total_count
json.ratings_count @ratings_count
json.total_sent_messages_count @total_sent_messages_count

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/csat_survey_response', formats: [:json], resource: @csat_survey_response

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_attribute_definition', formats: [:json], resource: @custom_attribute_definition

View File

@@ -0,0 +1,3 @@
json.array! @custom_attribute_definitions do |custom_attribute_definition|
json.partial! 'api/v1/models/custom_attribute_definition', formats: [:json], resource: custom_attribute_definition
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_attribute_definition', formats: [:json], resource: @custom_attribute_definition

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_attribute_definition', formats: [:json], resource: @custom_attribute_definition

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_filter', formats: [:json], resource: @custom_filter

View File

@@ -0,0 +1,3 @@
json.array! @custom_filters do |custom_filter|
json.partial! 'api/v1/models/custom_filter', formats: [:json], resource: custom_filter
end

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_filter', formats: [:json], resource: @custom_filter

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/custom_filter', formats: [:json], resource: @custom_filter

View File

@@ -0,0 +1 @@
json.partial! 'api/v1/models/dashboard_app', formats: [:json], resource: @dashboard_app

View File

@@ -0,0 +1,3 @@
json.array! @dashboard_apps do |dashboard_app|
json.partial! 'api/v1/models/dashboard_app', formats: [:json], resource: dashboard_app
end

Some files were not shown because too many files have changed in this diff Show More