Sha256: 328dfb46d05bdfb7701335a708030c6eafe4b8afa7a5046f2087bb86a1d2cacb

Contents?: true

Size: 904 Bytes

Versions: 14

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module JabberAdmin
  module Commands
    # Send a message (stanza) as if sent from a c2s session.
    #
    # @see https://bit.ly/2wwUcYr
    class SendStanzaC2s
      # Pass the correct data to the given callable.
      #
      # @param callable [Proc, #call] the callable to call
      # @param user [String] user JID w/ resource (eg. +tom@localhost/bot+)
      # @param stanza [String] the XML stanz to send
      #   (eg. <tt><message to='user1@localhost'>
      #   <ext attr='value'/></message></tt>)
      def self.call(callable, user:, stanza:)
        uid, host = user.split('@')
        host, resource = host.split('/')
        resource ||= 'bot'
        callable.call('send_stanza_c2s',
                      user: uid,
                      host: host,
                      resource: resource,
                      stanza: stanza)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
jabber_admin-1.3.4 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.3.3 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.3.2 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.3.1 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.3.0 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.2.0 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.1.0 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.5 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.4 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.3 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.2 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.1 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-1.0.0 lib/jabber_admin/commands/send_stanza_c2s.rb
jabber_admin-0.2.0 lib/jabber_admin/commands/send_stanza_c2s.rb