From 80d8d6d231f5624a7a1fedf8ee5446335cea3188 Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Wed, 5 Jun 2019 08:51:21 +0200 Subject: [PATCH] Apply namespace fixes from #33 --- cmd/xmpp_component/xmpp_component.go | 4 ++-- iq.go | 4 ++-- iq_test.go | 4 ++-- msg_chat_markers.go | 10 ++++++---- msg_receipts.go | 6 ++++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cmd/xmpp_component/xmpp_component.go b/cmd/xmpp_component/xmpp_component.go index a4640ed..4b76a82 100644 --- a/cmd/xmpp_component/xmpp_component.go +++ b/cmd/xmpp_component/xmpp_component.go @@ -80,8 +80,8 @@ func DiscoResult(c MyComponent, attrs xmpp.PacketAttrs, info *xmpp.DiscoInfo) { payload := xmpp.DiscoInfo{ Identity: identity, Features: []xmpp.Feature{ - {Var: "http://jabber.org/protocol/disco#info"}, - {Var: "http://jabber.org/protocol/disco#item"}, + {Var: xmpp.NSDiscoInfo}, + {Var: xmpp.NSDiscoItems}, }, } iq.AddPayload(&payload) diff --git a/iq.go b/iq.go index bfc13e3..eb2e9e8 100644 --- a/iq.go +++ b/iq.go @@ -318,8 +318,8 @@ type DiscoItem struct { } func init() { - typeRegistry.MapExtension(PKTIQ, xml.Name{"http://jabber.org/protocol/disco#info", "query"}, DiscoInfo{}) - typeRegistry.MapExtension(PKTIQ, xml.Name{"http://jabber.org/protocol/disco#items", "query"}, DiscoItems{}) + typeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoInfo, "query"}, DiscoInfo{}) + typeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoItems, "query"}, DiscoItems{}) typeRegistry.MapExtension(PKTIQ, xml.Name{"urn:ietf:params:xml:ns:xmpp-bind", "bind"}, BindBind{}) typeRegistry.MapExtension(PKTIQ, xml.Name{"urn:xmpp:iot:control", "set"}, ControlSet{}) } diff --git a/iq_test.go b/iq_test.go index f78456b..eb3ab2a 100644 --- a/iq_test.go +++ b/iq_test.go @@ -43,8 +43,8 @@ func TestGenerateIq(t *testing.T) { Type: "mqtt", }, Features: []xmpp.Feature{ - {Var: "http://jabber.org/protocol/disco#info"}, - {Var: "http://jabber.org/protocol/disco#item"}, + {Var: xmpp.NSDiscoInfo}, + {Var: xmpp.NSDiscoItems}, }, } iq.AddPayload(&payload) diff --git a/msg_chat_markers.go b/msg_chat_markers.go index 418a09a..fc7f61b 100644 --- a/msg_chat_markers.go +++ b/msg_chat_markers.go @@ -7,6 +7,8 @@ Support for: - XEP-0333 - Chat Markers: https://xmpp.org/extensions/xep-0333.html */ +const NSMsgChatMarkers = "urn:xmpp:chat-markers:0" + type Markable struct { MsgExtension XMLName xml.Name `xml:"urn:xmpp:chat-markers:0 markable"` @@ -31,8 +33,8 @@ type MarkAcknowledged struct { } func init() { - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:chat-markers:0", "markable"}, Markable{}) - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:chat-markers:0", "received"}, MarkReceived{}) - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:chat-markers:0", "displayed"}, MarkDisplayed{}) - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:chat-markers:0", "acknowledged"}, MarkAcknowledged{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatMarkers, "markable"}, Markable{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatMarkers, "received"}, MarkReceived{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatMarkers, "displayed"}, MarkDisplayed{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatMarkers, "acknowledged"}, MarkAcknowledged{}) } diff --git a/msg_receipts.go b/msg_receipts.go index 76958a8..43d5b7d 100644 --- a/msg_receipts.go +++ b/msg_receipts.go @@ -7,6 +7,8 @@ Support for: - XEP-0184 - Message Delivery Receipts: https://xmpp.org/extensions/xep-0184.html */ +const NSMsgReceipts = "urn:xmpp:receipts" + // Used on outgoing message, to tell the recipient that you are requesting a message receipt / ack. type ReceiptRequest struct { MsgExtension @@ -20,6 +22,6 @@ type ReceiptReceived struct { } func init() { - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:receipts", "request"}, ReceiptRequest{}) - typeRegistry.MapExtension(PKTMessage, xml.Name{"urn:xmpp:receipts", "received"}, ReceiptReceived{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgReceipts, "request"}, ReceiptRequest{}) + typeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgReceipts, "received"}, ReceiptReceived{}) }