-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0144.ts
56 lines (51 loc) · 1.45 KB
/
xep0144.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
// ====================================================================
// XEP-0144: Roster Item Exchange
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0144.html
// Version: 1.1.1 (2017-11-28)
// ====================================================================
import { JID } from '../JID';
import {
attribute,
DefinitionOptions,
extendIQ,
extendMessage,
JIDAttribute,
multipleChildText,
splicePath
} from '../jxt';
import { NS_ROSTER_EXCHANGE } from '../Namespaces';
declare module './' {
export interface Message {
rosterExchange?: RosterExchange[];
}
export interface IQPayload {
rosterExchange?: RosterExchange[];
}
}
export interface RosterExchange {
action: 'add' | 'delete' | 'modify';
jid: JID;
name?: string;
groups?: string[];
}
const Protocol: DefinitionOptions[] = [
extendMessage({
rosterExchange: splicePath(NS_ROSTER_EXCHANGE, 'x', 'rosterExchange', true)
}),
extendIQ({
rosterExchange: splicePath(NS_ROSTER_EXCHANGE, 'x', 'rosterExchange', true)
}),
{
element: 'item',
fields: {
action: attribute('action'),
groups: multipleChildText(null, 'group'),
jid: JIDAttribute('jid'),
name: attribute('name')
},
namespace: NS_ROSTER_EXCHANGE,
path: 'rosterExchange'
}
];
export default Protocol;