discourse_api 0.31.0 → 0.32.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 +4 -0
- data/examples/group_set_user_notification_level.rb +37 -0
- data/lib/discourse_api/api/groups.rb +5 -0
- data/lib/discourse_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d1ed5b5061991f2bad549f4edfe32a6000700848241c3dd31e72b770c4f3cc1
|
4
|
+
data.tar.gz: 1375bd4604231e28b361dc5f326574a4cd1f4c68a3af5b34252aeddf5b6b0f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc9b153b80fb9dc4d49c1a7330f6b0ac84b055d6456f9e74fb665c538e11fc33c7264900533aeaa43f1f3732e311dfaafd7076c03f459f1d439b894a2473900
|
7
|
+
data.tar.gz: 1a03023036d5d74693ef9fee74774b92a5d4c4b630dc7761dea0a9bde6cdfc88103585da1dc68873f5a25440931d666b7648bd5ac18c4838f4d496e8ca133536
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.32.0] - 2019-02-13
|
6
|
+
### Added
|
7
|
+
- Added a new method to update a users notification level in a group
|
8
|
+
|
5
9
|
## [0.31.0] - 2019-02-07
|
6
10
|
### Added
|
7
11
|
- Added `deactivate` method
|
@@ -0,0 +1,37 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require File.expand_path('../../lib/discourse_api', __FILE__)
|
3
|
+
|
4
|
+
client = DiscourseApi::Client.new("http://localhost:3000")
|
5
|
+
client.api_key = "YOUR_API_KEY"
|
6
|
+
client.api_username = "YOUR_USERNAME"
|
7
|
+
|
8
|
+
@target_username = "YOUR_TARGET_USERNAME"
|
9
|
+
@target_group_id = # YOUR NUMERIC TARGET GROUP ID
|
10
|
+
|
11
|
+
@user = client.user(@target_username)
|
12
|
+
|
13
|
+
# each user's group and the group's default notification level are stored under user['groups']
|
14
|
+
@user['groups'].each do |group|
|
15
|
+
if group['id'] == @target_group_id
|
16
|
+
@group_name = group['name']
|
17
|
+
@default_level = group['default_notification_level']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# and the user's notification setting for each group is stored under user['group_users]
|
22
|
+
@user['group_users'].each do |users_group|
|
23
|
+
if users_group['group_id'] == @target_group_id
|
24
|
+
@notification_level = users_group['notification_level']
|
25
|
+
puts "Group ID:#{@target_group_id} #{@group_name} Current Notification Level: #{@notification_level} Default: #{@default_level}"
|
26
|
+
response = client.group_set_user_notification_level(@group_name, @user['id'], @default_level)
|
27
|
+
puts response
|
28
|
+
@users_group_users_after_update = client.user(@target_username)['group_users']
|
29
|
+
# this just pulls the user from the database again to make sure we updated the user's group notification level
|
30
|
+
@users_group_users_after_update.each do |users_group_second_pass|
|
31
|
+
if users_group_second_pass['group_id'] == @target_group_id
|
32
|
+
puts "Updated ID:#{@target_group_id} #{@group_name} Notification Level: #{users_group_second_pass['notification_level']} Default: #{@default_level}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -113,6 +113,11 @@ module DiscourseApi
|
|
113
113
|
response = get("/groups/#{group_name}/members.json", params)
|
114
114
|
response.body['members']
|
115
115
|
end
|
116
|
+
|
117
|
+
def group_set_user_notification_level(group, user_id, notification_level)
|
118
|
+
response = post("/groups/#{group}/notifications?user_id=#{user_id}¬ification_level=#{notification_level}")
|
119
|
+
response
|
120
|
+
end
|
116
121
|
end
|
117
122
|
end
|
118
123
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-02-
|
14
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- examples/dashboard.rb
|
198
198
|
- examples/disposable_invite_tokens.rb
|
199
199
|
- examples/example.rb
|
200
|
+
- examples/group_set_user_notification_level.rb
|
200
201
|
- examples/groups.rb
|
201
202
|
- examples/invite_users.rb
|
202
203
|
- examples/post_action.rb
|