Show:

Streams.Message Class

Extends Base.Streams.Message
Module: Streams

Class representing 'Message' rows in the 'Streams' database
stored primarily on publisherId's fm server

Constructor

Streams.Message

(
  • fields
)

Parameters:

  • fields Object

    The fields values to initialize table row as an associative array of {column: value} pairs

Item Index

Methods

Methods

define

(
  • type
  • ctor
  • methods
)
static

Call this function to set a constructor for a message type

Parameters:

  • type String

    The type of the message, e.g. "Streams/chat/message"

  • ctor String | Function

    Your message's constructor, or path to a javascript file which will define it

  • methods Object

    An optional hash of methods

deliver

(
  • stream
  • toUserId
  • deliver
  • avatar
  • callback
)

Delivers the message posted to stream according to particular delivery method (see: Streams_SubscriptionRule.deliver). Message template is taken from views/{message.type} folder - 'email.handlebars' or 'mobile.handlebars' or 'device.handlebars' depending on delivery

Parameters:

  • stream Streams.Stream
  • toUserId Function

    the id of the user to whom to deliver

  • deliver String | Object

    can be any key under "Streams"/"rules"/"deliver" config, such as "default" or "invited". The value in the config should be an array of entries, each of which can be a string or an array itself. Entries can contain one or more of "email", "mobile" and "devices". They are tried, in order, and delivery stops as soon as at least one destination is found to deliver to. Or, it can be an object with "to" property as this key, or "emailAddress", "mobileNumber" or "deviceId" specified directly.

  • avatar Streams.Avatar

    the avatar for getting the displayName

  • callback Function

    Callback reports errors and response from delivery systems

getAll

()

Get all the instructions from a message.

getInstruction

(
  • instructionName
)

Get the value of an instruction in the message

Parameters:

post

(
  • fields
  • callback=null
)
static

Posts a message to the stream. Currently doesn't perform any access checks, so it is only meant to be called internally. It is not as robust as the PHP version, which is meant for more general use.

Parameters:

  • fields Object

    The fields of the message. Requires publisherId, streamName and byUserId

  • callback=null Function

setUp

()

The setUp() method is called the first time an object of this class is constructed.

Events

"Streams/deliver/:messageType"

Event Payload:

  • options Object

    for the notification delivery

  • callback Function

    to call when options has been transformed