server/api/integrations/integrations.controller.js
/**
 * Update user's notification preferences as passed in the request body.
 *
 * @param {Koa context} ctx
 *
 * POST /preferences
 */
Update user's notification preferences as passed in the request body.
@param {Koa context} ctx

POST /preferences
Update user ' s notification preferences as passed in the request body . @param { Koa context } ctx POST / preferences
async function saveNotificationPreferences (ctx) {
  const preferences = ctx.request.body;
  ctx.state.user.notificationPreferences = preferences;
  ctx.state.user.setup.integrations = true;
  try {
    await ctx.state.user.save();
  } catch (e) {
    logger.error(
      `Failed to update notification preferences for ${
        ctx.state.user.rcs_id
      }: ${e}`
    );
    return ctx.badRequest(
      'There was an error updating your notification preferences.'
    );
  }
  logger.info(`Updated notification preferences for ${ctx.state.user.rcs_id}.`);
  ctx.ok({ updatedUser: ctx.state.user });
}
async function saveNotificationPreferences ( ctx ) { const preferences = ctx . request . body ; ctx . state . user . notificationPreferences = preferences ; ctx . state . user . setup . integrations = true ; try { await ctx . state . user . save ( ) ; } catch ( e ) { logger . error ( ` ${ ctx . state . user . rcs_id } ${ e } ` ) ; return ctx . badRequest ( 'There was an error updating your notification preferences.' ) ; } logger . info ( ` ${ ctx . state . user . rcs_id } ` ) ; ctx . ok ( { updatedUser : ctx . state . user } ) ; }
Update user's notification preferences as passed in the request body.
Update user ' s notification preferences as passed in the request body .