Merge pull request #420 from shocknet/bug/presence-sockets

Added presence middleware to sockets
This commit is contained in:
CapDog 2021-07-12 16:26:15 -04:00 committed by GitHub
commit b9353f5b43

View file

@ -10,6 +10,7 @@ const { getGun, getUser, isAuthenticated } = require('../Mediator')
const { deepDecryptIfNeeded } = require('../rpc')
const Subscriptions = require('./subscriptions')
const GunEvents = require('../contact-api/events')
const GunActions = require('../../gunDB/contact-api/actions')
const {
encryptedEmit,
encryptedOn,
@ -243,6 +244,12 @@ const startSocket = socket => {
socket.emit(Common.Constants.ErrorCode.NOT_AUTH)
}
if (isAuthenticated()) {
socket.onAny(() => {
GunActions.setLastSeenApp()
})
}
on('subscribe:query', ({ $shock, publicKey }, response) => {
const subscriptionId = uuidv4()
try {