lib/blather/stanza/message.rb in blather-0.4.14 vs lib/blather/stanza/message.rb in blather-0.4.15
- old
+ new
@@ -173,11 +173,11 @@
node.children.detect do |e|
ns = e.namespace ? e.namespace.href : nil
klass = class_from_registration(e.element_name, ns)
end
- if klass && klass != self && klass != Blather::Stanza::X
+ if klass && klass != self && ![Blather::Stanza::X, Blather::Stanza::Iq].include?(klass)
klass.import(node)
else
new(node[:type]).inherit(node)
end
end
@@ -194,10 +194,18 @@
node.body = body
node.chat_state = :active if [:chat, :groupchat].include?(type)
node
end
+ # Overrides the parent method to ensure the current chat state is removed
+ #
+ # @see Blather::Stanza::Iq#inherit
+ def inherit(node)
+ xpath('ns:*', :ns => CHAT_STATE_NS).remove
+ super
+ end
+
# Check if the Message is of type :chat
#
# @return [true, false]
def chat?
self.type == :chat
@@ -258,10 +266,10 @@
# Get the message xhtml node
# This will create the node if it doesn't exist
#
# @return [XML::Node]
def xhtml_node
- unless h = find_first('ns:html', :ns => HTML_NS)
+ unless h = find_first('ns:html', :ns => HTML_NS) || find_first('ns:html', :ns => HTML_BODY_NS)
self << (h = XMPPNode.new('html', self.document))
h.namespace = HTML_NS
end
unless b = h.find_first('ns:body', :ns => HTML_BODY_NS)