Skip to content

Unique message id #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/xmpp_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'forwardable'
require 'singleton'
require 'ap'
require 'securerandom'

class Bot
include Jabber
Expand Down Expand Up @@ -226,7 +227,7 @@ def client
end

def deliver jid, message_text, message_type = :chat
message = Message.new(jid, message_text)
message = Message.new(jid, message_text).set_id(SecureRandom.uuid)
message.type = message_type
client.tap {|client|
client.send(message) unless client.nil?
Copy link
Contributor

@cmrd-senya cmrd-senya Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that instead of explicitly setting the id we should use Jabber::Client#send_with_id method here, because it's better to rely on gem-provided methods when they are available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send_with_id method does not generate a unique id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It relies on IdGenerator.generate_id where the documentation literally says

Generate an unique ID.

If there is something wrong with uniqueness there, maybe you can consider to make a PR for the xmpp4r gem?

Expand Down