Chore: Release Fixes (#3011)
- Fix super admin crashing - Fix error on telegram group messages fixes: #2856
This commit is contained in:
parent
2c381d726d
commit
946a09928e
4 changed files with 33 additions and 10 deletions
|
@ -3,10 +3,9 @@ class SuperAdmin::DashboardController < SuperAdmin::ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@data = Conversation.unscoped.group_by_day(:created_at, range: 30.days.ago..2.seconds.ago).count.to_a
|
@data = Conversation.unscoped.group_by_day(:created_at, range: 30.days.ago..2.seconds.ago).count.to_a
|
||||||
@accounts_count = number_with_delimiter(Account.all.length)
|
@accounts_count = number_with_delimiter(Account.count)
|
||||||
@users_count = number_with_delimiter(User.all.length)
|
@users_count = number_with_delimiter(User.count)
|
||||||
@inboxes_count = number_with_delimiter(Inbox.all.length)
|
@inboxes_count = number_with_delimiter(Inbox.count)
|
||||||
@conversations_count = number_with_delimiter(Conversation.all.length)
|
@conversations_count = number_with_delimiter(Conversation.count)
|
||||||
@messages_count = number_with_delimiter(Message.all.length)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
|
# Find the various telegram payload samples here: https://core.telegram.org/bots/webhooks#testing-your-bot-with-updates
|
||||||
|
# https://core.telegram.org/bots/api#available-types
|
||||||
|
|
||||||
class Telegram::IncomingMessageService
|
class Telegram::IncomingMessageService
|
||||||
include ::FileTypeHelper
|
include ::FileTypeHelper
|
||||||
pattr_initialize [:inbox!, :params!]
|
pattr_initialize [:inbox!, :params!]
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
# chatwoot doesn't support group conversations at the moment
|
||||||
|
return unless private_message?
|
||||||
|
|
||||||
set_contact
|
set_contact
|
||||||
update_contact_avatar
|
update_contact_avatar
|
||||||
set_conversation
|
set_conversation
|
||||||
|
@ -20,6 +26,10 @@ class Telegram::IncomingMessageService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def private_message?
|
||||||
|
params.dig(:message, :chat, :type) == 'private'
|
||||||
|
end
|
||||||
|
|
||||||
def account
|
def account
|
||||||
@account ||= inbox.account
|
@account ||= inbox.account
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,10 +53,6 @@ It renders the `_table` partial to display details about the resources.
|
||||||
<div class="metric"><%= @conversations_count %></div>
|
<div class="metric"><%= @conversations_count %></div>
|
||||||
<div>Conversations</div>
|
<div>Conversations</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="report-card">
|
|
||||||
<div class="metric"><%= @messages_count %></div>
|
|
||||||
<div>Messages</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chart--container" style="height:500px">
|
<div class="chart--container" style="height:500px">
|
||||||
|
|
|
@ -18,10 +18,28 @@ describe Telegram::IncomingMessageService do
|
||||||
}
|
}
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
described_class.new(inbox: telegram_channel.inbox, params: params).perform
|
described_class.new(inbox: telegram_channel.inbox, params: params).perform
|
||||||
expect(telegram_channel.inbox.conversations).not_to eq(0)
|
expect(telegram_channel.inbox.conversations.count).not_to eq(0)
|
||||||
expect(Contact.all.first.name).to eq('Sojan Jose')
|
expect(Contact.all.first.name).to eq('Sojan Jose')
|
||||||
expect(telegram_channel.inbox.messages.first.content).to eq('test')
|
expect(telegram_channel.inbox.messages.first.content).to eq('test')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when group messages' do
|
||||||
|
it 'doesnot create conversations, message and contacts' do
|
||||||
|
params = {
|
||||||
|
'update_id' => 2_342_342_343_242,
|
||||||
|
'message' => {
|
||||||
|
'message_id' => 1,
|
||||||
|
'from' => {
|
||||||
|
'id' => 23, 'is_bot' => false, 'first_name' => 'Sojan', 'last_name' => 'Jose', 'username' => 'sojan', 'language_code' => 'en'
|
||||||
|
},
|
||||||
|
'chat' => { 'id' => 23, 'first_name' => 'Sojan', 'last_name' => 'Jose', 'username' => 'sojan', 'type' => 'group' },
|
||||||
|
'date' => 1_631_132_077, 'text' => 'test'
|
||||||
|
}
|
||||||
|
}.with_indifferent_access
|
||||||
|
described_class.new(inbox: telegram_channel.inbox, params: params).perform
|
||||||
|
expect(telegram_channel.inbox.conversations.count).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue