Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #75 from ajaleelp/message_timestamps
Browse files Browse the repository at this point in the history
Store timestamp of message in Message.extensions
  • Loading branch information
jimmycuadra committed Jan 28, 2016
2 parents 1340045 + cfba261 commit b98d2e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/lita/adapters/slack/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def dispatch_message(user)
source.private_message! if channel && channel[0] == "D"
message = Message.new(robot, body, source)
message.command! if source.private_message?
message.extensions[:slack] = { timestamp: data["ts"] }
log.debug("Dispatching message to Lita from #{user.id}.")
robot.receive(message)
end
Expand Down
2 changes: 1 addition & 1 deletion lita-slack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "eventmachine"
spec.add_runtime_dependency "faraday"
spec.add_runtime_dependency "faye-websocket", ">= 0.8.0"
spec.add_runtime_dependency "lita", ">= 4.6.0"
spec.add_runtime_dependency "lita", ">= 4.7.0"
spec.add_runtime_dependency "multi_json"

spec.add_development_dependency "bundler", "~> 1.3"
Expand Down
9 changes: 7 additions & 2 deletions spec/lita/adapters/slack/message_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"type" => "message",
"channel" => "C2147483705",
"user" => "U023BECGF",
"text" => "Hello"
"text" => "Hello",
"ts" => "1234.5678"
}
end
let(:message) { instance_double('Lita::Message', command!: false) }
let(:message) { instance_double('Lita::Message', command!: false, extensions: {}) }
let(:source) { instance_double('Lita::Source', private_message?: false) }
let(:user) { instance_double('Lita::User', id: 'U023BECGF') }

Expand All @@ -49,8 +50,12 @@

it "dispatches the message to Lita" do
expect(robot).to receive(:receive).with(message)
subject.handle
end

it "saves the timestamp in extensions" do
subject.handle
expect(message.extensions[:slack][:timestamp]).to eq("1234.5678")
end

context "when the message is a direct message" do
Expand Down

0 comments on commit b98d2e3

Please sign in to comment.