simplex-chat 0.3.0 → 0.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/simplex-chat/errors.rb +20 -0
 - data/lib/simplex-chat/patches.rb +17 -0
 - data/lib/simplex-chat/types.rb +17 -0
 - data/lib/simplex-chat/version.rb +1 -1
 - data/lib/simplex-chat.rb +58 -44
 - metadata +5 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cb15441c1b0a770fff253bb8eddbacf6bf52df1ddcddd502597ada7385a62c1c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0ba06bf88529d8bbd2eb429fd781162c94a23bfe7577ea313ef9ca8db346c407
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e975110a2bfa186b9f1f9f80264fa0343bc6e148e113a4eaf0d778064abbdeb54e822725e51ca499700f4e2a855fa41a8a06aa532b5561ecc33e75795528adcc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b681e83e16e20ad1e55f0c16918a5fe438703bd98c29e1f6a4cca2e24af19e3a352162a9bb2dab673f927974b222715fe431cf7d521ff0848431631846fe5d66
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SimpleXChat
         
     | 
| 
      
 4 
     | 
    
         
            +
              # All SimpleX-related errors will inherit from GenericError
         
     | 
| 
      
 5 
     | 
    
         
            +
              # These errors should be recoverable
         
     | 
| 
      
 6 
     | 
    
         
            +
              class GenericError < StandardError
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              class SendCommandError < GenericError
         
     | 
| 
      
 10 
     | 
    
         
            +
                def initialize(cmd)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  super "Failed to send command: #{cmd}"
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              class UnexpectedResponseError < GenericError
         
     | 
| 
      
 16 
     | 
    
         
            +
                def initialize(type, expected_type)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  super "Unexpected response type: #{type} (expected: #{expected_type})"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SimpleXChat
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'net/http'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              # Fixes regex match for status line in HTTPResponse
         
     | 
| 
      
 7 
     | 
    
         
            +
              class HTTPResponse < Net::HTTPResponse
         
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def read_status_line(sock)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    str = sock.readline
         
     | 
| 
      
 11 
     | 
    
         
            +
                    m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\Z/in.match(str) or
         
     | 
| 
      
 12 
     | 
    
         
            +
                      raise Net::HTTPBadResponse, "wrong status line: #{str.dump}"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    m.captures
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SimpleXChat
         
     | 
| 
      
 4 
     | 
    
         
            +
              module ChatType
         
     | 
| 
      
 5 
     | 
    
         
            +
                DIRECT = '@'
         
     | 
| 
      
 6 
     | 
    
         
            +
                GROUP = '#'
         
     | 
| 
      
 7 
     | 
    
         
            +
                CONTACT_REQUEST = '<@'
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              module GroupMemberRole
         
     | 
| 
      
 11 
     | 
    
         
            +
                AUTHOR = 'author' # reserved and unused as of now, but added anyways
         
     | 
| 
      
 12 
     | 
    
         
            +
                OWNER = 'owner'
         
     | 
| 
      
 13 
     | 
    
         
            +
                ADMIN = 'admin'
         
     | 
| 
      
 14 
     | 
    
         
            +
                MEMBER = 'member'
         
     | 
| 
      
 15 
     | 
    
         
            +
                OBSERVER = 'observer'
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/simplex-chat/version.rb
    CHANGED
    
    
    
        data/lib/simplex-chat.rb
    CHANGED
    
    | 
         @@ -1,6 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'simplex-chat/version'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'simplex-chat/errors'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'simplex-chat/patches'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require_relative 'simplex-chat/types'
         
     | 
| 
       4 
7 
     | 
    
         | 
| 
       5 
8 
     | 
    
         
             
            module SimpleXChat
         
     | 
| 
       6 
9 
     | 
    
         
             
              require 'net/http'
         
     | 
| 
         @@ -10,36 +13,10 @@ module SimpleXChat 
     | 
|
| 
       10 
13 
     | 
    
         
             
              require 'concurrent'
         
     | 
| 
       11 
14 
     | 
    
         
             
              require 'time'
         
     | 
| 
       12 
15 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
              # Fixes regex match for status line in HTTPResponse
         
     | 
| 
       14 
     | 
    
         
            -
              class HTTPResponse < Net::HTTPResponse
         
     | 
| 
       15 
     | 
    
         
            -
                class << self
         
     | 
| 
       16 
     | 
    
         
            -
                  def read_status_line(sock)
         
     | 
| 
       17 
     | 
    
         
            -
                    str = sock.readline
         
     | 
| 
       18 
     | 
    
         
            -
                    m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\Z/in.match(str) or
         
     | 
| 
       19 
     | 
    
         
            -
                      raise Net::HTTPBadResponse, "wrong status line: #{str.dump}"
         
     | 
| 
       20 
     | 
    
         
            -
                    m.captures
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
              module ChatType
         
     | 
| 
       26 
     | 
    
         
            -
                DIRECT = '@'
         
     | 
| 
       27 
     | 
    
         
            -
                GROUP = '#'
         
     | 
| 
       28 
     | 
    
         
            -
                CONTACT_REQUEST = '<@'
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              module GroupMemberRole
         
     | 
| 
       32 
     | 
    
         
            -
                AUTHOR = 'author' # reserved and unused as of now, but added anyways
         
     | 
| 
       33 
     | 
    
         
            -
                OWNER = 'owner'
         
     | 
| 
       34 
     | 
    
         
            -
                ADMIN = 'admin'
         
     | 
| 
       35 
     | 
    
         
            -
                MEMBER = 'member'
         
     | 
| 
       36 
     | 
    
         
            -
                OBSERVER = 'observer'
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
16 
     | 
    
         
             
              class ClientAgent
         
     | 
| 
       40 
17 
     | 
    
         
             
                attr_accessor :on_message
         
     | 
| 
       41 
18 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
                def initialize 
     | 
| 
      
 19 
     | 
    
         
            +
                def initialize(client_uri, connect: true, log_level: Logger::INFO, timeout_ms: 10_000, interval_ms: 100)
         
     | 
| 
       43 
20 
     | 
    
         
             
                  @uri = client_uri
         
     | 
| 
       44 
21 
     | 
    
         
             
                  @message_queue = SizedQueue.new 4096
         
     | 
| 
       45 
22 
     | 
    
         
             
                  @chat_message_queue = Queue.new
         
     | 
| 
         @@ -87,6 +64,7 @@ module SimpleXChat 
     | 
|
| 
       87 
64 
     | 
    
         | 
| 
       88 
65 
     | 
    
         
             
                        msg = JSON.parse obj.to_s
         
     | 
| 
       89 
66 
     | 
    
         
             
                        # @logger.debug("New message: #{msg}")
         
     | 
| 
      
 67 
     | 
    
         
            +
                        # @logger.debug("Command waiters: #{@command_waiters}")
         
     | 
| 
       90 
68 
     | 
    
         | 
| 
       91 
69 
     | 
    
         
             
                        corr_id = msg["corrId"]
         
     | 
| 
       92 
70 
     | 
    
         
             
                        resp = msg["resp"]
         
     | 
| 
         @@ -96,6 +74,7 @@ module SimpleXChat 
     | 
|
| 
       96 
74 
     | 
    
         
             
                          single_use_queue.push(resp)
         
     | 
| 
       97 
75 
     | 
    
         
             
                          @logger.debug("Message sent to waiter with corrId '#{corr_id}'")
         
     | 
| 
       98 
76 
     | 
    
         
             
                        else
         
     | 
| 
      
 77 
     | 
    
         
            +
                          @logger.debug("Message put on message queue")
         
     | 
| 
       99 
78 
     | 
    
         
             
                          @message_queue.push resp
         
     | 
| 
       100 
79 
     | 
    
         
             
                        end
         
     | 
| 
       101 
80 
     | 
    
         
             
                      rescue IO::WaitReadable
         
     | 
| 
         @@ -168,6 +147,7 @@ module SimpleXChat 
     | 
|
| 
       168 
147 
     | 
    
         | 
| 
       169 
148 
     | 
    
         
             
                      msg_text = chat_item["chatItem"]["meta"]["itemText"]
         
     | 
| 
       170 
149 
     | 
    
         
             
                      timestamp = chat_item["chatItem"]["meta"]["updatedAt"]
         
     | 
| 
      
 150 
     | 
    
         
            +
                      image_preview = chat_item.dig "chatItem", "content", "msgContent", "image"
         
     | 
| 
       171 
151 
     | 
    
         | 
| 
       172 
152 
     | 
    
         
             
                      chat_message = {
         
     | 
| 
       173 
153 
     | 
    
         
             
                        :chat_type => chat_type,
         
     | 
| 
         @@ -176,7 +156,8 @@ module SimpleXChat 
     | 
|
| 
       176 
156 
     | 
    
         
             
                        :contact => contact,
         
     | 
| 
       177 
157 
     | 
    
         
             
                        :group => group,
         
     | 
| 
       178 
158 
     | 
    
         
             
                        :msg_text => msg_text,
         
     | 
| 
       179 
     | 
    
         
            -
                        :msg_timestamp => Time.parse(timestamp)
         
     | 
| 
      
 159 
     | 
    
         
            +
                        :msg_timestamp => Time.parse(timestamp),
         
     | 
| 
      
 160 
     | 
    
         
            +
                        :img_preview => image_preview
         
     | 
| 
       180 
161 
     | 
    
         
             
                      }
         
     | 
| 
       181 
162 
     | 
    
         | 
| 
       182 
163 
     | 
    
         
             
                      @chat_message_queue.push chat_message
         
     | 
| 
         @@ -212,9 +193,12 @@ module SimpleXChat 
     | 
|
| 
       212 
193 
     | 
    
         
             
                  # command response
         
     | 
| 
       213 
194 
     | 
    
         
             
                  single_use_queue = SizedQueue.new 1
         
     | 
| 
       214 
195 
     | 
    
         
             
                  @command_waiters[corr_id] = single_use_queue
         
     | 
| 
      
 196 
     | 
    
         
            +
                  @logger.debug("Created command waiter for command ##{corr_id}")
         
     | 
| 
       215 
197 
     | 
    
         | 
| 
      
 198 
     | 
    
         
            +
                  @logger.debug("Sending command ##{corr_id}: #{json.to_s}")
         
     | 
| 
       216 
199 
     | 
    
         
             
                  @socket.write frame.to_s
         
     | 
| 
       217 
200 
     | 
    
         | 
| 
      
 201 
     | 
    
         
            +
                  @logger.debug("Waiting response for command ##{corr_id}...")
         
     | 
| 
       218 
202 
     | 
    
         
             
                  msg = nil
         
     | 
| 
       219 
203 
     | 
    
         
             
                  iterations = timeout_ms / interval_ms
         
     | 
| 
       220 
204 
     | 
    
         
             
                  iterations.times do
         
     | 
| 
         @@ -223,23 +207,26 @@ module SimpleXChat 
     | 
|
| 
       223 
207 
     | 
    
         
             
                      break
         
     | 
| 
       224 
208 
     | 
    
         
             
                    rescue ThreadError
         
     | 
| 
       225 
209 
     | 
    
         
             
                      sleep(interval_ms / 1000.0)
         
     | 
| 
       226 
     | 
    
         
            -
                    ensure
         
     | 
| 
       227 
     | 
    
         
            -
                      # Clean up command_waiters
         
     | 
| 
       228 
     | 
    
         
            -
                      @command_waiters.delete corr_id
         
     | 
| 
       229 
210 
     | 
    
         
             
                    end
         
     | 
| 
       230 
211 
     | 
    
         
             
                  end
         
     | 
| 
       231 
212 
     | 
    
         | 
| 
       232 
213 
     | 
    
         
             
                  if msg == nil
         
     | 
| 
       233 
     | 
    
         
            -
                    raise  
     | 
| 
      
 214 
     | 
    
         
            +
                    raise SendCommandError.new(json.to_s)
         
     | 
| 
       234 
215 
     | 
    
         
             
                  end
         
     | 
| 
       235 
216 
     | 
    
         | 
| 
      
 217 
     | 
    
         
            +
                  @logger.debug("Command ##{corr_id} finished successfully with response: #{msg}")
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
       236 
219 
     | 
    
         
             
                  msg
         
     | 
| 
      
 220 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 221 
     | 
    
         
            +
                  @command_waiters.delete corr_id
         
     | 
| 
      
 222 
     | 
    
         
            +
                  @logger.debug("Cleaned up command waiter ##{corr_id}")
         
     | 
| 
       237 
223 
     | 
    
         
             
                end
         
     | 
| 
       238 
224 
     | 
    
         | 
| 
       239 
225 
     | 
    
         
             
                def api_version
         
     | 
| 
       240 
226 
     | 
    
         
             
                  resp = send_command '/version'
         
     | 
| 
       241 
227 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       242 
     | 
    
         
            -
                   
     | 
| 
      
 228 
     | 
    
         
            +
                  expected_resp_type = "versionInfo"
         
     | 
| 
      
 229 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       243 
230 
     | 
    
         | 
| 
       244 
231 
     | 
    
         
             
                  resp["versionInfo"]["version"]
         
     | 
| 
       245 
232 
     | 
    
         
             
                end
         
     | 
| 
         @@ -247,7 +234,8 @@ module SimpleXChat 
     | 
|
| 
       247 
234 
     | 
    
         
             
                def api_profile
         
     | 
| 
       248 
235 
     | 
    
         
             
                  resp = send_command '/profile'
         
     | 
| 
       249 
236 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       250 
     | 
    
         
            -
                   
     | 
| 
      
 237 
     | 
    
         
            +
                  expected_resp_type = "userProfile"
         
     | 
| 
      
 238 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       251 
239 
     | 
    
         | 
| 
       252 
240 
     | 
    
         
             
                  {
         
     | 
| 
       253 
241 
     | 
    
         
             
                    "name" => resp["user"]["profile"]["displayName"],
         
     | 
| 
         @@ -264,7 +252,8 @@ module SimpleXChat 
     | 
|
| 
       264 
252 
     | 
    
         
             
                    return nil
         
     | 
| 
       265 
253 
     | 
    
         
             
                  end
         
     | 
| 
       266 
254 
     | 
    
         | 
| 
       267 
     | 
    
         
            -
                   
     | 
| 
      
 255 
     | 
    
         
            +
                  expected_resp_type = "userContactLink"
         
     | 
| 
      
 256 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       268 
257 
     | 
    
         | 
| 
       269 
258 
     | 
    
         
             
                  resp["contactLink"]["connReqContact"]
         
     | 
| 
       270 
259 
     | 
    
         
             
                end
         
     | 
| 
         @@ -272,15 +261,35 @@ module SimpleXChat 
     | 
|
| 
       272 
261 
     | 
    
         
             
                def api_create_user_address
         
     | 
| 
       273 
262 
     | 
    
         
             
                  resp = send_command '/address'
         
     | 
| 
       274 
263 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       275 
     | 
    
         
            -
                   
     | 
| 
      
 264 
     | 
    
         
            +
                  expected_resp_type = "userContactLinkCreated"
         
     | 
| 
      
 265 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       276 
266 
     | 
    
         | 
| 
       277 
267 
     | 
    
         
             
                  resp["connReqContact"]
         
     | 
| 
       278 
268 
     | 
    
         
             
                end
         
     | 
| 
       279 
269 
     | 
    
         | 
| 
       280 
     | 
    
         
            -
                def api_send_text_message(chat_type,  
     | 
| 
       281 
     | 
    
         
            -
                  resp = send_command "#{chat_type}#{ 
     | 
| 
      
 270 
     | 
    
         
            +
                def api_send_text_message(chat_type, receiver, message)
         
     | 
| 
      
 271 
     | 
    
         
            +
                  resp = send_command "#{chat_type}#{receiver} #{message}"
         
     | 
| 
      
 272 
     | 
    
         
            +
                  resp_type = resp["type"]
         
     | 
| 
      
 273 
     | 
    
         
            +
                  expected_resp_type = "newChatItems"
         
     | 
| 
      
 274 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
                  resp["chatItems"]
         
     | 
| 
      
 277 
     | 
    
         
            +
                end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                def api_send_image(chat_type, receiver, file_path)
         
     | 
| 
      
 280 
     | 
    
         
            +
                  resp = send_command "/image #{chat_type}#{receiver} #{file_path}"
         
     | 
| 
      
 281 
     | 
    
         
            +
                  resp_type = resp["type"]
         
     | 
| 
      
 282 
     | 
    
         
            +
                  expected_resp_type = "newChatItems"
         
     | 
| 
      
 283 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
      
 284 
     | 
    
         
            +
             
     | 
| 
      
 285 
     | 
    
         
            +
                  resp["chatItems"]
         
     | 
| 
      
 286 
     | 
    
         
            +
                end
         
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
      
 288 
     | 
    
         
            +
                def api_send_file(chat_type, receiver, file_path)
         
     | 
| 
      
 289 
     | 
    
         
            +
                  resp = send_command "/file #{chat_type}#{receiver} #{file_path}"
         
     | 
| 
       282 
290 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       283 
     | 
    
         
            -
                   
     | 
| 
      
 291 
     | 
    
         
            +
                  expected_resp_type = "newChatItems"
         
     | 
| 
      
 292 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       284 
293 
     | 
    
         | 
| 
       285 
294 
     | 
    
         
             
                  resp["chatItems"]
         
     | 
| 
       286 
295 
     | 
    
         
             
                end
         
     | 
| 
         @@ -288,7 +297,8 @@ module SimpleXChat 
     | 
|
| 
       288 
297 
     | 
    
         
             
                def api_contacts
         
     | 
| 
       289 
298 
     | 
    
         
             
                  resp = send_command "/contacts"
         
     | 
| 
       290 
299 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       291 
     | 
    
         
            -
                   
     | 
| 
      
 300 
     | 
    
         
            +
                  expected_resp_type = "contactsList"
         
     | 
| 
      
 301 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       292 
302 
     | 
    
         | 
| 
       293 
303 
     | 
    
         
             
                  contacts = resp["contacts"]
         
     | 
| 
       294 
304 
     | 
    
         
             
                  contacts.map{ |c| {
         
     | 
| 
         @@ -304,7 +314,8 @@ module SimpleXChat 
     | 
|
| 
       304 
314 
     | 
    
         
             
                def api_groups
         
     | 
| 
       305 
315 
     | 
    
         
             
                  resp = send_command "/groups"
         
     | 
| 
       306 
316 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       307 
     | 
    
         
            -
                   
     | 
| 
      
 317 
     | 
    
         
            +
                  expected_resp_type = "groupsList"
         
     | 
| 
      
 318 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       308 
319 
     | 
    
         | 
| 
       309 
320 
     | 
    
         
             
                  groups = resp["groups"]
         
     | 
| 
       310 
321 
     | 
    
         
             
                  groups.map{ |entry| 
         
     | 
| 
         @@ -331,7 +342,8 @@ module SimpleXChat 
     | 
|
| 
       331 
342 
     | 
    
         | 
| 
       332 
343 
     | 
    
         
             
                  resp = send_command "/auto_accept #{onoff}"
         
     | 
| 
       333 
344 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       334 
     | 
    
         
            -
                   
     | 
| 
      
 345 
     | 
    
         
            +
                  expected_resp_type = "userContactLinkUpdated"
         
     | 
| 
      
 346 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       335 
347 
     | 
    
         | 
| 
       336 
348 
     | 
    
         
             
                  nil
         
     | 
| 
       337 
349 
     | 
    
         
             
                end
         
     | 
| 
         @@ -339,7 +351,8 @@ module SimpleXChat 
     | 
|
| 
       339 
351 
     | 
    
         
             
                def api_kick_group_member(group, member)
         
     | 
| 
       340 
352 
     | 
    
         
             
                  resp = send_command "/remove #{group} #{member}"
         
     | 
| 
       341 
353 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       342 
     | 
    
         
            -
                   
     | 
| 
      
 354 
     | 
    
         
            +
                  expected_resp_type = "userDeletedMember"
         
     | 
| 
      
 355 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       343 
356 
     | 
    
         
             
                end
         
     | 
| 
       344 
357 
     | 
    
         | 
| 
       345 
358 
     | 
    
         
             
                # Parameters for /network:
         
     | 
| 
         @@ -363,7 +376,8 @@ module SimpleXChat 
     | 
|
| 
       363 
376 
     | 
    
         
             
                  end
         
     | 
| 
       364 
377 
     | 
    
         
             
                  resp = send_command command
         
     | 
| 
       365 
378 
     | 
    
         
             
                  resp_type = resp["type"]
         
     | 
| 
       366 
     | 
    
         
            -
                   
     | 
| 
      
 379 
     | 
    
         
            +
                  expected_resp_type = "networkConfig"
         
     | 
| 
      
 380 
     | 
    
         
            +
                  raise UnexpectedResponseError.new(resp_type, expected_resp_type) unless resp_type == expected_resp_type
         
     | 
| 
       367 
381 
     | 
    
         | 
| 
       368 
382 
     | 
    
         
             
                  resp["networkConfig"]
         
     | 
| 
       369 
383 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: simplex-chat
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - rdbo
         
     | 
| 
       8 
8 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       9 
9 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       10 
     | 
    
         
            -
            date: 2025-03- 
     | 
| 
      
 10 
     | 
    
         
            +
            date: 2025-03-03 00:00:00.000000000 Z
         
     | 
| 
       11 
11 
     | 
    
         
             
            dependencies:
         
     | 
| 
       12 
12 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       13 
13 
     | 
    
         
             
              name: websocket
         
     | 
| 
         @@ -48,6 +48,9 @@ files: 
     | 
|
| 
       48 
48 
     | 
    
         
             
            - README.md
         
     | 
| 
       49 
49 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       50 
50 
     | 
    
         
             
            - lib/simplex-chat.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - lib/simplex-chat/errors.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/simplex-chat/patches.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/simplex-chat/types.rb
         
     | 
| 
       51 
54 
     | 
    
         
             
            - lib/simplex-chat/version.rb
         
     | 
| 
       52 
55 
     | 
    
         
             
            - showcase.png
         
     | 
| 
       53 
56 
     | 
    
         
             
            homepage: https://github.com/rdbo/simplex-chat-ruby
         
     |