API Docs for: 2.6
Show:

controller_postit Class

Module: postit

Provides the post-it functionalities.

Methods

deletedPostitCb

(
  • err
  • recipient
  • results
)

A post-it has been deleted from the database. It's the callback function called when get new post-it messages from the database component, after a post-it has been deleted by a user.

Parameters:

  • err Object

    The error

  • recipient String

    The username of the recipient

  • results Object

    All the unread post-it of the recipient user

deletePostit

(
  • id
  • cb
)

Deletes the post-it with the specified unique identifier.

Parameters:

  • id String

    The unique identifier of the post-it message

  • cb Function

    The callback function

evtDeletedPostit

(
  • recipient
)

A post-it has been deleted from the database.

Parameters:

  • recipient Object

    The username of the recipient

getAllUserHistoryInterval

(
  • data
  • cb
)

Gets the history of the post-it created by all the users into the interval time. It can be possible to filter the results.

Parameters:

  • data Object
    • from String

      The starting date of the interval in the YYYYMMDD format (e.g. 20130521)

    • to String

      The ending date of the interval in the YYYYMMDD format (e.g. 20130528)

    • [filter] String optional

      The filter to be used

  • cb Function

    The callback function

getHistoryInterval

(
  • data
  • cb
)

Get the history of the post-it created by the user into the interval time. It can be possible to filter the results.

Parameters:

  • data Object
    • username String

      The username involved in the research

    • from String

      The starting date of the interval in the YYYYMMDD format (e.g. 20130521)

    • to String

      The ending date of the interval in the YYYYMMDD format (e.g. 20130528)

    • [filter] String optional

      The filter to be used

  • cb Function

    The callback function

getNewPostit

(
  • username
  • cb
)

Returns all the new post-it messages of the user.

Parameters:

  • username String

    The name of the user

  • cb Function

    The callback function

getPostit

(
  • id
  • cb
)

Returns the post-it with the specified unique identifier.

Parameters:

  • id String

    The unique identifier of the post-it message

  • cb Function

    The callback function

getPostitCb

(
  • err
  • username
  • id
  • result
)

Updates the read date status of the postit only if the reader is the recipient of the post-it. Then emits the event to update all the new post-it messages of the recipient user. The event is emitted only if the message was new before read it and the read status has been updated.

Parameters:

  • err Object

    The error object

  • username String

    The username of the reader

  • id String

    The post-it database identifier

  • result Object

    The result object of the query

modifyPostit

(
  • id
  • text
  • cb
)

Changes the post-it with the specified unique identifier.

Parameters:

  • id String

    The unique identifier of the post-it message

  • text String

    The text of the post-it message

  • cb Function

    The callback function

newPostit

(
  • data
  • cb
)

Creates a new post-it and save it in the database.

Parameters:

  • data Object
    • recipient String

      The recipient of the post-it

    • creator String

      The creator of the post-it

    • text String

      The text of the message

  • cb Function

    The callback function

newPostitCb

(
  • err
  • creator
  • recipient
  • results
)
private

It's the callback function called when get all unread postit of a recipient user from the database component. It's called when a new post-it message has been created for a recipient user.

Parameters:

  • err Object

    The error

  • creator String

    The creator username of the new post-it

  • recipient String

    The recipient username of the new post-it

  • results Object

    All the unread post-it of the recipient user

on

(
  • type
  • cb
)
Object

Subscribe a callback function to a custom event fired by this object. It's the same of nodejs events.EventEmitter.on method.

Parameters:

  • type String

    The name of the event

  • cb Function

    The callback to execute in response to the event

Returns:

Object:

A subscription handle capable of detaching that subscription.

readPostit

(
  • username
  • id
  • cb
)

Returns the post-it with the specified unique identifier and update the read status of the post-it.

Parameters:

  • username String

    The username of the reader

  • id String

    The unique identifier of the post-it message

  • cb Function

    The callback function

readPostitCb

(
  • err
  • recipient
  • results
)

A post-it has been read from the database. It's the callback function called when get new post-it messages from the database component, after a post-it has been read by a user.

Parameters:

  • err Object

    The error

  • recipient String

    The username of the recipient

  • results Object

    All the unread post-it of the recipient user

save

(
  • data
  • cb
)

Save the post-it data into the database using dbconn module. Then gets all the unread post-it of the recipient user and emit the new post-it event EVT_NEW_POSTIT.

Parameters:

  • data Object
    • recipient String

      The recipient of the post-it

    • creator String

      The creator of the post-it

    • text String

      The text of the message

  • cb Function

    The callback function

setDbconn

(
  • dbConnMod
)

Set the module to be used for database functionalities.

Parameters:

  • dbConnMod Object

    The dbconn module.

setDbconnListeners

() private

Sets the event listeners for the database component.

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

start

()

Start the components.

updateNewPostitCb

(
  • err
  • recipient
  • results
)
private

It's the callback function called when get all unread postit of a recipient user from the database component. It's called when a new post-it message has been created for a recipient user.

Parameters:

  • err Object

    The error

  • recipient String

    The recipient username of the new post-it

  • results Object

    All the unread post-it of the recipient user

Properties

dbconn

Object private

The dbconn module.

emitter

Object private

The event emitter.

EVT_NEW_POSTIT

String

The name of the new post-it event.

Default: "newPostit"

EVT_UPDATE_NEW_POSTIT

String

The name of the event for update of the new post-it messages.

Default: "updateNewPostit"

IDLOG

String private final

The module identifier used by the logger.

Default: [controller_postit]

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

Events

newPostit

Fired when new post-it has been created for a user.

Event Payload:

  • postits Object

    The list of all unread post-it of the recipient user

updateNewPostit

Fired when new post-it has been created for a user, or a post-it has been read or deleted.

Event Payload:

  • postits Object

    The list of all unread post-it of the recipient user