forked from stealthyinc/messenger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.js
65 lines (51 loc) · 1.96 KB
/
common.js
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
import {Platform} from 'react-native'
export const NO_SESSION = 'none'
const USE_PRODUCTION_FIREBASE_IN_DEV = false
module.exports.getDbRootPath = function (aPublicKey) {
// ud --> user data:
const context = ((process.env.NODE_ENV !== 'development') ||
USE_PRODUCTION_FIREBASE_IN_DEV)
? 'ud' : 'development/ud'
return `/global/${context}/${aPublicKey}`
}
module.exports.getDbSessionPath = function (aPublicKey) {
const rootPath = module.exports.getDbRootPath(aPublicKey)
return `${rootPath}/session`
}
module.exports.getDbDiscoveryPath = function (aPublicKey) {
const rootPath = module.exports.getDbRootPath(aPublicKey)
return `${rootPath}/discovery`
}
module.exports.getDbNotificationPath = function (aPublicKey) {
const rootPath = module.exports.getDbRootPath(aPublicKey)
return `${rootPath}/notifications`
}
module.exports.getDbExistingDataPath = function (aPublicKey) {
const rootPath = module.exports.getDbRootPath(aPublicKey)
return `${rootPath}/existingData`
}
module.exports.getDbChannelRootPath = function (aPublicKey,
aChannelProtocol = 'public_channel_v2_0') {
// ud --> user data:
const context = ((process.env.NODE_ENV !== 'development') ||
USE_PRODUCTION_FIREBASE_IN_DEV)
? `${aChannelProtocol}/ud` : `development/${aChannelProtocol}/ud`
return `/global/${context}/${aPublicKey}`
}
module.exports.getDbChannelStatusPath = function (aPublicKey) {
const rootPath = module.exports.getDbChannelRootPath(aPublicKey)
return `${rootPath}/status`
}
module.exports.getDbChannelNotificationPath = function (aPublicKey) {
const rootPath = module.exports.getDbChannelRootPath(aPublicKey)
return `${rootPath}/message_notifications`
}
var __sessionId
//
module.exports.getSessionId = function () {
if (!__sessionId) {
__sessionId = `${Platform.OS}-${Date.now()}`
}
console.log(`INFO(common.js::getSessionId): returning ${__sessionId}`)
return __sessionId
}