zendesk / radar

High level API and backend for writing web apps that use push messaging

Home Page:http://radar.zendesk.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change default expiry for presence per channel?

coryvirok opened this issue · comments

I have a couple of levels of presence for the project I'm working on.

  1. Users online right now for the whole project
  2. Users looking at a specific page

I'd like to change the default 15 second timeout for when disconnect events are sent to connected users on a per-channel basis.

For projects, I'd like the event to fire after 15 seconds of non-presence. For page presence, I'd like it to fire after 5 seconds.

I thought this was configurable via my resource type definition using the maxAgeSeconds policy:

  {
    name: 'projectPresence',
    expression: new RegExp('^presence:/rollbar/project/[0-9]+$'),
    type: 'Presence',
    policy: { cache: true, maxAgeSeconds: 15 },
    authProvider: {
      authorize: security.resourceTokenValidator
    }
  },
  {
    name: 'projectItemPresence',
    expression: new RegExp('^presence:/rollbar/project/[0-9]+/item/[0-9]+$'),
    type: 'Presence',
    policy: { cache: false, maxAgeSeconds: 5 },
    authProvider: {
      authorize: security.resourceTokenValidator
    }
  }

However, it looks like this 15 second number is hard-coded here:
https://github.com/zendesk/radar/blob/master/core/lib/resources/presence/presence_manager.js#L16

You are right, this should be a configurable and was an oversight when I rewrote presence. The test suites set their custom expiry so the tests are more faster, however I never made it configurable. I will let you know when I have the fix. If you want this urgently, a PR is always welcome!

PS: maxAgeSeconds is a config for messageList type for pruning old messages. I would suggest calling this 'userExpirySeconds' for this.

This is being addressed in #104 It should be available soon through npm. I will update here once I have the new version.

This is fixed in version 0.11.1.

awesome, thanks!