mixin_bot 1.3.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 436b9a0d785744f840ab00dbb6643a372fcba52a1a2091c8c86f9fd1e0c08b30
4
- data.tar.gz: 895cd928e05c763ef9452ab564ceb357a1c512f52ce7b57ca69b7067380d7233
3
+ metadata.gz: 73565cefb791be042d4130d44248e575b30cac2b00d032508e6d2a215d02c845
4
+ data.tar.gz: 521142f48775c4eb1166c4ccb22fe974bf91adab0c3a1b900980660b440d9606
5
5
  SHA512:
6
- metadata.gz: c9d2183496bde43efaed75052508ad9791bcf5c3842709a764bac499815d817a8b3222a602ba0f6140b624855aaf3c88f08e945cb19e6ede0f290b2c308edb57
7
- data.tar.gz: c085749d2fc91b1aa9104d48e46eb1cfd4a765b18c8c7095e71f11b714d8572dff05f03e69f51e5a67d3f196ca6cc8b0c49ee63db76452940a2d1f9ccd9f4c0c
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] || SecureRandom.uuid,
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:, conversation_id: nil, access_token: nil)
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
- access_token:
39
+ random_id:,
40
+ access_token: kwargs[:access_token]
35
41
  )
36
42
  end
37
43
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '1.3.1'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee