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

fix_broken_message_muc #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lita/adapters/hipchat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def send_messages(target, strings)
if target.private_message?
connector.message_jid(target.user.id, strings)
else
connector.message_muc(target.room, strings)
connector.message_muc(muc_domain, target.room, strings)
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/lita/adapters/hipchat/connector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def message_jid(user_jid, strings)
end
end

def message_muc(room_jid, strings)
def message_muc(muc_domain, room_jid, strings)
room_jid = [room_jid, muc_domain].join('@')
muc = mucs[room_jid]
strings.each do |s|
Lita.logger.debug("Sending message to MUC #{room_jid}: #{s}")
Expand Down
4 changes: 2 additions & 2 deletions spec/lita/adapters/hipchat/connector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@
describe "#message_muc" do
it "sends the messages to the room" do
muc = instance_double("Jabber::MUC::SimpleMUCClient")
allow(subject).to receive(:mucs).and_return("jid" => muc)
allow(subject).to receive(:mucs).and_return("jid@conf.hipchat.com" => muc)
expect(muc).to receive(:say).with("foo")
expect(muc).to receive(:say).with("bar")
subject.message_muc("jid", ["foo", "bar"])
subject.message_muc("conf.hipchat.com", "jid", ["foo", "bar"])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lita/adapters/hipchat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
describe "#send_messages" do
it "sends messages to rooms" do
source = instance_double("Lita::Source", room: "room_id", private_message?: false)
expect(subject.connector).to receive(:message_muc).with("room_id", ["Hello!"])
expect(subject.connector).to receive(:message_muc).with("conf.hipchat.com", "room_id", ["Hello!"])
subject.send_messages(source, ["Hello!"])
end

Expand Down