Class: Pubnub::FetchMessages
- Inherits:
-
SingleEvent
- Object
- Event
- SingleEvent
- Pubnub::FetchMessages
- Includes:
- Concurrent::Async, Validator::FetchMessages
- Defined in:
- lib/pubnub/events/fetch_messages.rb
Overview
Holds functionality to fetch:
- batch messages (for multiple channels)
- messages with message actions.
Instance Attribute Summary
Attributes inherited from Event
#callback, #channel, #channel_group, #fresh_clone, #given_options, #group, #idle_timeout, #open_timeout, #origin, #presence_callback, #read_timeout, #ssl, #state, #wildcard_channel, #with_presence
Instance Method Summary collapse
-
#initialize(options, app) ⇒ FetchMessages
constructor
A new instance of FetchMessages.
Methods included from Validator::FetchMessages
Methods included from Validator::CommonValidator
#validate_origin, #validate_publish_key, #validate_subscribe_key, #validate_user_id
Methods inherited from Event
#finalized?, #fire, #send_request, #sync?, #uri
Methods included from Event::EFormatter
#format_channels, #format_envelopes, #format_group
Constructor Details
#initialize(options, app) ⇒ FetchMessages
Returns a new instance of FetchMessages.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pubnub/events/fetch_messages.rb', line 11 def initialize(, app) @telemetry_name = :l_hist @include_custom_message_type = .fetch(:include_custom_message_type, false) @include_message_actions = .fetch(:include_message_actions, false) @include_message_type = .fetch(:include_message_type, true) @encode_channels = .fetch(:encode_channels, true) @include_uuid = .fetch(:include_uuid, true) @include_meta = .fetch(:include_meta, false) @start = [:start] if .key?(:start) @end = [:end] if .key?(:end) channel = [:channel] if .key?(:channel) && ![:channel].empty? @channels = [:channels] if .key?(:channels) && ![:channels].empty? if @include_message_actions @channel = channel elsif @channels.nil? && !channel.nil? @channels = [channel] @channel = nil .delete :channel end maximum = @include_message_actions || @channels&.size == 1 ? 100 : 25 @max = [[:max], maximum].min unless [:max].nil? @event = current_operation # Override crypto module if custom cipher key has been used. random_iv = .key?(:random_iv) ? [:random_iv] : true [:crypto_module] = Crypto::CryptoModule.new_legacy([:cipher_key], random_iv) if [:cipher_key] super end |