Show:

Users Class

Extends Base.Users
Module: Users

Static methods for the Users model

Item Index

Properties

Methods

listen

(
  • [options={}]
)

Start internal listener for Users plugin and open socket
Accepts "Users/session" message

Parameters:

  • [options={}] Object optional
    • [apn.provider={}] Object optional

      Additional options for node-apn Provider

    • [apn.appId=Q.app.name] String optional

      Only needed if you have multiple ios platform apps

listen

(
  • options={}
)

Fetches a user from the database

Parameters:

  • options={} Object

    So far no options are implemented.

userFromSession

(
  • sessionId
  • callback
)

Gets a user (from database if needed) associated with sessionId and passes it to callback.

Parameters:

  • sessionId String
    User's session Id
  • callback Function

    Passes a Users.User object, or null if the the user wasn't found

(
  • icon
  • [size=40]
)
String

Calculate the url of a user's icon

Parameters:

  • icon String

    the value of the user's "icon" field

  • [size=40] Number optional

    the size of the icon to render.

Returns:

String:

the url

pushNotifications

(
  • userIds
  • notifications
  • [callback]
  • [options]
  • [filter]
)
static

Pushes notifications to all devices of the given user or users

Parameters:

  • userIds String | Array

    A user id, or an array of them, in which case notifications would be an object of { userId: notification }

  • notifications Object

    If userIds is an array, this is a hash of {userId: notification} objects, otherwise it is just a single notification object. Please see Users.Device.prototype.pushNotification for the schema of this object.

  • [callback] Function optional

    A function to call after the push has been completed

  • [options] Function optional

    Any additional options to pass to device.pushNotification method

  • [filter] Function optional

    Receives the Users.Device object. Return false to skip the device.

Properties

clients

Object

Store clients

sessions

Object

Store user sessions