lib/dispatch-rider/publisher.rb in dispatch-rider-1.3.6 vs lib/dispatch-rider/publisher.rb in dispatch-rider-1.4.0
- old
+ new
@@ -33,11 +33,26 @@
self
end
def publish(opts = {})
options = opts.dup
+ add_message_id(options[:message])
service_channel_mapper.map(options.delete(:destinations)).each do |(service, channels)|
notification_service_registrar.fetch(service).publish(options.merge(:to => channels))
+ end
+ end
+
+ private
+
+ def add_message_id(message)
+ message[:body][:guid] = generate_new_message_id
+ end
+
+ def generate_new_message_id
+ if DispatchRider.config.debug
+ DispatchRider::Debug::PUBLISHER_MESSAGE_GUID
+ else
+ SecureRandom.uuid
end
end
class ServiceChannelMapper
attr_reader :destination_registrar