forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xep0191.ts
66 lines (61 loc) · 1.72 KB
/
xep0191.ts
1
2
3
4
5
6
7
8
9
10
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ====================================================================
// XEP-0191: Blocking Command
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0191.html
// Version: 1.3 (2015-03-12)
// ====================================================================
import { JID } from '../JID';
import { childBoolean, DefinitionOptions, extendStanzaError, multipleChildAttribute } from '../jxt';
import { NS_BLOCKING, NS_BLOCKING_ERRORS } from '../Namespaces';
declare module './' {
export interface IQPayload {
blockList?: Blocking;
}
export interface StanzaError {
blocked?: boolean;
}
}
export interface Blocking {
action: 'list' | 'block' | 'unblock';
jids?: JID[];
}
export interface BlockingList extends Blocking {
action: 'list';
jids: JID[];
}
const Protocol: DefinitionOptions[] = [
extendStanzaError({
blocked: childBoolean(NS_BLOCKING_ERRORS, 'blocked')
}),
{
element: 'blocklist',
fields: {
jids: multipleChildAttribute(null, 'item', 'jid')
},
namespace: NS_BLOCKING,
path: 'iq.blockList',
type: 'list',
typeField: 'action'
},
{
element: 'block',
fields: {
jids: multipleChildAttribute(null, 'item', 'jid')
},
namespace: NS_BLOCKING,
path: 'iq.blockList',
type: 'block',
typeField: 'action'
},
{
element: 'unblock',
fields: {
jids: multipleChildAttribute(null, 'item', 'jid')
},
namespace: NS_BLOCKING,
path: 'iq.blockList',
type: 'unblock',
typeField: 'action'
}
];
export default Protocol;