mixin_bot 1.3.0 → 1.4.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/lib/mixin_bot/api/conversation.rb +10 -4
- data/lib/mixin_bot/api/message.rb +4 -1
- data/lib/mixin_bot/utils/crypto.rb +18 -0
- data/lib/mixin_bot/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73565cefb791be042d4130d44248e575b30cac2b00d032508e6d2a215d02c845
|
4
|
+
data.tar.gz: 521142f48775c4eb1166c4ccb22fe974bf91adab0c3a1b900980660b440d9606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d2729f574eca707316ea7bc05989a5f4fe411c562a81bdbf88a46b2dec855cf9f4701c33ce17016ac034ef490c42a01bddc3f9d7f3e819254fc228dc0b7b09
|
7
|
+
data.tar.gz: 9a45a5441a0859dc404011788a5fac8afced8f7c1d0e9db100fe404abe05258f7364539b1417f6360367a65e861340b9b16223c7d63bb65d1e831877f0997f35
|
@@ -16,22 +16,28 @@ module MixinBot
|
|
16
16
|
def create_conversation(**kwargs)
|
17
17
|
path = '/conversations'
|
18
18
|
payload = {
|
19
|
+
announcement: kwargs[:announcement],
|
19
20
|
category: kwargs[:category],
|
20
|
-
conversation_id: kwargs[:conversation_id]
|
21
|
+
conversation_id: kwargs[:conversation_id],
|
21
22
|
name: kwargs[:name],
|
22
|
-
participants: kwargs[:participants]
|
23
|
+
participants: kwargs[:participants],
|
24
|
+
random_id: kwargs[:random_id]
|
23
25
|
}.compact_blank
|
24
26
|
|
25
27
|
client.post path, **payload, access_token: kwargs[:access_token]
|
26
28
|
end
|
27
29
|
|
28
|
-
def create_group_conversation(user_ids:, name:,
|
30
|
+
def create_group_conversation(user_ids:, name:, **kwargs)
|
31
|
+
random_id = kwargs[:random_id] || SecureRandom.uuid
|
32
|
+
conversation_id = kwargs[:conversation_id] || MixinBot.utils.generate_group_conversation_id(user_ids:, name:, owner_id: config.app_id, random_id:)
|
29
33
|
create_conversation(
|
34
|
+
announcement: kwargs[:announcement],
|
30
35
|
category: 'GROUP',
|
31
36
|
conversation_id:,
|
32
37
|
name:,
|
33
38
|
participants: user_ids.map(&->(participant) { { user_id: participant } }),
|
34
|
-
|
39
|
+
random_id:,
|
40
|
+
access_token: kwargs[:access_token]
|
35
41
|
)
|
36
42
|
end
|
37
43
|
|
@@ -95,7 +95,10 @@ module MixinBot
|
|
95
95
|
|
96
96
|
# read the gzipped message form websocket
|
97
97
|
def ws_message(data)
|
98
|
-
|
98
|
+
data = data.pack('c*') if data.is_a?(Array)
|
99
|
+
raise MixinBot::ArgumentError, 'data should be String or Array of integer' unless data.is_a?(String)
|
100
|
+
|
101
|
+
io = StringIO.new(data, 'rb')
|
99
102
|
gzip = Zlib::GzipReader.new io
|
100
103
|
msg = gzip.read
|
101
104
|
gzip.close
|
@@ -111,6 +111,24 @@ module MixinBot
|
|
111
111
|
r
|
112
112
|
end
|
113
113
|
|
114
|
+
def generate_group_conversation_id(user_ids:, name:, owner_id:, random_id: nil)
|
115
|
+
random_id ||= SecureRandom.uuid
|
116
|
+
|
117
|
+
# Start with owner_id and group name
|
118
|
+
gid = unique_uuid(owner_id, name)
|
119
|
+
|
120
|
+
# Combine with random_id
|
121
|
+
gid = unique_uuid(gid, random_id)
|
122
|
+
|
123
|
+
# Sort participants and combine with each one
|
124
|
+
sorted_participants = user_ids.sort
|
125
|
+
sorted_participants.each do |participant|
|
126
|
+
gid = unique_uuid(gid, participant)
|
127
|
+
end
|
128
|
+
|
129
|
+
gid
|
130
|
+
end
|
131
|
+
|
114
132
|
def generate_trace_from_hash(hash, output_index = 0)
|
115
133
|
md5 = Digest::MD5.new
|
116
134
|
md5 << hash
|
data/lib/mixin_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -308,7 +307,6 @@ licenses:
|
|
308
307
|
- MIT
|
309
308
|
metadata:
|
310
309
|
rubygems_mfa_required: 'true'
|
311
|
-
post_install_message:
|
312
310
|
rdoc_options: []
|
313
311
|
require_paths:
|
314
312
|
- lib
|
@@ -323,8 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
321
|
- !ruby/object:Gem::Version
|
324
322
|
version: '0'
|
325
323
|
requirements: []
|
326
|
-
rubygems_version: 3.
|
327
|
-
signing_key:
|
324
|
+
rubygems_version: 3.6.9
|
328
325
|
specification_version: 4
|
329
326
|
summary: A Ruby SDK for Mixin Nexwork
|
330
327
|
test_files: []
|