Don’t load responses to threads (#14)
* Don’t load responses to threads * Add test case for ignoring threaded messages * Appease rubocop
This commit is contained in:
parent
e22a7e38b8
commit
6ed0deedf8
|
@ -220,7 +220,11 @@ module DiscourseChat::Provider::SlackProvider
|
|||
# Build some message objects
|
||||
@messages = []
|
||||
raw_messages.each_with_index do |message, index|
|
||||
# Only load messages
|
||||
next unless message["type"] == "message"
|
||||
# Don't load responses to threads (if ts==thread_ts then it's the thread parent)
|
||||
next if message["thread_ts"] && message["thread_ts"] != message["ts"]
|
||||
|
||||
this_message = SlackMessage.new(message, self)
|
||||
@messages << this_message
|
||||
end
|
||||
|
|
|
@ -28,6 +28,13 @@ RSpec.describe DiscourseChat::Provider::SlackProvider::SlackTranscript do
|
|||
"text": "So, who's interested in the new <https://meta.discourse.org|discourse plugin>?",
|
||||
"ts": "1501801629.052212"
|
||||
},
|
||||
{
|
||||
"type": "message",
|
||||
"user": "U6E2W7R8C",
|
||||
"text": "I'm interested!!",
|
||||
"ts": "1501801634.053761",
|
||||
"thread_ts": "1501801629.052212"
|
||||
},
|
||||
{
|
||||
"text": "",
|
||||
"username": "Test Community",
|
||||
|
@ -128,6 +135,10 @@ RSpec.describe DiscourseChat::Provider::SlackProvider::SlackTranscript do
|
|||
transcript.load_chat_history
|
||||
end
|
||||
|
||||
it 'ignores messages in a thread' do
|
||||
expect(transcript.messages.length).to eq(6)
|
||||
end
|
||||
|
||||
it 'loads in chronological order' do # API presents in reverse chronological
|
||||
expect(transcript.messages.first.ts).to eq('1501093331.439776')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue