-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathxep0080.ts
94 lines (90 loc) · 2.9 KB
/
xep0080.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// ====================================================================
// XEP-0080: User Location
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0080.html
// Version: 1.9 (2015-12-01)
//
// Additional:
// --------------------------------------------------------------------
// XEP-0350: Data Forms Geolocation Element
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0350.html
// Version: 0.2 (2017-09-11)
// ====================================================================
import {
childDate,
childFloat,
childText,
childTimezoneOffset,
DefinitionOptions,
languageAttribute,
pubsubItemContentAliases
} from '../jxt';
import { NS_GEOLOC } from '../Namespaces';
import { PubsubItemContent } from './';
export interface Geolocation extends PubsubItemContent {
itemType?: typeof NS_GEOLOC;
lang?: string;
accuracy?: number;
altitude?: number;
altitudeAccuracy?: number;
area?: string;
heading?: number;
building?: string;
country?: string;
countryCode?: string;
datum?: string;
description?: string;
error?: number;
floor?: string;
latitude?: number;
locality?: string;
longitude?: number;
postalCode?: string;
region?: string;
room?: string;
speed?: number;
street?: string;
text?: string;
timestamp?: Date;
tzo?: number;
uri?: string;
}
const Protocol: DefinitionOptions = {
aliases: [
{ path: 'message.geoloc', impliedType: true },
{ path: 'dataform.fields.geoloc', impliedType: true }, // XEP-0350
...pubsubItemContentAliases()
],
element: 'geoloc',
fields: {
accuracy: childFloat(null, 'accuracy'),
altitude: childFloat(null, 'alt'),
altitudeAccuracy: childFloat(null, 'altaccuracy'),
area: childText(null, 'area'),
building: childText(null, 'building'),
country: childText(null, 'country'),
countryCode: childText(null, 'countrycode'),
datum: childText(null, 'datum'),
description: childText(null, 'description'),
error: childFloat(null, 'error'),
floor: childText(null, 'floor'),
heading: childFloat(null, 'bearing'),
lang: languageAttribute(),
latitude: childFloat(null, 'lat'),
locality: childText(null, 'locality'),
longitude: childFloat(null, 'lon'),
postalCode: childText(null, 'postalcode'),
region: childText(null, 'region'),
room: childText(null, 'room'),
speed: childFloat(null, 'speed'),
street: childText(null, 'street'),
text: childText(null, 'text'),
timestamp: childDate(null, 'timestamp'),
tzo: childTimezoneOffset(null, 'tzo'),
uri: childText(null, 'uri')
},
namespace: NS_GEOLOC,
type: NS_GEOLOC
};
export default Protocol;