|
1
|
|
|
|
|
2
|
|
|
import window from 'window'; |
|
3
|
|
|
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils'; |
|
4
|
|
|
import * as Settings from 'Storage/Settings'; |
|
5
|
|
|
|
|
6
|
|
|
const |
|
7
|
|
|
ROOT = './', |
|
8
|
|
|
HASH_PREFIX = '#/', |
|
9
|
|
|
SERVER_PREFIX = './?', |
|
10
|
|
|
SUB_QUERY_PREFIX = '&q[]=', |
|
11
|
|
|
|
|
12
|
|
|
VERSION = Settings.appSettingsGet('version'), |
|
13
|
|
|
|
|
14
|
|
|
WEB_PREFIX = Settings.appSettingsGet('webPath') || '', |
|
15
|
|
|
VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/', |
|
16
|
|
|
STATIC_PREFIX = VERSION_PREFIX + 'static/', |
|
17
|
|
|
|
|
18
|
|
|
ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'), |
|
19
|
|
|
ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin'; |
|
20
|
|
|
|
|
21
|
|
|
let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @returns {void} |
|
25
|
|
|
*/ |
|
26
|
|
|
export function populateAuthSuffix() |
|
27
|
|
|
{ |
|
28
|
|
|
AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @returns {string} |
|
33
|
|
|
*/ |
|
34
|
|
|
export function subQueryPrefix() |
|
35
|
|
|
{ |
|
36
|
|
|
return SUB_QUERY_PREFIX; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param {string=} startupUrl |
|
41
|
|
|
* @returns {string} |
|
42
|
|
|
*/ |
|
43
|
|
|
export function root(startupUrl = '') |
|
44
|
|
|
{ |
|
45
|
|
|
return HASH_PREFIX + pString(startupUrl); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @returns {string} |
|
50
|
|
|
*/ |
|
51
|
|
|
export function rootAdmin() |
|
52
|
|
|
{ |
|
53
|
|
|
return ADMIN_HOST_USE ? ROOT : SERVER_PREFIX + ADMIN_PATH; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @returns {string} |
|
58
|
|
|
*/ |
|
59
|
|
|
export function rootUser() |
|
60
|
|
|
{ |
|
61
|
|
|
return ROOT; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param {string} type |
|
66
|
|
|
* @param {string} download |
|
67
|
|
|
* @param {string=} customSpecSuffix |
|
68
|
|
|
* @returns {string} |
|
69
|
|
|
*/ |
|
70
|
|
|
export function attachmentRaw(type, download, customSpecSuffix) |
|
71
|
|
|
{ |
|
72
|
|
|
customSpecSuffix = isUnd(customSpecSuffix) ? AUTH_PREFIX : customSpecSuffix; |
|
73
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + customSpecSuffix + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + download; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param {string} download |
|
78
|
|
|
* @param {string=} customSpecSuffix |
|
79
|
|
|
* @returns {string} |
|
80
|
|
|
*/ |
|
81
|
|
|
export function attachmentDownload(download, customSpecSuffix) |
|
82
|
|
|
{ |
|
83
|
|
|
return attachmentRaw('Download', download, customSpecSuffix); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param {string} download |
|
88
|
|
|
* @param {string=} customSpecSuffix |
|
89
|
|
|
* @returns {string} |
|
90
|
|
|
*/ |
|
91
|
|
|
export function attachmentPreview(download, customSpecSuffix) |
|
92
|
|
|
{ |
|
93
|
|
|
return attachmentRaw('View', download, customSpecSuffix); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param {string} download |
|
98
|
|
|
* @param {string=} customSpecSuffix |
|
99
|
|
|
* @returns {string} |
|
100
|
|
|
*/ |
|
101
|
|
|
export function attachmentThumbnailPreview(download, customSpecSuffix) |
|
102
|
|
|
{ |
|
103
|
|
|
return attachmentRaw('ViewThumbnail', download, customSpecSuffix); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param {string} download |
|
108
|
|
|
* @param {string=} customSpecSuffix |
|
109
|
|
|
* @returns {string} |
|
110
|
|
|
*/ |
|
111
|
|
|
export function attachmentPreviewAsPlain(download, customSpecSuffix) |
|
112
|
|
|
{ |
|
113
|
|
|
return attachmentRaw('ViewAsPlain', download, customSpecSuffix); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param {string} download |
|
118
|
|
|
* @param {string=} customSpecSuffix |
|
119
|
|
|
* @returns {string} |
|
120
|
|
|
*/ |
|
121
|
|
|
export function attachmentFramed(download, customSpecSuffix) |
|
122
|
|
|
{ |
|
123
|
|
|
return attachmentRaw('FramedView', download, customSpecSuffix); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param {string} type |
|
128
|
|
|
* @returns {string} |
|
129
|
|
|
*/ |
|
130
|
|
|
export function serverRequest(type) |
|
131
|
|
|
{ |
|
132
|
|
|
return SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/'; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @returns {string} |
|
137
|
|
|
*/ |
|
138
|
|
|
export function upload() |
|
139
|
|
|
{ |
|
140
|
|
|
return serverRequest('Upload'); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @returns {string} |
|
145
|
|
|
*/ |
|
146
|
|
|
export function uploadContacts() |
|
147
|
|
|
{ |
|
148
|
|
|
return serverRequest('UploadContacts'); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @returns {string} |
|
153
|
|
|
*/ |
|
154
|
|
|
export function uploadBackground() |
|
155
|
|
|
{ |
|
156
|
|
|
return serverRequest('UploadBackground'); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* @returns {string} |
|
161
|
|
|
*/ |
|
162
|
|
|
export function append() |
|
163
|
|
|
{ |
|
164
|
|
|
return serverRequest('Append'); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @param {string} email |
|
169
|
|
|
* @returns {string} |
|
170
|
|
|
*/ |
|
171
|
|
|
export function change(email) |
|
172
|
|
|
{ |
|
173
|
|
|
return serverRequest('Change') + encodeURIComponent(email) + '/'; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param {string} add |
|
178
|
|
|
* @returns {string} |
|
179
|
|
|
*/ |
|
180
|
|
|
export function ajax(add) |
|
181
|
|
|
{ |
|
182
|
|
|
return serverRequest('Ajax') + add; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @param {string} requestHash |
|
187
|
|
|
* @returns {string} |
|
188
|
|
|
*/ |
|
189
|
|
|
export function messageViewLink(requestHash) |
|
190
|
|
|
{ |
|
191
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ViewAsPlain/' + SUB_QUERY_PREFIX + '/' + requestHash; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @param {string} requestHash |
|
196
|
|
|
* @returns {string} |
|
197
|
|
|
*/ |
|
198
|
|
|
export function messageDownloadLink(requestHash) |
|
199
|
|
|
{ |
|
200
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* @param {string} email |
|
205
|
|
|
* @returns {string} |
|
206
|
|
|
*/ |
|
207
|
|
|
export function avatarLink(email) |
|
208
|
|
|
{ |
|
209
|
|
|
return SERVER_PREFIX + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/'; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @param {string} hash |
|
214
|
|
|
* @returns {string} |
|
215
|
|
|
*/ |
|
216
|
|
|
export function publicLink(hash) |
|
217
|
|
|
{ |
|
218
|
|
|
return SERVER_PREFIX + '/Raw/0/Public/' + hash + '/'; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @param {string} hash |
|
223
|
|
|
* @returns {string} |
|
224
|
|
|
*/ |
|
225
|
|
|
export function userBackground(hash) |
|
226
|
|
|
{ |
|
227
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @returns {string} |
|
232
|
|
|
*/ |
|
233
|
|
|
export function phpInfo() |
|
234
|
|
|
{ |
|
235
|
|
|
return SERVER_PREFIX + '/Info'; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* @param {string} lang |
|
240
|
|
|
* @param {boolean} isAdmin |
|
241
|
|
|
* @returns {string} |
|
242
|
|
|
*/ |
|
243
|
|
|
export function langLink(lang, isAdmin) |
|
244
|
|
|
{ |
|
245
|
|
|
return SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + VERSION + '/'; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* @returns {string} |
|
250
|
|
|
*/ |
|
251
|
|
|
export function exportContactsVcf() |
|
252
|
|
|
{ |
|
253
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsVcf/'; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* @returns {string} |
|
258
|
|
|
*/ |
|
259
|
|
|
export function exportContactsCsv() |
|
260
|
|
|
{ |
|
261
|
|
|
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsCsv/'; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* @param {boolean} xauth = false |
|
266
|
|
|
* @returns {string} |
|
267
|
|
|
*/ |
|
268
|
|
|
export function socialGoogle(xauth = false) |
|
269
|
|
|
{ |
|
270
|
|
|
return SERVER_PREFIX + 'SocialGoogle' + |
|
271
|
|
|
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '') + (xauth ? '&xauth=1' : ''); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @returns {string} |
|
276
|
|
|
*/ |
|
277
|
|
|
export function socialTwitter() |
|
278
|
|
|
{ |
|
279
|
|
|
return SERVER_PREFIX + 'SocialTwitter' + |
|
280
|
|
|
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : ''); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* @returns {string} |
|
285
|
|
|
*/ |
|
286
|
|
|
export function socialFacebook() |
|
287
|
|
|
{ |
|
288
|
|
|
return SERVER_PREFIX + 'SocialFacebook' + |
|
289
|
|
|
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : ''); |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @param {string} path |
|
294
|
|
|
* @returns {string} |
|
295
|
|
|
*/ |
|
296
|
|
|
export function staticPrefix(path) |
|
297
|
|
|
{ |
|
298
|
|
|
return STATIC_PREFIX + path; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* @returns {string} |
|
303
|
|
|
*/ |
|
304
|
|
|
export function emptyContactPic() |
|
305
|
|
|
{ |
|
306
|
|
|
return staticPrefix('css/images/empty-contact.png'); |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* @param {string} fileName |
|
311
|
|
|
* @returns {string} |
|
312
|
|
|
*/ |
|
313
|
|
|
export function sound(fileName) |
|
314
|
|
|
{ |
|
315
|
|
|
return staticPrefix('sounds/' + fileName); |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* @returns {string} |
|
320
|
|
|
*/ |
|
321
|
|
|
export function notificationMailIcon() |
|
322
|
|
|
{ |
|
323
|
|
|
return staticPrefix('css/images/icom-message-notification.png'); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* @returns {string} |
|
328
|
|
|
*/ |
|
329
|
|
|
export function openPgpJs() |
|
330
|
|
|
{ |
|
331
|
|
|
return staticPrefix('js/min/openpgp.min.js'); |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* @returns {string} |
|
336
|
|
|
*/ |
|
337
|
|
|
export function openPgpWorkerJs() |
|
338
|
|
|
{ |
|
339
|
|
|
return staticPrefix('js/min/openpgp.worker.min.js'); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* @returns {string} |
|
344
|
|
|
*/ |
|
345
|
|
|
export function openPgpWorkerPath() |
|
346
|
|
|
{ |
|
347
|
|
|
return staticPrefix('js/min/'); |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* @param {string} theme |
|
352
|
|
|
* @returns {string} |
|
353
|
|
|
*/ |
|
354
|
|
|
export function themePreviewLink(theme) |
|
355
|
|
|
{ |
|
356
|
|
|
let prefix = VERSION_PREFIX; |
|
357
|
|
|
if ('@custom' === theme.substr(-7)) |
|
358
|
|
|
{ |
|
359
|
|
|
theme = trim(theme.substring(0, theme.length - 7)); |
|
360
|
|
|
prefix = WEB_PREFIX; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
return prefix + 'themes/' + window.encodeURI(theme) + '/images/preview.png'; |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
/** |
|
367
|
|
|
* @param {string} inboxFolderName = 'INBOX' |
|
368
|
|
|
* @returns {string} |
|
369
|
|
|
*/ |
|
370
|
|
|
export function inbox(inboxFolderName = 'INBOX') |
|
371
|
|
|
{ |
|
372
|
|
|
return HASH_PREFIX + 'mailbox/' + inboxFolderName; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* @param {string=} screenName = '' |
|
377
|
|
|
* @returns {string} |
|
378
|
|
|
*/ |
|
379
|
|
|
export function settings(screenName = '') |
|
380
|
|
|
{ |
|
381
|
|
|
return HASH_PREFIX + 'settings' + (screenName ? '/' + screenName : ''); |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* @returns {string} |
|
386
|
|
|
*/ |
|
387
|
|
|
export function about() |
|
388
|
|
|
{ |
|
389
|
|
|
return HASH_PREFIX + 'about'; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
/** |
|
393
|
|
|
* @param {string} screenName |
|
394
|
|
|
* @returns {string} |
|
395
|
|
|
*/ |
|
396
|
|
|
export function admin(screenName) |
|
397
|
|
|
{ |
|
398
|
|
|
let result = HASH_PREFIX; |
|
399
|
|
|
switch (screenName) |
|
400
|
|
|
{ |
|
401
|
|
|
case 'AdminDomains': |
|
402
|
|
|
result += 'domains'; |
|
403
|
|
|
break; |
|
404
|
|
|
case 'AdminSecurity': |
|
405
|
|
|
result += 'security'; |
|
406
|
|
|
break; |
|
407
|
|
|
case 'AdminLicensing': |
|
408
|
|
|
result += 'licensing'; |
|
409
|
|
|
break; |
|
410
|
|
|
// no default |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
return result; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* @param {string} folder |
|
418
|
|
|
* @param {number=} page = 1 |
|
419
|
|
|
* @param {string=} search = '' |
|
420
|
|
|
* @param {string=} threadUid = '' |
|
421
|
|
|
* @returns {string} |
|
422
|
|
|
*/ |
|
423
|
|
|
export function mailBox(folder, page = 1, search = '', threadUid = '') |
|
424
|
|
|
{ |
|
425
|
|
|
page = isNormal(page) ? pInt(page) : 1; |
|
426
|
|
|
search = pString(search); |
|
427
|
|
|
|
|
428
|
|
|
let result = HASH_PREFIX + 'mailbox/'; |
|
429
|
|
|
|
|
430
|
|
|
if ('' !== folder) |
|
431
|
|
|
{ |
|
432
|
|
|
const resultThreadUid = pInt(threadUid); |
|
433
|
|
|
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : ''); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
if (1 < page) |
|
437
|
|
|
{ |
|
438
|
|
|
result = result.replace(/[\/]+$/, ''); |
|
439
|
|
|
result += '/p' + page; |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
if ('' !== search) |
|
443
|
|
|
{ |
|
444
|
|
|
result = result.replace(/[\/]+$/, ''); |
|
445
|
|
|
result += '/' + window.encodeURI(search); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
return result; |
|
449
|
|
|
} |
|
450
|
|
|
|