From 4ab67ad41e75befc0aedc17959564e9292b7b3ca Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 07:36:53 +0800 Subject: [PATCH 1/6] See is this blocks public rooms --- src/hipchat.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index d2868c2..8b6f5a1 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -154,9 +154,14 @@ class HipChat extends Adapter @logger.info "Not joining #{jid} because it is blacklisted" return - @logger.info "Joining #{jid}" - connector.join jid - + connector.getRooms (err, rooms, stanza) => + if rooms + for room in rooms + if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid + @logger.info "Not joining #{room.jid} because it is a public room" + else + @logger.info "Joining #{jid}" + connector.join jid # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err From d8c6673f8b5f034fc8e55ddd0de4700e33d2ce8d Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 08:07:34 +0800 Subject: [PATCH 2/6] Ooops --- src/hipchat.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index 8b6f5a1..57d0a45 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -159,9 +159,8 @@ class HipChat extends Adapter for room in rooms if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid @logger.info "Not joining #{room.jid} because it is a public room" - else - @logger.info "Joining #{jid}" - connector.join jid + return + connector.join jid # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err From 61f0f4a2214a19370ba1c2df92c30fd94dae0aaf Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 08:15:34 +0800 Subject: [PATCH 3/6] See if this option works --- src/hipchat.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index 57d0a45..033b361 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -160,7 +160,7 @@ class HipChat extends Adapter if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid @logger.info "Not joining #{room.jid} because it is a public room" return - connector.join jid + connector.join jid # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err From ab2d29daa3fe62a608f58e93493b892c41d40a9d Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 08:28:35 +0800 Subject: [PATCH 4/6] Stop joining --- src/hipchat.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index 033b361..8415e88 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -147,6 +147,7 @@ class HipChat extends Adapter @robot.brain.userForId user.id, user joinRoom = (jid) => + joinroom = 1 if jid and typeof jid is "object" jid = "#{jid.local}@#{jid.domain}" @@ -159,8 +160,8 @@ class HipChat extends Adapter for room in rooms if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid @logger.info "Not joining #{room.jid} because it is a public room" - return - connector.join jid + joinroom = 0 + connector.join jid unless joinroom == 0 # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err From 7d8be64aaa902dca6db0f77208b178c25a51ff33 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 08:32:51 +0800 Subject: [PATCH 5/6] Maybe this will stop it joining? --- src/hipchat.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index 8415e88..b276d13 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -147,7 +147,7 @@ class HipChat extends Adapter @robot.brain.userForId user.id, user joinRoom = (jid) => - joinroom = 1 + @joinroom = 1 if jid and typeof jid is "object" jid = "#{jid.local}@#{jid.domain}" @@ -160,8 +160,8 @@ class HipChat extends Adapter for room in rooms if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid @logger.info "Not joining #{room.jid} because it is a public room" - joinroom = 0 - connector.join jid unless joinroom == 0 + @joinroom = 0 + connector.join jid unless @joinroom == 0 # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err From 087408e160b3c316f7ad61976d6d4b0415f3b1d2 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Fri, 14 Jul 2017 08:38:07 +0800 Subject: [PATCH 6/6] This way maybe --- src/hipchat.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index b276d13..659ca96 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -147,7 +147,6 @@ class HipChat extends Adapter @robot.brain.userForId user.id, user joinRoom = (jid) => - @joinroom = 1 if jid and typeof jid is "object" jid = "#{jid.local}@#{jid.domain}" @@ -160,8 +159,10 @@ class HipChat extends Adapter for room in rooms if !@options.rooms_join_public && room.guest_url != '' && room.jid == jid @logger.info "Not joining #{room.jid} because it is a public room" - @joinroom = 0 - connector.join jid unless @joinroom == 0 + return + else if room.jid == jid + connector.join jid + return # Fetch user info connector.getRoster (err, users, stanza) => return init.reject err if err