citadel-ruby-client 0.2.4 → 0.2.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 213ec157a282e48f010274dc726ea9a3f1b5549e
|
4
|
+
data.tar.gz: 331f77a434f450bae64535b661813706b7b172fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e03656e5bb831d7f1596169ee9e08f6047c8ad421865c3330bc024e9f20e87a6f7450fd6f838d8d8a8f317f861a628260fdeb6270d035ba7e987e865d8acbc8
|
7
|
+
data.tar.gz: baee4d3e33432ae453baf035c1ff2791d95e8b3b6597696d4ffc4a8b915f5f49ed55c8b25c8befe8b65f87b4d4f3e30ef1cf1a35d63ee1e8fb3274787aac925e
|
data/lib/citadel-ruby-client.rb
CHANGED
@@ -7,7 +7,6 @@ require 'citadel-ruby-client/matrix_paths'
|
|
7
7
|
require 'citadel-ruby-client/matrix_interceptor'
|
8
8
|
|
9
9
|
module Citadel
|
10
|
-
|
11
10
|
DEFAULT_PUBLIC_ROOMS_LIMIT = 100
|
12
11
|
|
13
12
|
class << self
|
@@ -16,11 +15,11 @@ module Citadel
|
|
16
15
|
|
17
16
|
class Client
|
18
17
|
def initialize(tenant_url, public_rooms_limit = DEFAULT_PUBLIC_ROOMS_LIMIT)
|
19
|
-
if tenant_url[-1,1] == '/'
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
Citadel.tenant_url = if tenant_url[-1, 1] == '/'
|
19
|
+
tenant_url[0, tenant_url.length - 1]
|
20
|
+
else
|
21
|
+
tenant_url
|
22
|
+
end
|
24
23
|
Citadel.public_rooms_limit = public_rooms_limit
|
25
24
|
end
|
26
25
|
|
@@ -30,8 +29,9 @@ module Citadel
|
|
30
29
|
|
31
30
|
def auth_token
|
32
31
|
return @auth_token if defined? @auth_token
|
32
|
+
|
33
33
|
puts 'Citadel: You need to sign in'
|
34
|
-
|
34
|
+
nil
|
35
35
|
end
|
36
36
|
|
37
37
|
def sign_in(login, password)
|
@@ -78,13 +78,13 @@ module Citadel
|
|
78
78
|
def create_room(room_name, topic)
|
79
79
|
matrix_paths = MatrixPaths.new
|
80
80
|
url = matrix_paths.base_uri + matrix_paths.create_room_path
|
81
|
-
room_name_alias = room_name.
|
81
|
+
room_name_alias = room_name.tr!(' ', '_')
|
82
82
|
data_hash = { creation_content: { 'm.federate': false },
|
83
83
|
name: room_name,
|
84
84
|
preset: 'public_chat',
|
85
85
|
visibility: 'public',
|
86
86
|
room_alias_name: room_name_alias,
|
87
|
-
topic: topic}
|
87
|
+
topic: topic }
|
88
88
|
data = JSON.generate data_hash
|
89
89
|
|
90
90
|
response = HTTP.auth(auth_token).post(url, body: data)
|
@@ -102,7 +102,6 @@ module Citadel
|
|
102
102
|
########
|
103
103
|
|
104
104
|
def send_message(room_id, message)
|
105
|
-
|
106
105
|
matrix_paths = MatrixPaths.new
|
107
106
|
randomizer = Random.new
|
108
107
|
txn = randomizer.rand(100)
|
@@ -130,7 +129,6 @@ module Citadel
|
|
130
129
|
end
|
131
130
|
|
132
131
|
def invite_in_room(room_id, user_id)
|
133
|
-
|
134
132
|
matrix_paths = MatrixPaths.new
|
135
133
|
url = matrix_paths.base_uri + matrix_paths.invite_in_room_path(room_id)
|
136
134
|
data_hash = { user_id: user_id }
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Citadel
|
4
4
|
class MatrixPaths
|
5
|
-
|
6
5
|
def base_uri
|
7
6
|
Citadel.tenant_url + '/_matrix/client/r0'
|
8
7
|
end
|
@@ -24,7 +23,7 @@ module Citadel
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def list_public_rooms_path
|
27
|
-
'/publicRooms' + '?limit=' + Citadel.public_rooms_limit
|
26
|
+
'/publicRooms' + '?limit=' + Citadel.public_rooms_limit.to_s
|
28
27
|
end
|
29
28
|
|
30
29
|
def list_joined_rooms_path
|