UNPKG

@speakr/speakr-module-services

Version:
37 lines (33 loc) 1.26 kB
"use strict"; const db = require('../../db'); module.exports = function(options){ let media_type = options.initiatives.user_created_media_type || options.initiatives.media_type; let link = options.initiatives.product == 'Content Distribution' ? options.initiatives.target_link : options.creatives.link; let config = { content:options.creatives.content, content_type: media_type, disclosure_type: options.initiatives.disclosure_type, platform_id: options.initiatives.platform_id, network_id: options.initiatives.network_id, account_id: options.invites.account_id, offer_price: options.invites.offer_price, initiative_id: options.invites.initiative_id, initiatives_accounts_invites_id: options.invites.id, image_link: options.initiatives.image_link, video_link: options.initiatives.video_link, youtube_video_title: options.creatives.youtube_video_title, submission_status: 'In review', link: link }; return db.creatives.create(config) .then(creatives => { if (!!creatives) { options.creatives = creatives; return Promise.resolve(options) } else { return Promise.resolve(options) } }).catch((err) => { return Promise.reject(err); }); };