Class: moment

moment()

new moment()

Moment API Controller

Author:
  • Calvin Ho
Source:

Methods

(static) exports.cloneChildren(originalParent:, clonedParent:, user:, optOutReason) → {Void}

Clone an Activity with its onboarding processes

Parameters:
Name Type Description
originalParent:

the original Activity to be cloned

clonedParent:

the cloned Activity

user:

the User object

optOutReason

null - join as participant and organizer 'admin' - an organizer cloning a sample or an Activity for another leader, therefore no need to join as participant and organizer 'staff' - Restvo staff. same as 'admin' + append a timestamp to the cloned title

Source:
Returns:

last updated by Calvin Ho on 1/9/20

Type
Void

(static) exports.cloneMoments(req, res, next) → {Promise.<void>}

Clone Activity

Parameters:
Name Type Description
req
res
next
  1. clone 1 level of associated Plans and their onboarding processes,
  2. clone the Activity

optOutReason: null - join as participant and organizer 'admin' - an admin cloning a sample or an Activity for another leader, therefore no need to join as participant and organizer 'staff' - Restvo staff. same as 'admin' + append a timestamp to the cloned title

last updated by Calvin Ho on Dec 4

Source:
Returns:
Type
Promise.<void>

(static) exports.computeMatchingUsers(req, res, next) → {Promise.<void>}

execute the matching algorithm to find users best matched based on how they answered the questions

Parameters:
Name Type Description
req
res
next
Source:
Returns:
Type
Promise.<void>

(static) exports.create(moment:, user:, optOutReason) → {Activity}

Create Activity

Parameters:
Name Type Description
moment:

the Activity object

user:

the User object

optOutReason

null - join as participant and organizer 'admin' - an organizer cloning a sample or an Activity for another leader, therefore no need to join as participant and organizer 'staff' - Restvo staff. same as 'admin' + append a timestamp to the cloned title

Source:
Returns:

an object of the created Activity

last updated by Calvin Ho on 2/25/20

Type
Activity

(static) exports.createMoment(req, res, next) → {Promise.<void>}

Create Activity

Parameters:
Name Type Description
req
res
next
req.body:

an object of the Activity to be created

Source:
Returns:

last updated by Calvin Ho on Nov 21

Type
Promise.<void>

(static) exports.deleteMoment(req, res, next) → {Promise.<*>}

Delete an Activity

Parameters:
Name Type Description
req
Properties
Name Type Description
params.momentId:

the Activity (type: ObjectId) of interest

res
next
Source:
Returns:
Type
Promise.<*>

(static) exports.findResponsesByMomentId(req, res, next) → {Array}

Load Responses by Activity Id

Parameters:
Name Type Description
req
Properties
Name Type Description
params.momentId:

Activity of interest (type: ObjectId)

res
next
Source:
Returns:

an array of responses updated by Calvin Ho on 2/12/20

Type
Array

(static) exports.findResponsesByMomentIds(req, res, next) → {Array}

Load Responses by an array of Activity Ids

Parameters:
Name Type Description
req
Properties
Name Type Description
params.momentId:

Activity of interest (type: ObjectId)

res
next
Source:
Returns:

an array of responses updated by Calvin Ho on 2/12/20

Type
Array

(static) exports.loadChildActivities(req, res, next) → {array}

Loads all the child Activities hosted by the given program

Parameters:
Name Type Description
req
Properties
Name Type Description
params.programId:

Activity (type: ObjectId) of interest

res
next
Source:
Returns:

Array of child Activities

created by Calvin Ho 1/9/20

Type
array

(static) exports.loadMoment(req, res, next) → {Object}

Load an Activity

Parameters:
Name Type Description
req
res
next
req.params.momentId

(required): the Activity of interest (type: ObjectId)

Source:
Returns:

Object of the Moment

Type
Object

(static) exports.loadNearbyPeople(req, res, next) → {Promise.<void>}

Querying nearby users (obsolete as not using map at this point)

Parameters:
Name Type Description
req
res
next
Source:
Returns:
Type
Promise.<void>

(static) exports.loadNotes(req, res, next) → {Array}

Load all notes of a given Relationship

Parameters:
Name Type Description
req
res
next
req.query.relationship:

notes in this relationship (type: ObjectID) will be loaded

Source:
Returns:

an array of Notes object updated by Calvin Ho 2/14/2020

Type
Array

(static) exports.loadOnboardActivities(req, res, next) → {Promise.<void>}

Load the list of onboarding flow that the program (req.params.dependentMomentId) associates with

Parameters:
Name Type Description
req
res
next
Source:
Returns:

created by Calvin Ho 10/14/19

Type
Promise.<void>

(static) exports.loadPublicActivityByCategory(req, res, next) → {Promise.<void>}

for querying activity by category

Parameters:
Name Type Description
req
res
next
Source:
Returns:

last worked on by Calvin Ho on 3/20/2019

Type
Promise.<void>

(static) exports.loadPublicMoment(req, res, next) → {Moment}

load an Activity without authentication

Parameters:
Name Type Description
req
res
next
req.params.momentId

(required): the Moment (type ObjectId) of interest

Source:
Returns:

an object of the Moment

Type
Moment

(static) exports.loadSampleActivities(req, res, next) → {Array}

load all Activities shared in the marketplace

Parameters:
Name Type Description
req
res
next
req.query.version:

API version

Source:
Returns:

an array of marketplace activities req.body.categories is an array of categories the user is requesting. Typical use case in Picker expects an array of 1 category created by Calvin Ho 1/9/20

Type
Array

(static) exports.loadUserOnboardingAnswers(user:, showOnlyPublicProfile:) → {Array}

load all the onboarding answers of a given user

Parameters:
Name Type Description
user:

the user (type: ObjectID)

showOnlyPublicProfile:

whether to show only public profile or full private profile (type: Boolean)

Source:
Returns:

an array of Notes object updated by Calvin Ho 4/21/2020

Type
Array

(static) exports.sendRefreshNotification(io:, calendar:, title:, body:) → {Void}

send Push Notification messages about Calendar Reminders

Parameters:
Name Type Description
io:

socket io object

calendar:

the calendar object

title:

title of the Push message

body:

the body of the Push message

Source:
Returns:
Type
Void

(static) exports.submitResponse(req, res, next, req, res, next, req, res, next, req, res, next, req, res, next, req, res, next) → {Promise.<void>|Promise.<void>|Promise.<void>|String|String|Promise.<void>}

Submit various types of responses

Parameters:
Name Type Description
req
Properties
Name Type Description
body.moment:
res
next
req
Properties
Name Type Description
body.moment:

the Activity (type: ObjectId)

body.relationship

(optional): the relationship context (type: ObjectId)

body.calendar

(optional): the calendar context (type: ObjectId)

res
next
req
Properties
Name Type Description
body.moment:

the Activity (type: ObjectId)

res
next
req
Properties
Name Type Description
body.class:

null

body.dependentMomentId:

the parent Onboarding process (type: ObjectId)

res
next
req
Properties
Name Type Description
body.class:

response class (type: Number)

body.dependentMomentId:

the Onboarding process (type: ObjectId)

res
next
req
Properties
Name Type Description
body.class:

response class (type: Number)

body.dependentMomentId:

the Onboarding process/question of interest (type: ObjectId)

res
next
Source:
Returns:
  • Type
    Promise.<void>
  • Type
    Promise.<void>
  • Type
    Promise.<void>
  • 'success'

    Type
    String
  • 'success'

    Type
    String
  • Type
    Promise.<void>
Examples
User's Response to Old Restvo Features (response class id = null)
User's Response to an Activity or Content Calendar's Interactables (response class id = null)
the user's multiple choice responses to an Activity's list of questions
Parent/Child Relationship Record for Onboarding Processes (response class id = null)
an Onboarding Process choices of a parent onboarding process's question. Only responding to one question is allowed per record
Activity's Matching Config (50000) Settings (response class id = 50000)
an User Matching setting that defines which Onboarding Processes, which question in it, and the logical query operator it uses when matching users' responses

(static) exports.touchSchedulesContentCalendarItems(momentId:, operation:, userObjectIds:) → {Void}

add or remove users in the Activity's schedules' content calendar items

Parameters:
Name Type Description
momentId:

The Relationship (type: ObjectId) which hosts the Schedules

operation:

Operation (type: String)

userObjectIds:

an array of Users (type: [ObjectId])

Source:
Returns:

updated by Calvin Ho 1/13/20

Type
Void

(static) exports.updateMoment(req, res, next) → {String}

Update an Activity

Parameters:
Name Type Description
req
Properties
Name Type Description
body:

Activity to be updated

res
next
Source:
Returns:

"success" // last updated by Calvin Ho on Oct 6

Type
String

(static) exports.updateMomentUserLists(req, res, next) → {Promise.<void>}

update an Activity's users lists

Parameters:
Name Type Description
req
res
next
req.body.operation:

operation

req.body.user_lists:

array of list names: ["user_list_1", "user_list_2"] etc.

req.body.users:

array of user IDs or null to be added to the user lists if null, req.body.conversationId: participants in a chat room to be added to the user lists if null, req.body.conversations: list of conversations whose participants to be added to the user lists

req.body.momentId:

activity ID

req.body.calendarId:

calendar ID

Source:
Returns:

Modified by Calvin Ho: 9/5/2019

Type
Promise.<void>

(static) loadPublicActivities(req, res, next) → {Promise.<void>}

Obsolete. For future reference only

Parameters:
Name Type Description
req
res
next
Source:
Returns:
Type
Promise.<void>

(static) loadUserPreferences(req, res, next) → {Array}

load the list of onboarding questionnaires the user is required to respond to

Parameters:
Name Type Description
req
res
next
req.query.type:

type of Onboarding Process (type: Number). Type 2: Participant, Type 3: Organizer, Type 4: Leader

req.query.pageNum:

page number (type: Number)

Source:
Returns:

Array of Onboarding Processes created by Calvin Ho 5/7/19

Type
Array