-
Notifications
You must be signed in to change notification settings - Fork 253
/
xep0357.ts
70 lines (64 loc) · 1.69 KB
/
xep0357.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
// ====================================================================
// XEP-0357: Push Notifications
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0357.html
// Version: 0.3 (2017-08-24)
// ====================================================================
import { JID } from '../JID';
import {
addAlias,
attribute,
DefinitionOptions,
JIDAttribute,
pubsubItemContentAliases
} from '../jxt';
import { NS_DATAFORM, NS_PUSH_0 } from '../Namespaces';
import { DataForm } from './';
declare module './' {
export interface IQPayload {
push?: PushNotificationControl;
}
}
export interface PushNotificationControl {
action: 'enable' | 'disable';
node?: string;
jid?: JID;
form?: DataForm;
}
export interface PushNotification {
form?: DataForm;
}
const Protocol: DefinitionOptions[] = [
addAlias(NS_DATAFORM, 'x', ['iq.push.form', 'pushNotification.form']),
{
element: 'enable',
fields: {
jid: JIDAttribute('jid'),
node: attribute('node')
},
namespace: NS_PUSH_0,
path: 'iq.push',
type: 'enable',
typeField: 'action'
},
{
element: 'disable',
fields: {
jid: JIDAttribute('jid'),
node: attribute('node')
},
namespace: NS_PUSH_0,
path: 'iq.push',
type: 'disable',
typeField: 'action'
},
{
aliases: pubsubItemContentAliases(),
element: 'notification',
namespace: NS_PUSH_0,
path: 'pushNotification',
type: NS_PUSH_0,
typeField: 'itemType'
}
];
export default Protocol;