forked from legastero/stanza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xep0016.ts
76 lines (71 loc) · 2.07 KB
/
xep0016.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
67
68
69
70
71
72
73
74
75
76
// ====================================================================
// XEP-0016: Privacy Lists
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0016.html
// Version: 1.7 (2007-08-13)
// ====================================================================
import {
attribute,
childAttribute,
childBoolean,
DefinitionOptions,
integerAttribute
} from '../jxt';
import { NS_PRIVACY } from '../Namespaces';
declare module './' {
export interface IQPayload {
privacy?: PrivacyList;
}
}
export interface PrivacyList {
activeList?: string;
defaultList?: string;
lists?: Array<{
name: string;
items: Array<{
type?: 'jid' | 'group' | 'subscription';
value?: string;
action: 'allow' | 'deny';
order: number;
messages?: boolean;
incomingPresence?: boolean;
outgoingPresence?: boolean;
iq?: boolean;
}>;
}>;
}
const Protocol: DefinitionOptions[] = [
{
element: 'query',
fields: {
activeList: childAttribute(null, 'active', 'name'),
defaultList: childAttribute(null, 'default', 'name')
},
namespace: NS_PRIVACY,
path: 'iq.privacy'
},
{
aliases: [{ path: 'iq.privacy.lists', multiple: true }],
element: 'list',
fields: {
name: attribute('name')
},
namespace: NS_PRIVACY
},
{
aliases: [{ path: 'iq.privacy.lists.items', multiple: true }],
element: 'item',
fields: {
action: attribute('action'),
incomingPresence: childBoolean(null, 'presence-in'),
iq: childBoolean(null, 'iq'),
messages: childBoolean(null, 'message'),
order: integerAttribute('order'),
outgoingPresence: childBoolean(null, 'presence-out'),
type: attribute('type'),
value: attribute('value')
},
namespace: NS_PRIVACY
}
];
export default Protocol;