set last seen action
This commit is contained in:
parent
788e40c84e
commit
1d9215c7f6
2 changed files with 34 additions and 1 deletions
|
|
@ -344,6 +344,34 @@ class Mediator {
|
|||
this.socket.on(Event.ON_SEED_BACKUP, this.onSeedBackup)
|
||||
|
||||
this.socket.on(IS_GUN_AUTH, this.isGunAuth)
|
||||
|
||||
this.socket.on('SET_LAST_SEEN_APP', async body => {
|
||||
try {
|
||||
await throwOnInvalidToken(body.token)
|
||||
await new Promise((res, rej) => {
|
||||
getUser()
|
||||
.get('lastSeenApp')
|
||||
.put(Date.now(), ack => {
|
||||
if (ack.err) {
|
||||
rej(new Error(ack.err))
|
||||
} else {
|
||||
res()
|
||||
}
|
||||
})
|
||||
})
|
||||
this.socket.emit('SET_LAST_SEEN_APP', {
|
||||
ok: true,
|
||||
msg: null,
|
||||
origBody: body
|
||||
})
|
||||
} catch (e) {
|
||||
this.socket.emit('SET_LAST_SEEN_APP', {
|
||||
ok: false,
|
||||
msg: e.message,
|
||||
origBody: body
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** @param {SimpleSocket} socket */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ const { Buffer } = require('buffer')
|
|||
const APIKeyPair = new Map()
|
||||
const authorizedDevices = new Map()
|
||||
|
||||
const nonEncryptedEvents = ['ping', 'disconnect', 'IS_GUN_AUTH']
|
||||
const nonEncryptedEvents = [
|
||||
'ping',
|
||||
'disconnect',
|
||||
'IS_GUN_AUTH',
|
||||
'SET_LAST_SEEN_APP'
|
||||
]
|
||||
|
||||
const Encryption = {
|
||||
isNonEncrypted: event => nonEncryptedEvents.includes(event),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue