From 1819a87b94dd1a9f512686f751062e9a5cec858a Mon Sep 17 00:00:00 2001 From: dotansimha Date: Wed, 25 Jan 2017 01:13:27 +0200 Subject: [PATCH] Step 13.35: Update creation of users stubs --- api/server/main.ts | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/api/server/main.ts b/api/server/main.ts index 6d7cd4cfb..50f99d160 100644 --- a/api/server/main.ts +++ b/api/server/main.ts @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { Picture } from './models'; import { Accounts } from 'meteor/accounts-base'; import { Users } from './collections/users'; @@ -12,43 +13,74 @@ Meteor.startup(() => { return; } + let picture = importPictureFromUrl({ + name: 'man1.jpg', + url: 'https://randomuser.me/api/portraits/men/1.jpg' + }); + Accounts.createUserWithPhone({ phone: '+972540000001', profile: { name: 'Ethan Gonzalez', - picture: 'https://randomuser.me/api/portraits/men/1.jpg' + pictureId: picture._id } }); + picture = importPictureFromUrl({ + name: 'lego1.jpg', + url: 'https://randomuser.me/api/portraits/lego/1.jpg' + }); + Accounts.createUserWithPhone({ phone: '+972540000002', profile: { name: 'Bryan Wallace', - picture: 'https://randomuser.me/api/portraits/lego/1.jpg' + pictureId: picture._id } }); + picture = importPictureFromUrl({ + name: 'woman1.jpg', + url: 'https://randomuser.me/api/portraits/women/1.jpg' + }); + Accounts.createUserWithPhone({ phone: '+972540000003', profile: { name: 'Avery Stewart', - picture: 'https://randomuser.me/api/portraits/women/1.jpg' + pictureId: picture._id } }); + picture = importPictureFromUrl({ + name: 'woman2.jpg', + url: 'https://randomuser.me/api/portraits/women/2.jpg' + }); + Accounts.createUserWithPhone({ phone: '+972540000004', profile: { name: 'Katie Peterson', - picture: 'https://randomuser.me/api/portraits/women/2.jpg' + pictureId: picture._id } }); + picture = importPictureFromUrl({ + name: 'man2.jpg', + url: 'https://randomuser.me/api/portraits/men/2.jpg' + }); + Accounts.createUserWithPhone({ phone: '+972540000005', profile: { name: 'Ray Edwards', - picture: 'https://randomuser.me/api/portraits/men/2.jpg' + pictureId: picture._id } }); }); + +function importPictureFromUrl(options: { name: string, url: string }): Picture { + const description = { name: options.name }; + + return Meteor.call('ufsImportURL', options.url, description, 'pictures'); +}