|
|
@@ -2,29 +2,29 @@
|
|
2
|
2
|
import Logger from 'jitsi-meet-logger';
|
|
3
|
3
|
import RNCalendarEvents from 'react-native-calendar-events';
|
|
4
|
4
|
|
|
|
5
|
+import { SET_ROOM } from '../base/conference';
|
|
5
|
6
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
7
|
+import { parseURIString } from '../base/util';
|
|
6
|
8
|
|
|
7
|
9
|
import { APP_WILL_MOUNT } from '../app';
|
|
8
|
10
|
|
|
9
|
|
-import { updateCalendarEntryList } from './actions';
|
|
|
11
|
+import { maybeAddNewKnownDomain, updateCalendarEntryList } from './actions';
|
|
10
|
12
|
|
|
11
|
13
|
const FETCH_END_DAYS = 10;
|
|
12
|
14
|
const FETCH_START_DAYS = -1;
|
|
13
|
15
|
const MAX_LIST_LENGTH = 10;
|
|
14
|
16
|
const logger = Logger.getLogger(__filename);
|
|
15
|
17
|
|
|
16
|
|
-// this is to be dynamic later.
|
|
17
|
|
-const domainList = [
|
|
18
|
|
- 'meet.jit.si',
|
|
19
|
|
- 'beta.meet.jit.si'
|
|
20
|
|
-];
|
|
21
|
|
-
|
|
22
|
18
|
MiddlewareRegistry.register(store => next => action => {
|
|
23
|
19
|
const result = next(action);
|
|
24
|
20
|
|
|
25
|
21
|
switch (action.type) {
|
|
26
|
22
|
case APP_WILL_MOUNT:
|
|
|
23
|
+ _ensureDefaultServer(store);
|
|
27
|
24
|
_fetchCalendarEntries(store);
|
|
|
25
|
+ break;
|
|
|
26
|
+ case SET_ROOM:
|
|
|
27
|
+ _parseAndAddDomain(store);
|
|
28
|
28
|
}
|
|
29
|
29
|
|
|
30
|
30
|
return result;
|
|
|
@@ -64,6 +64,22 @@ function _ensureCalendarAccess() {
|
|
64
|
64
|
});
|
|
65
|
65
|
}
|
|
66
|
66
|
|
|
|
67
|
+/**
|
|
|
68
|
+ * Ensures presence of the default server in the known domains list.
|
|
|
69
|
+ *
|
|
|
70
|
+ * @private
|
|
|
71
|
+ * @param {Object} store - The redux store.
|
|
|
72
|
+ * @returns {Promise}
|
|
|
73
|
+ */
|
|
|
74
|
+function _ensureDefaultServer(store) {
|
|
|
75
|
+ const state = store.getState();
|
|
|
76
|
+ const defaultURL = parseURIString(
|
|
|
77
|
+ state['features/app'].app._getDefaultURL()
|
|
|
78
|
+ );
|
|
|
79
|
+
|
|
|
80
|
+ store.dispatch(maybeAddNewKnownDomain(defaultURL.host));
|
|
|
81
|
+}
|
|
|
82
|
+
|
|
67
|
83
|
/**
|
|
68
|
84
|
* Reads the user's calendar and updates the stored entries if need be.
|
|
69
|
85
|
*
|
|
|
@@ -86,11 +102,12 @@ function _fetchCalendarEntries(store) {
|
|
86
|
102
|
[]
|
|
87
|
103
|
)
|
|
88
|
104
|
.then(events => {
|
|
|
105
|
+ const { knownDomains } = store.getState()['features/calendar-sync'];
|
|
89
|
106
|
const eventList = [];
|
|
90
|
107
|
|
|
91
|
108
|
if (events && events.length) {
|
|
92
|
109
|
for (const event of events) {
|
|
93
|
|
- const jitsiURL = _getURLFromEvent(event);
|
|
|
110
|
+ const jitsiURL = _getURLFromEvent(event, knownDomains);
|
|
94
|
111
|
const now = Date.now();
|
|
95
|
112
|
|
|
96
|
113
|
if (jitsiURL) {
|
|
|
@@ -117,24 +134,6 @@ function _fetchCalendarEntries(store) {
|
|
117
|
134
|
}
|
|
118
|
135
|
}
|
|
119
|
136
|
|
|
120
|
|
- // TEST events to check notification popup.
|
|
121
|
|
- // TODO: Remove this before a PR.
|
|
122
|
|
- eventList.push({
|
|
123
|
|
- endDate: Date.now() + (60 * 60 * 1000),
|
|
124
|
|
- id: -1,
|
|
125
|
|
- startDate: Date.now() + (80 * 1000),
|
|
126
|
|
- title: 'ShipIt 41',
|
|
127
|
|
- url: 'https://meet.jit.si/shipit41'
|
|
128
|
|
- });
|
|
129
|
|
-
|
|
130
|
|
- eventList.push({
|
|
131
|
|
- endDate: Date.now() + (2 * 60 * 60 * 1000),
|
|
132
|
|
- id: -2,
|
|
133
|
|
- startDate: Date.now() + (60 * 60 * 1000),
|
|
134
|
|
- title: 'ShipIt 41 demo',
|
|
135
|
|
- url: 'https://meet.jit.si/shipit41'
|
|
136
|
|
- });
|
|
137
|
|
-
|
|
138
|
137
|
store.dispatch(updateCalendarEntryList(eventList.sort((a, b) =>
|
|
139
|
138
|
a.startDate - b.startDate
|
|
140
|
139
|
).slice(0, MAX_LIST_LENGTH)));
|
|
|
@@ -153,12 +152,13 @@ function _fetchCalendarEntries(store) {
|
|
153
|
152
|
*
|
|
154
|
153
|
* @private
|
|
155
|
154
|
* @param {Object} event - The event to parse.
|
|
|
155
|
+ * @param {Array<string>} knownDomains - The known domain names.
|
|
156
|
156
|
* @returns {string}
|
|
157
|
157
|
*
|
|
158
|
158
|
*/
|
|
159
|
|
-function _getURLFromEvent(event) {
|
|
|
159
|
+function _getURLFromEvent(event, knownDomains) {
|
|
160
|
160
|
const urlRegExp
|
|
161
|
|
- = new RegExp(`http(s)?://(${domainList.join('|')})/[^\\s<>$]+`, 'gi');
|
|
|
161
|
+ = new RegExp(`http(s)?://(${knownDomains.join('|')})/[^\\s<>$]+`, 'gi');
|
|
162
|
162
|
const fieldsToSearch = [
|
|
163
|
163
|
event.title,
|
|
164
|
164
|
event.url,
|
|
|
@@ -180,3 +180,17 @@ function _getURLFromEvent(event) {
|
|
180
|
180
|
|
|
181
|
181
|
return null;
|
|
182
|
182
|
}
|
|
|
183
|
+
|
|
|
184
|
+/**
|
|
|
185
|
+ * Retreives the domain name of a room upon join and stores it
|
|
|
186
|
+ * in the known domain list, if not present yet.
|
|
|
187
|
+ *
|
|
|
188
|
+ * @private
|
|
|
189
|
+ * @param {Object} store - The redux store.
|
|
|
190
|
+ * @returns {Promise}
|
|
|
191
|
+ */
|
|
|
192
|
+function _parseAndAddDomain(store) {
|
|
|
193
|
+ const { locationURL } = store.getState()['features/base/connection'];
|
|
|
194
|
+
|
|
|
195
|
+ store.dispatch(maybeAddNewKnownDomain(locationURL.host));
|
|
|
196
|
+}
|