* fix: correct structure of lastMessages in message content * fix: update send_message to store external_created_at timestamp with result from request * fix: filter incoming messages for unread conversation logic * fix: improve extraction of message timestamp in send_message method * feat: enhance message timestamp extraction and update logic in send_message method * refactor: send_message to improve error handling and update external_created_at timestamp * chore: move message timestamp extraction to helper * fix: use message timestamp extract on incoming * fix: update unread_conversation to handle last message correctly for Baileys provider --------- Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
21 lines
649 B
Ruby
21 lines
649 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe BaileysHelper do
|
|
let(:timestamp) { 1_748_003_165 }
|
|
let(:timestamp_hash) { { 'low' => timestamp, 'high' => 123, 'unsigned' => true } }
|
|
|
|
it 'extracts the timestamp from a string' do
|
|
expect(extract_baileys_message_timestamp(timestamp.to_s)).to eq(timestamp)
|
|
end
|
|
|
|
it 'extracts the timestamp from an int' do
|
|
expect(extract_baileys_message_timestamp(timestamp)).to eq(timestamp)
|
|
end
|
|
|
|
it 'extracts the timestamp from a hash' do
|
|
expected_timestamp = timestamp + (timestamp_hash['high'] << 32)
|
|
|
|
expect(extract_baileys_message_timestamp(timestamp_hash)).to eq(expected_timestamp)
|
|
end
|
|
end
|