| 1 |
package xmpp |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
) |
| 6 |
|
| 7 |
// ErrorServiceUnavailable implements error response about a feature that is not available. Currently implemented for |
| 8 |
// xep-0030. |
| 9 |
// QueryXmlns is about incoming xmlns attribute in query tag. |
| 10 |
// Node is about incoming node attribute in query tag (looks like it used only in disco#commands). |
| 11 |
// |
| 12 |
// If queried feature is not here on purpose, standards suggest to answer with this stanza. |
| 13 |
func (c *Client) ErrorServiceUnavailable(v IQ, queryXmlns, node string) (string, error) { |
| 14 |
query := fmt.Sprintf("<query xmlns='%s' ", queryXmlns) |
| 15 |
|
| 16 |
if node != "" { |
| 17 |
query += fmt.Sprintf("node='%s' />", node) |
| 18 |
} else { |
| 19 |
query += "/>" |
| 20 |
} |
| 21 |
|
| 22 |
query += "<error type='cancel'>" |
| 23 |
query += "<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' />" |
| 24 |
query += "</error>" |
| 25 |
|
| 26 |
return c.RawInformation( |
| 27 |
v.To, |
| 28 |
v.From, |
| 29 |
v.ID, |
| 30 |
IQTypeError, |
| 31 |
query, |
| 32 |
) |
| 33 |
} |
| 34 |
|
| 35 |
// ErrorNotImplemented implements error response about a feature that is not (yet?) implemented. |
| 36 |
// Xmlns is about not implemented feature. |
| 37 |
// |
| 38 |
// If queried feature is not here because of it under development or for similar reasons, standards suggest to answer with |
| 39 |
// this stanza. |
| 40 |
func (c *Client) ErrorNotImplemented(v IQ, xmlns, feature string) (string, error) { |
| 41 |
query := "<error type='cancel'>" |
| 42 |
query += "<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' />" |
| 43 |
query += fmt.Sprintf( |
| 44 |
"<unsupported xmlns='%s' feature='%s' />", |
| 45 |
xmlns, |
| 46 |
feature, |
| 47 |
) |
| 48 |
query += "</error>" |
| 49 |
|
| 50 |
return c.RawInformation( |
| 51 |
v.To, |
| 52 |
v.From, |
| 53 |
v.ID, |
| 54 |
IQTypeError, |
| 55 |
query, |
| 56 |
) |
| 57 |
} |