This commit is contained in:
@@ -19,28 +19,28 @@ module NostrManager
|
||||
|
||||
thread = Thread.new do
|
||||
client.on :connect do
|
||||
puts "#{log_prefix} Publishing #{event.id}..."
|
||||
Rails.logger.debug "#{log_prefix} Publishing #{event.id}..."
|
||||
client.publish event
|
||||
end
|
||||
|
||||
client.on :error do |e|
|
||||
puts "#{log_prefix} Error: #{e}"
|
||||
puts "#{log_prefix} Closing thread..."
|
||||
Rails.logger.debug "#{log_prefix} Error: #{e}"
|
||||
Rails.logger.debug "#{log_prefix} Closing thread..."
|
||||
thread.exit
|
||||
end
|
||||
|
||||
client.on :message do |m|
|
||||
puts "#{log_prefix} Message: #{m}"
|
||||
Rails.logger.debug "#{log_prefix} Message: #{m}"
|
||||
msg = JSON.parse(m) rescue []
|
||||
if msg[0] == "OK" && msg[1] == event.id && msg[2]
|
||||
puts "#{log_prefix} Event published. Closing thread..."
|
||||
Rails.logger.debug "#{log_prefix} Event published. Closing thread..."
|
||||
else
|
||||
puts "#{log_prefix} Unexpected message from relay. Closing thread..."
|
||||
Rails.logger.debug "#{log_prefix} Unexpected message from relay. Closing thread..."
|
||||
end
|
||||
thread.exit
|
||||
end
|
||||
|
||||
puts "#{log_prefix} Connecting to #{relay.url}..."
|
||||
Rails.logger.debug "#{log_prefix} Connecting to #{relay.url}..."
|
||||
client.connect relay
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user