lita-hipchat 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e89f7ec49f80d0ec744dee829115f6f0f679979a
4
- data.tar.gz: 1320411df7e3435973f6e86ed861e113f84f3bf6
3
+ metadata.gz: 3afeeed54c6b3093fd68a764bdda47a6d925ce4e
4
+ data.tar.gz: 4bc84ba99ea9bf19751559e8532e8d2d2816da21
5
5
  SHA512:
6
- metadata.gz: 6dd4f4d590969bb40e15b09fe7d8810b1eb02781921adfb275ae44a576abb4256c35be0abf6fa9b54926d863e9a26eee7339ed2de54606abefa902c842d981c4
7
- data.tar.gz: d65bf267d3358c42b9e444dd1eb4bb7a1b1856575761bc7b3d370ea6437a31fe48eeb24fe68124f25d81c8e3d9a3666e2c1cc1b83f1bfa62a6bb8fcfb3f6a46b
6
+ metadata.gz: af847c34127057fe05a209e1f3131887f18b7b04da82472f15af56dbb4c893106fc77abc10650fd72530a8cb0cf680795de6a9b3dfd8dfea07458488e31389dd
7
+ data.tar.gz: 80c197bae7c7b5d1740b82b16e45bacd9115481892dd498acff094a3214e25a14468331f533b131da0a8b8554c1105c7a7dc42fae3e52dfb31ba333193630af8
data/README.md CHANGED
@@ -28,6 +28,7 @@ Values for all of the following attributes can be found on the "XMPP/Jabber info
28
28
  * `debug` (Boolean) - If `true`, turns on the underlying Jabber library's (xmpp4r) logger, which is fairly verbose. Default: `false`.
29
29
  * `rooms` (Symbol, Array<String>) - An array of room JIDs that Lita should join upon connection. Can also be the symbol `:all`, which will cause Lita to discover and join all rooms. Default: `nil` (no rooms).
30
30
  * `muc_domain` (String) - The XMPP Multi-User Chat domain to use. Default: `"conf.hipchat.com"`.
31
+ * `ignore_unknown_users` (Boolean) - Messages generated through HipChat's API which don't come from a real user account will be ignored by the robot. With the default setting of false, Lita will emit a warning but the message will be dispatched to any registered handlers as usual. Default: `false`.
31
32
 
32
33
  **Note: You must set the robot's name to the value shown as "Room nickname" on the XMPP settings page.**
33
34
 
@@ -24,6 +24,7 @@ module Lita
24
24
  def muc_message(muc)
25
25
  muc.on_message do |time, nick, text|
26
26
  user = user_by_name(nick)
27
+ return unless user
27
28
  source = Source.new(user: user, room: muc.jid.bare.to_s)
28
29
  message = Message.new(robot, text, source)
29
30
  Lita.logger.debug(
@@ -62,8 +63,8 @@ module Lita
62
63
  items = roster.items.detect { |jid, item| item.iname == name }
63
64
  if items
64
65
  user_by_jid(items.first)
65
- else
66
- Lita.logger.warn <<-MSG
66
+ elsif !Lita.config.adapter.ignore_unknown_users
67
+ Lita.logger.warn <<-MSG.chomp
67
68
  No user with the name #{name.inspect} was found in the roster. The message may
68
69
  have been generated from the HipChat API. A temporary user has been created for
69
70
  this message, but Lita will not be able to reply.
data/lita-hipchat.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-hipchat"
3
- spec.version = "1.4.0"
3
+ spec.version = "1.5.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{A HipChat adapter for Lita.}
@@ -92,6 +92,13 @@ describe Lita::Adapters::HipChat::Callback, lita: true do
92
92
  expect(robot).to receive(:receive).with(message)
93
93
  subject.muc_message(muc)
94
94
  end
95
+
96
+ it "ignores messages from unknown users if the config for it is set" do
97
+ Lita.config.adapter.ignore_unknown_users = true
98
+ allow(muc).to receive(:on_message).and_yield(nil, "Unknown", "foo")
99
+ expect(robot).not_to receive(:receive)
100
+ subject.muc_message(muc)
101
+ end
95
102
  end
96
103
 
97
104
  describe "#roster_update" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita