rocketchat 0.1.19 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +34 -0
- data/.rubocop.yml +63 -8
- data/CHANGELOG.md +38 -14
- data/README.md +2 -0
- data/lib/rocket_chat/error.rb +4 -0
- data/lib/rocket_chat/gem_version.rb +1 -1
- data/lib/rocket_chat/im_summary.rb +1 -1
- data/lib/rocket_chat/messages/channel.rb +3 -1
- data/lib/rocket_chat/messages/group.rb +34 -0
- data/lib/rocket_chat/messages/im.rb +49 -2
- data/lib/rocket_chat/messages/room.rb +22 -1
- data/lib/rocket_chat/messages/room_support.rb +10 -0
- data/lib/rocket_chat/messages/user.rb +7 -4
- data/lib/rocket_chat/request_helper.rb +1 -1
- data/lib/rocket_chat/user.rb +15 -0
- data/rocketchat.gemspec +14 -4
- metadata +54 -15
- data/.travis.yml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7907a530b955caeebf01a3e7761eb2b88722d3cebccd409b9c85468db0a4bd6
|
4
|
+
data.tar.gz: 5d368fbed83d9a6777aeccfbe02382295fc1024c53e1bd987cea266cfc0de1ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eea355bd46d9c4beb48170431f2e27386faeb3748db31be3764cdda4cb158f10a57f22b4d2de668ee9e33930d56c8bb6175ebb4a8bf7e0346992a00ba3ddf34e
|
7
|
+
data.tar.gz: 5bb2267586fe3995ba4d645747a7b71d2ac72d93ea7064dceedc0eddcc2c775698991f0f963394ebd8304e7ab76d0624271a603c425989659390627a5cede2fc
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Test RocketChat Ruby gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
pull_request:
|
7
|
+
branches: [main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- name: Lint code - Rubocop
|
26
|
+
run: bundle exec rubocop
|
27
|
+
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rspec
|
30
|
+
|
31
|
+
- name: Test & publish code coverage
|
32
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
33
|
+
env:
|
34
|
+
CC_TEST_REPORTER_ID: abf0a371ff8851f13b563671914b195bb46f0997f0f93142e666d9acad08e22f
|
data/.rubocop.yml
CHANGED
@@ -1,24 +1,79 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 2.5
|
9
|
+
|
10
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Layout/SpaceAroundMethodCallOperator:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Lint/DeprecatedOpenSSLConstant:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Lint/MixedRegexpCaptureTypes:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Lint/RaiseException:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Lint/StructNewOverride:
|
29
|
+
Enabled: true
|
2
30
|
|
3
31
|
Metrics/BlockLength:
|
4
32
|
Exclude:
|
5
33
|
- "**/*_spec.rb"
|
6
34
|
- "spec/shared/*.rb"
|
7
35
|
|
8
|
-
Metrics/LineLength:
|
9
|
-
Max: 120
|
10
|
-
|
11
36
|
Metrics/MethodLength:
|
12
37
|
Max: 15
|
13
38
|
Exclude:
|
14
39
|
- "**/*_spec.rb"
|
15
40
|
|
16
|
-
Style/NumericLiterals:
|
17
|
-
Exclude:
|
18
|
-
- "**/*_spec.rb"
|
19
|
-
|
20
41
|
RSpec/ExampleLength:
|
21
42
|
Max: 10
|
22
43
|
|
23
44
|
RSpec/MultipleExpectations:
|
24
45
|
Max: 5
|
46
|
+
|
47
|
+
RSpec/MultipleMemoizedHelpers:
|
48
|
+
Max: 15
|
49
|
+
|
50
|
+
RSpec/NestedGroups:
|
51
|
+
Max: 4
|
52
|
+
|
53
|
+
Style/ExponentialNotation:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Style/HashEachMethods:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Style/HashTransformKeys:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Style/HashTransformValues:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Style/NumericLiterals:
|
66
|
+
Exclude:
|
67
|
+
- "**/*_spec.rb"
|
68
|
+
|
69
|
+
Style/RedundantFetchBlock:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Style/RedundantRegexpCharacterClass:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Style/RedundantRegexpEscape:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Style/SlicingWithRange:
|
79
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,24 @@
|
|
3
3
|
## Unreleased
|
4
4
|
- None
|
5
5
|
|
6
|
+
## [0.1.22](releases/tag/v0.1.22) - 2022-07-21
|
7
|
+
### Fixed
|
8
|
+
- [#38] Fix room (channel/group) online API queries (use `query` instead of `roomId`) ([@abrom][])
|
9
|
+
|
10
|
+
## [0.1.21](releases/tag/v0.1.21) - 2021-08-30
|
11
|
+
### Added
|
12
|
+
- [#36] Improve support for various REST APIs ([@abrom][])
|
13
|
+
|
14
|
+
## [0.1.20](releases/tag/v0.1.20) - 2021-03-29
|
15
|
+
### Added
|
16
|
+
- [#34] Support for channels.members and groups.members ([@alinavancea][])
|
17
|
+
|
18
|
+
### Deprecation
|
19
|
+
- [#35] Drop Ruby 2.3 and 2.4 support ([@abrom][])
|
20
|
+
|
6
21
|
## [0.1.19](releases/tag/v0.1.19) - 2019-03-01
|
7
22
|
### Fixed
|
8
|
-
- Address CVE-2020-8130 - `rake` OS command injection vulnerability
|
23
|
+
- Address CVE-2020-8130 - `rake` OS command injection vulnerability ([@abrom][])
|
9
24
|
|
10
25
|
## [0.1.18](releases/tag/v0.1.18) - 2018-01-05
|
11
26
|
### Added
|
@@ -13,19 +28,19 @@
|
|
13
28
|
|
14
29
|
## [0.1.17](releases/tag/v0.1.17) - 2019-01-05
|
15
30
|
### Deprecation
|
16
|
-
- Drop Ruby 2.1 from build matrix
|
31
|
+
- Drop Ruby 2.1 from build matrix ([@abrom][])
|
17
32
|
|
18
33
|
## [0.1.16](releases/tag/v0.1.16) - 2018-10-3
|
19
34
|
### Deprecation
|
20
|
-
- Drop Ruby 2.0 from build matrix
|
35
|
+
- Drop Ruby 2.0 from build matrix ([@abrom][])
|
21
36
|
|
22
37
|
### Added
|
23
38
|
- [#27] Support for channels.online ([@chrisstime][])
|
24
|
-
- `rubocop-rspec` dependency and fixed new lints
|
39
|
+
- [#28] `rubocop-rspec` dependency and fixed new lints ([@abrom][])
|
25
40
|
|
26
41
|
## [0.1.15](releases/tag/v0.1.15) - 2017-12-21
|
27
42
|
### Fixed
|
28
|
-
- Updated yard to resolve potential security vulnerability
|
43
|
+
- Updated yard to resolve potential security vulnerability ([@abrom][])
|
29
44
|
|
30
45
|
## [0.1.14](releases/tag/v0.1.14) - 2017-10-9
|
31
46
|
### Added
|
@@ -33,16 +48,16 @@
|
|
33
48
|
|
34
49
|
## [0.1.13](releases/tag/v0.1.13) - 2017-10-9
|
35
50
|
### Added
|
36
|
-
- Support for channel/group addAll endpoint
|
51
|
+
- Support for channel/group addAll endpoint ([@abrom][])
|
37
52
|
|
38
53
|
## [0.1.12](releases/tag/v0.1.12) - 2017-08-28
|
39
54
|
### Fixed
|
40
|
-
- GET request parameter encoding
|
55
|
+
- GET request parameter encoding ([@abrom][])
|
41
56
|
|
42
57
|
## [0.1.11](releases/tag/v0.1.11) - 2017-08-22
|
43
58
|
### Fixed
|
44
59
|
- [#15] Response parser improvements ([@reist][],[@danischreiber][])
|
45
|
-
- [#17] Fixed a missing dependency issue with `net/http`
|
60
|
+
- [#17] Fixed a missing dependency issue with `net/http` ([@abrom][])
|
46
61
|
|
47
62
|
### Added
|
48
63
|
- [#14] Add/remove moderator from room ([@danischreiber][])
|
@@ -53,11 +68,11 @@
|
|
53
68
|
|
54
69
|
## [0.1.9](releases/tag/v0.1.9) - 2017-07-16
|
55
70
|
### Fixed
|
56
|
-
- Update chat message handlers to support Ruby 2.0
|
71
|
+
- Update chat message handlers to support Ruby 2.0 ([@abrom][])
|
57
72
|
|
58
73
|
## [0.1.8](releases/tag/v0.1.8) - 2017-07-16
|
59
74
|
### Added
|
60
|
-
- Messages chat API support
|
75
|
+
- Messages chat API support ([@abrom][])
|
61
76
|
|
62
77
|
## [0.1.7](releases/tag/v0.1.7) - 2017-07-16
|
63
78
|
### Added
|
@@ -74,7 +89,7 @@
|
|
74
89
|
|
75
90
|
## [0.1.4](releases/tag/v0.1.4) - 2017-07-9
|
76
91
|
### Fixed
|
77
|
-
- Fixed a missing dependency issue with `uri`
|
92
|
+
- Fixed a missing dependency issue with `uri` ([@abrom][])
|
78
93
|
|
79
94
|
## [0.1.2](releases/tag/v0.1.2) - 2017-05-24
|
80
95
|
### Added
|
@@ -82,15 +97,15 @@
|
|
82
97
|
|
83
98
|
## [0.1.1](releases/tag/v0.1.1) - 2017-05-1
|
84
99
|
### Added
|
85
|
-
- Support for settings get/set endpoints
|
100
|
+
- Support for settings get/set endpoints ([@abrom][])
|
86
101
|
|
87
102
|
## [0.0.8](releases/tag/v0.0.8) - 2017-04-30
|
88
103
|
### Added
|
89
|
-
- Support for Users `getPresence` endpoint
|
104
|
+
- Support for Users `getPresence` endpoint ([@abrom][])
|
90
105
|
|
91
106
|
## [0.0.7](releases/tag/v0.0.7) - 2017-04-30
|
92
107
|
### Added
|
93
|
-
- Support for Users `list` endpoint
|
108
|
+
- Support for Users `list` endpoint ([@abrom][])
|
94
109
|
|
95
110
|
## [0.0.6](releases/tag/v0.0.6) - 2017-04-25
|
96
111
|
### Fixed
|
@@ -99,3 +114,12 @@
|
|
99
114
|
## [0.0.5](releases/tag/v0.0.5) - 2017-04-25
|
100
115
|
### Added
|
101
116
|
- [#1] Added Users `info` and `delete` endpoints ([@reist][])
|
117
|
+
|
118
|
+
[@abrom]: https://github.com/abrom
|
119
|
+
[@reist]: https://github.com/reist
|
120
|
+
[@danischreiber]: https://github.com/danischreiber
|
121
|
+
[@hardik127]: https://github.com/hardik127
|
122
|
+
[@chrisstime]: https://github.com/chrisstime
|
123
|
+
[@christianmoretti]: https://github.com/christianmoretti
|
124
|
+
[@alinavancea]: https://github.com/alinavancea
|
125
|
+
|
data/README.md
CHANGED
@@ -68,6 +68,7 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
68
68
|
* [/api/v1/channels.setTopic](docs/channels.md#channelsset_attr)
|
69
69
|
* [/api/v1/channels.setType](docs/channels.md#channelsset_attr)
|
70
70
|
* [/api/v1/channels.online](docs/channels.md#channelsonline)
|
71
|
+
* [/api/v1/channels.members](docs/channels.md#channelsmembers)
|
71
72
|
* /api/v1/channels.unarchive
|
72
73
|
|
73
74
|
#### Groups
|
@@ -89,6 +90,7 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
89
90
|
* /api/v1/groups.setReadOnly
|
90
91
|
* /api/v1/groups.setTopic
|
91
92
|
* /api/v1/groups.setType
|
93
|
+
* [/api/v1/groups.members](docs/groups.md#groupsmembers)
|
92
94
|
* /api/v1/groups.unarchive
|
93
95
|
|
94
96
|
#### Users
|
data/lib/rocket_chat/error.rb
CHANGED
@@ -46,13 +46,15 @@ module RocketChat
|
|
46
46
|
#
|
47
47
|
# channels.online REST API
|
48
48
|
# @param [String] room_id Rocket.Chat room id
|
49
|
+
# @param [String] name Rocket.Chat room name
|
49
50
|
# @return [Users[]]
|
51
|
+
# @note Must provide either `room_id` or `name` parameter. `room_id` will take precedence if providing both
|
50
52
|
# @raise [HTTPError, StatusError]
|
51
53
|
#
|
52
54
|
def online(room_id: nil, name: nil)
|
53
55
|
response = session.request_json(
|
54
56
|
'/api/v1/channels.online',
|
55
|
-
body:
|
57
|
+
body: { query: room_query_params(room_id, name) }
|
56
58
|
)
|
57
59
|
|
58
60
|
response['online'].map { |hash| RocketChat::User.new hash } if response['success']
|
@@ -57,6 +57,40 @@ module RocketChat
|
|
57
57
|
response['groups'].map { |hash| RocketChat::Room.new hash } if response['success']
|
58
58
|
end
|
59
59
|
|
60
|
+
# groups.listAll REST API
|
61
|
+
# @param [Integer] offset Query offset
|
62
|
+
# @param [Integer] count Query count/limit
|
63
|
+
# @param [Hash] sort Query field sort hash. eg `{ msgs: 1, name: -1 }`
|
64
|
+
# @param [Hash] fields Query fields to return. eg `{ name: 1, ro: 0 }`
|
65
|
+
# @return [Room[]]
|
66
|
+
# @raise [HTTPError, StatusError]
|
67
|
+
#
|
68
|
+
def list_all(offset: nil, count: nil, sort: nil, fields: nil, query: nil)
|
69
|
+
response = session.request_json(
|
70
|
+
'/api/v1/groups.listAll',
|
71
|
+
body: build_list_body(offset, count, sort, fields, query)
|
72
|
+
)
|
73
|
+
|
74
|
+
response['groups'].map { |hash| RocketChat::Room.new hash } if response['success']
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# groups.online REST API
|
79
|
+
# @param [String] room_id Rocket.Chat room id
|
80
|
+
# @param [String] name Rocket.Chat room name
|
81
|
+
# @return [Users[]]
|
82
|
+
# @note Must provide either `room_id` or `name` parameter. `room_id` will take precedence if providing both
|
83
|
+
# @raise [HTTPError, StatusError]
|
84
|
+
#
|
85
|
+
def online(room_id: nil, name: nil)
|
86
|
+
response = session.request_json(
|
87
|
+
'/api/v1/groups.online',
|
88
|
+
body: { query: room_query_params(room_id, name) }
|
89
|
+
)
|
90
|
+
|
91
|
+
response['online'].map { |hash| RocketChat::User.new hash } if response['success']
|
92
|
+
end
|
93
|
+
|
60
94
|
# Keys for set_attr:
|
61
95
|
# * [String] description A room's description
|
62
96
|
# * [String] purpose Alias for description
|
@@ -6,6 +6,8 @@ module RocketChat
|
|
6
6
|
# Rocket.Chat Direct messages
|
7
7
|
#
|
8
8
|
class Im
|
9
|
+
include ListSupport
|
10
|
+
|
9
11
|
#
|
10
12
|
# @param [Session] session Session
|
11
13
|
#
|
@@ -16,18 +18,63 @@ module RocketChat
|
|
16
18
|
#
|
17
19
|
# im.create REST API
|
18
20
|
# @param [String] username Rocket.Chat username
|
21
|
+
# @param [String[]] usernames Array of Rocket.Chat usernames
|
22
|
+
# @param [Boolean] exclude_self Flag indicating whether the authenticated user should be included in the group
|
19
23
|
# @return [RocketChat::Room]
|
20
24
|
# @raise [HTTPError, StatusError]
|
21
25
|
#
|
22
|
-
def create(username:)
|
26
|
+
def create(username: nil, usernames: nil, exclude_self: false)
|
27
|
+
params =
|
28
|
+
if exclude_self
|
29
|
+
{ usernames: usernames.join(','), excludeSelf: true }
|
30
|
+
elsif usernames
|
31
|
+
{ usernames: usernames.join(',') }
|
32
|
+
else
|
33
|
+
{ username: username }
|
34
|
+
end
|
35
|
+
|
23
36
|
response = session.request_json(
|
24
37
|
'/api/v1/im.create',
|
25
38
|
method: :post,
|
26
|
-
body:
|
39
|
+
body: params
|
27
40
|
)
|
28
41
|
RocketChat::Room.new response['room']
|
29
42
|
end
|
30
43
|
|
44
|
+
#
|
45
|
+
# im.delete REST API
|
46
|
+
# @param [String] room_id Rocket.Chat direct message room ID
|
47
|
+
# @return [Boolean]
|
48
|
+
# @raise [HTTPError, StatusError]
|
49
|
+
#
|
50
|
+
def delete(room_id: nil)
|
51
|
+
session.request_json(
|
52
|
+
'/api/v1/im.delete',
|
53
|
+
method: :post,
|
54
|
+
body: { roomId: room_id },
|
55
|
+
upstreamed_errors: ['error-room-not-found']
|
56
|
+
)['success']
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# im.list.everyone REST API
|
61
|
+
# @param [Integer] offset Query offset
|
62
|
+
# @param [Integer] count Query count/limit
|
63
|
+
# @param [Hash] sort Query field sort hash. eg `{ msgs: 1, name: -1 }`
|
64
|
+
# @param [Hash] fields Query fields to return. eg `{ name: 1, ro: 0 }`
|
65
|
+
# @param [Hash] query The query. `{ active: true, type: { '$in': ['name', 'general'] } }`
|
66
|
+
# @return [Room[]]
|
67
|
+
# @raise [HTTPError, StatusError]
|
68
|
+
#
|
69
|
+
def list_everyone(offset: nil, count: nil, sort: nil, fields: nil, query: nil)
|
70
|
+
response = session.request_json(
|
71
|
+
'/api/v1/im.list.everyone',
|
72
|
+
body: build_list_body(offset, count, sort, fields, query)
|
73
|
+
)
|
74
|
+
|
75
|
+
response['ims'].map { |hash| RocketChat::Room.new hash } if response['success']
|
76
|
+
end
|
77
|
+
|
31
78
|
#
|
32
79
|
# im.counters REST API
|
33
80
|
# @param [String] room_id Rocket.Chat roomId
|
@@ -11,9 +11,11 @@ module RocketChat
|
|
11
11
|
|
12
12
|
def self.inherited(subclass)
|
13
13
|
field = subclass.name.split('::')[-1].downcase
|
14
|
-
collection = field
|
14
|
+
collection = "#{field}s"
|
15
15
|
subclass.send(:define_singleton_method, :field) { field }
|
16
16
|
subclass.send(:define_singleton_method, :collection) { collection }
|
17
|
+
|
18
|
+
super
|
17
19
|
end
|
18
20
|
|
19
21
|
#
|
@@ -283,6 +285,25 @@ module RocketChat
|
|
283
285
|
)['success']
|
284
286
|
end
|
285
287
|
|
288
|
+
#
|
289
|
+
# *.members* REST API
|
290
|
+
# @param [String] room_id Rocket.Chat room id
|
291
|
+
# @param [String] name Rocket.Chat room name
|
292
|
+
# @param [Integer] offset Query offset
|
293
|
+
# @param [Integer] count Query count/limit
|
294
|
+
# @param [Hash] sort Query field sort hash. eg `{ msgs: 1, name: -1 }`
|
295
|
+
# @return [Users[]]
|
296
|
+
# @raise [HTTPError, StatusError]
|
297
|
+
#
|
298
|
+
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil)
|
299
|
+
response = session.request_json(
|
300
|
+
self.class.api_path('members'),
|
301
|
+
body: room_params(room_id, name).merge(build_list_body(offset, count, sort, nil, nil))
|
302
|
+
)
|
303
|
+
|
304
|
+
response['members'].map { |hash| RocketChat::User.new hash } if response['success']
|
305
|
+
end
|
306
|
+
|
286
307
|
private
|
287
308
|
|
288
309
|
attr_reader :session
|
@@ -69,7 +69,7 @@ module RocketChat
|
|
69
69
|
method: :post,
|
70
70
|
body: {
|
71
71
|
userId: id,
|
72
|
-
data: user_option_hash(options, true)
|
72
|
+
data: user_option_hash(options, include_personal_fields: true)
|
73
73
|
}
|
74
74
|
)
|
75
75
|
RocketChat::User.new response['user']
|
@@ -114,13 +114,16 @@ module RocketChat
|
|
114
114
|
# users.info REST API
|
115
115
|
# @param [String] user_id Rocket.Chat user id
|
116
116
|
# @param [String] username Username
|
117
|
+
# @param [Boolean] include_rooms Whether to include rooms in the response.
|
118
|
+
# Requires calling user to have the `view-other-user-channels` permission
|
117
119
|
# @return [User]
|
118
120
|
# @raise [HTTPError, StatusError]
|
119
121
|
#
|
120
|
-
def info(user_id: nil, username: nil)
|
122
|
+
def info(user_id: nil, username: nil, include_rooms: false)
|
121
123
|
response = session.request_json(
|
122
124
|
'/api/v1/users.info',
|
123
|
-
body: user_params(user_id, username)
|
125
|
+
body: user_params(user_id, username)
|
126
|
+
.merge(include_rooms ? { fields: { userRooms: 1 }.to_json } : {}),
|
124
127
|
upstreamed_errors: ['error-invalid-user']
|
125
128
|
)
|
126
129
|
|
@@ -179,7 +182,7 @@ module RocketChat
|
|
179
182
|
|
180
183
|
attr_reader :session
|
181
184
|
|
182
|
-
def user_option_hash(options, include_personal_fields
|
185
|
+
def user_option_hash(options, include_personal_fields: false)
|
183
186
|
args = [options, :active, :roles, :join_default_channels, :require_password_change,
|
184
187
|
:send_welcome_email, :verified, :custom_fields]
|
185
188
|
args += %i[username email name password] if include_personal_fields
|
@@ -111,7 +111,7 @@ module RocketChat
|
|
111
111
|
add_body(req, body) if body
|
112
112
|
else
|
113
113
|
uri = path
|
114
|
-
uri +=
|
114
|
+
uri += "?#{body.map { |k, v| "#{k}=#{v}" }.join('&')}" if body
|
115
115
|
req = Net::HTTP::Get.new(uri, headers)
|
116
116
|
end
|
117
117
|
|
data/lib/rocket_chat/user.rb
CHANGED
@@ -70,6 +70,21 @@ module RocketChat
|
|
70
70
|
data['roles']
|
71
71
|
end
|
72
72
|
|
73
|
+
# User rooms
|
74
|
+
def rooms
|
75
|
+
return [] unless data['rooms'].is_a? Array
|
76
|
+
|
77
|
+
data['rooms'].map do |hash|
|
78
|
+
# the users.info API returns the rooms data with the subscription ID as `_id` and room ID as `rid`
|
79
|
+
if hash['rid']
|
80
|
+
hash['subscription_id'] = hash['_id']
|
81
|
+
hash['_id'] = hash['rid']
|
82
|
+
end
|
83
|
+
|
84
|
+
RocketChat::Room.new hash
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
def inspect
|
74
89
|
format(
|
75
90
|
'#<%<class_name>s:0x%<object_id>p @id="%<id>s" @username="%<username>s" @active="%<active>s">',
|
data/rocketchat.gemspec
CHANGED
@@ -15,6 +15,14 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.description = 'Rocket.Chat REST API v1 for Ruby'
|
16
16
|
spec.homepage = 'https://github.com/abrom/rocketchat-ruby'
|
17
17
|
spec.license = 'MIT'
|
18
|
+
spec.required_ruby_version = ['>= 2.5.0', '< 3.2.0']
|
19
|
+
|
20
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
21
|
+
# delete this section to allow pushing this gem to any host.
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
23
|
+
|
24
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
18
26
|
|
19
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|docs)/}) }
|
20
28
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -23,9 +31,11 @@ Gem::Specification.new do |spec|
|
|
23
31
|
spec.add_development_dependency 'bundler', ['>= 1.11', '< 3.0']
|
24
32
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
25
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
-
spec.add_development_dependency 'rubocop', '~>
|
27
|
-
spec.add_development_dependency 'rubocop-
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency '
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 1.28'
|
35
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.13'
|
36
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
|
37
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
|
38
|
+
spec.add_development_dependency 'simplecov', '~> 0.16', '< 0.18'
|
39
|
+
spec.add_development_dependency 'webmock', '~> 3.12'
|
30
40
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
31
41
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- int512
|
8
8
|
- abrom
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -65,28 +65,56 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '1.28'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.28'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rubocop-performance
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.13'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.13'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rubocop-rake
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.6'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
76
104
|
- !ruby/object:Gem::Dependency
|
77
105
|
name: rubocop-rspec
|
78
106
|
requirement: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
110
|
+
version: '2.10'
|
83
111
|
type: :development
|
84
112
|
prerelease: false
|
85
113
|
version_requirements: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - "~>"
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
117
|
+
version: '2.10'
|
90
118
|
- !ruby/object:Gem::Dependency
|
91
119
|
name: simplecov
|
92
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +122,9 @@ dependencies:
|
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0.16'
|
125
|
+
- - "<"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0.18'
|
97
128
|
type: :development
|
98
129
|
prerelease: false
|
99
130
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -101,20 +132,23 @@ dependencies:
|
|
101
132
|
- - "~>"
|
102
133
|
- !ruby/object:Gem::Version
|
103
134
|
version: '0.16'
|
135
|
+
- - "<"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0.18'
|
104
138
|
- !ruby/object:Gem::Dependency
|
105
139
|
name: webmock
|
106
140
|
requirement: !ruby/object:Gem::Requirement
|
107
141
|
requirements:
|
108
142
|
- - "~>"
|
109
143
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
144
|
+
version: '3.12'
|
111
145
|
type: :development
|
112
146
|
prerelease: false
|
113
147
|
version_requirements: !ruby/object:Gem::Requirement
|
114
148
|
requirements:
|
115
149
|
- - "~>"
|
116
150
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
151
|
+
version: '3.12'
|
118
152
|
- !ruby/object:Gem::Dependency
|
119
153
|
name: yard
|
120
154
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,9 +172,9 @@ executables:
|
|
138
172
|
extensions: []
|
139
173
|
extra_rdoc_files: []
|
140
174
|
files:
|
175
|
+
- ".github/workflows/test.yml"
|
141
176
|
- ".gitignore"
|
142
177
|
- ".rubocop.yml"
|
143
|
-
- ".travis.yml"
|
144
178
|
- CHANGELOG.md
|
145
179
|
- Gemfile
|
146
180
|
- LICENSE
|
@@ -175,8 +209,10 @@ files:
|
|
175
209
|
homepage: https://github.com/abrom/rocketchat-ruby
|
176
210
|
licenses:
|
177
211
|
- MIT
|
178
|
-
metadata:
|
179
|
-
|
212
|
+
metadata:
|
213
|
+
allowed_push_host: https://rubygems.org
|
214
|
+
rubygems_mfa_required: 'true'
|
215
|
+
post_install_message:
|
180
216
|
rdoc_options: []
|
181
217
|
require_paths:
|
182
218
|
- lib
|
@@ -184,15 +220,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
220
|
requirements:
|
185
221
|
- - ">="
|
186
222
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
223
|
+
version: 2.5.0
|
224
|
+
- - "<"
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: 3.2.0
|
188
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
228
|
requirements:
|
190
229
|
- - ">="
|
191
230
|
- !ruby/object:Gem::Version
|
192
231
|
version: '0'
|
193
232
|
requirements: []
|
194
|
-
rubygems_version: 3.
|
195
|
-
signing_key:
|
233
|
+
rubygems_version: 3.2.33
|
234
|
+
signing_key:
|
196
235
|
specification_version: 4
|
197
236
|
summary: Rocket.Chat REST API v1 for Ruby
|
198
237
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
env:
|
2
|
-
global:
|
3
|
-
- CC_TEST_REPORTER_ID=abf0a371ff8851f13b563671914b195bb46f0997f0f93142e666d9acad08e22f
|
4
|
-
|
5
|
-
language: ruby
|
6
|
-
|
7
|
-
rvm:
|
8
|
-
- 2.2
|
9
|
-
- 2.3
|
10
|
-
- 2.4
|
11
|
-
- 2.5
|
12
|
-
- 2.6
|
13
|
-
|
14
|
-
before_install:
|
15
|
-
- gem update bundler
|
16
|
-
|
17
|
-
install:
|
18
|
-
- bundle install --jobs=3 --retry=3
|
19
|
-
- gem install rubocop
|
20
|
-
|
21
|
-
before_script:
|
22
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
23
|
-
- chmod +x ./cc-test-reporter
|
24
|
-
- ./cc-test-reporter before-build
|
25
|
-
|
26
|
-
script:
|
27
|
-
- rubocop
|
28
|
-
- bundle exec rake
|
29
|
-
|
30
|
-
after_script:
|
31
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|