lita-pubsub 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/lita/handlers/pubsub.rb +14 -10
- data/lita-pubsub.gemspec +1 -1
- data/spec/lita/handlers/pubsub_spec.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68a896e1f4a09f59163397b82b838cca616d71d2
|
4
|
+
data.tar.gz: 1e6d2a0da4e961588b9ed11f4796df2e00e045dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ba0e1107797510cd6bc27f77539a80226a4fbc87221df94daa7ca4a17dff046f3469781393fc37c63932b85fb4919fd14e66b3a912cf62e306b3c171ee0115
|
7
|
+
data.tar.gz: 24ea314614874cde1155be2ed13f3a21b1a86a5a3ff4d30ff70fcf9c5e9175d17772cca8b8d4c687339f279da139bfedc63dc54d7553c2e771900498f5b7da7b
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.2.0] - 2017-11-14
|
10
|
+
### Added
|
11
|
+
- Send asynchronous early response to http publish requests
|
data/lib/lita/handlers/pubsub.rb
CHANGED
@@ -76,23 +76,27 @@ module Lita
|
|
76
76
|
|
77
77
|
def http_get(request, response)
|
78
78
|
validate_http_password!(request.params['password'])
|
79
|
-
robot.trigger(
|
80
|
-
:publish,
|
81
|
-
event: request.params['event'],
|
82
|
-
data: request.params['data']
|
83
|
-
)
|
84
79
|
response.write('ok')
|
80
|
+
Thread.new do
|
81
|
+
robot.trigger(
|
82
|
+
:publish,
|
83
|
+
event: request.params['event'],
|
84
|
+
data: request.params['data']
|
85
|
+
)
|
86
|
+
end
|
85
87
|
end
|
86
88
|
|
87
89
|
def http_post(request, response)
|
88
90
|
data = JSON.parse(request.body.read)
|
89
91
|
validate_http_password!(request.params['password'] || data['password'])
|
90
|
-
robot.trigger(
|
91
|
-
:publish,
|
92
|
-
event: data['event'],
|
93
|
-
data: data['data']
|
94
|
-
)
|
95
92
|
response.write('ok')
|
93
|
+
Thread.new do
|
94
|
+
robot.trigger(
|
95
|
+
:publish,
|
96
|
+
event: data['event'],
|
97
|
+
data: data['data']
|
98
|
+
)
|
99
|
+
end
|
96
100
|
end
|
97
101
|
|
98
102
|
def all_subscriptions(response)
|
data/lita-pubsub.gemspec
CHANGED
@@ -108,6 +108,7 @@ describe Lita::Handlers::Pubsub, lita_handler: true do
|
|
108
108
|
it 'receives events via http get' do
|
109
109
|
send_message("lita subscribe foo", from: room)
|
110
110
|
http.get('/publish?event=foo&data=bar%20baz&password=secret')
|
111
|
+
sleep 0.1 # Give thread some time
|
111
112
|
expect(replies.last).to eq('*foo*: bar baz')
|
112
113
|
end
|
113
114
|
|
@@ -118,6 +119,7 @@ describe Lita::Handlers::Pubsub, lita_handler: true do
|
|
118
119
|
'{"event": "foo", "data":"bar baz", "password":"secret"}',
|
119
120
|
'Content-Type' => 'application/json'
|
120
121
|
)
|
122
|
+
sleep 0.1 # Give thread some time
|
121
123
|
expect(replies.last).to eq('*foo*: bar baz')
|
122
124
|
end
|
123
125
|
|
@@ -125,18 +127,21 @@ describe Lita::Handlers::Pubsub, lita_handler: true do
|
|
125
127
|
send_message("lita subscribe foo", from: room)
|
126
128
|
Lita.config.handlers.pubsub.http_password = nil
|
127
129
|
http.get('/publish?event=foo&data=bar%20baz')
|
130
|
+
sleep 0.1 # Give thread some time
|
128
131
|
expect(replies.last).to eq('*foo*: bar baz')
|
129
132
|
end
|
130
133
|
|
131
134
|
it 'rejects http request without any password' do
|
132
135
|
expect {
|
133
136
|
http.get('/publish?event=foo&data=bar%20baz')
|
137
|
+
sleep 0.1 # Give thread some time
|
134
138
|
}.to raise_error('incorrect password!')
|
135
139
|
end
|
136
140
|
|
137
141
|
it 'rejects bad password via http get' do
|
138
142
|
expect {
|
139
143
|
http.get('/publish?event=foo&data=bar%20baz&password=haxor')
|
144
|
+
sleep 0.1 # Give thread some time
|
140
145
|
}.to raise_error('incorrect password!')
|
141
146
|
end
|
142
147
|
|
@@ -147,6 +152,7 @@ describe Lita::Handlers::Pubsub, lita_handler: true do
|
|
147
152
|
'{"event":"foo", "data":"bar baz", "password":"lol"}',
|
148
153
|
'Content-Type' => 'application/json'
|
149
154
|
)
|
155
|
+
sleep 0.1 # Give thread some time
|
150
156
|
}.to raise_error('incorrect password!')
|
151
157
|
end
|
152
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Varaneckas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
133
|
- ".travis.yml"
|
134
|
+
- CHANGELOG.md
|
134
135
|
- Gemfile
|
135
136
|
- README.md
|
136
137
|
- Rakefile
|