|
1 | 1 | import { Meteor } from 'meteor/meteor'; |
2 | | -import { Picture } from './models'; |
3 | 2 | import { Accounts } from 'meteor/accounts-base'; |
4 | | -import { Users } from './collections/users'; |
5 | 3 |
|
6 | 4 | Meteor.startup(() => { |
7 | 5 | if (Meteor.settings) { |
8 | 6 | Object.assign(Accounts._options, Meteor.settings['accounts-phone']); |
9 | 7 | SMS.twilio = Meteor.settings['twilio']; |
10 | 8 | } |
11 | | - |
12 | | - if (Users.collection.find().count() > 0) { |
13 | | - return; |
14 | | - } |
15 | | - |
16 | | - let picture = importPictureFromUrl({ |
17 | | - name: 'man1.jpg', |
18 | | - url: 'https://randomuser.me/api/portraits/men/1.jpg' |
19 | | - }); |
20 | | - |
21 | | - Accounts.createUserWithPhone({ |
22 | | - phone: '+972540000001', |
23 | | - profile: { |
24 | | - name: 'Ethan Gonzalez', |
25 | | - pictureId: picture._id |
26 | | - } |
27 | | - }); |
28 | | - |
29 | | - picture = importPictureFromUrl({ |
30 | | - name: 'lego1.jpg', |
31 | | - url: 'https://randomuser.me/api/portraits/lego/1.jpg' |
32 | | - }); |
33 | | - |
34 | | - Accounts.createUserWithPhone({ |
35 | | - phone: '+972540000002', |
36 | | - profile: { |
37 | | - name: 'Bryan Wallace', |
38 | | - pictureId: picture._id |
39 | | - } |
40 | | - }); |
41 | | - |
42 | | - picture = importPictureFromUrl({ |
43 | | - name: 'woman1.jpg', |
44 | | - url: 'https://randomuser.me/api/portraits/women/1.jpg' |
45 | | - }); |
46 | | - |
47 | | - Accounts.createUserWithPhone({ |
48 | | - phone: '+972540000003', |
49 | | - profile: { |
50 | | - name: 'Avery Stewart', |
51 | | - pictureId: picture._id |
52 | | - } |
53 | | - }); |
54 | | - |
55 | | - picture = importPictureFromUrl({ |
56 | | - name: 'woman2.jpg', |
57 | | - url: 'https://randomuser.me/api/portraits/women/2.jpg' |
58 | | - }); |
59 | | - |
60 | | - Accounts.createUserWithPhone({ |
61 | | - phone: '+972540000004', |
62 | | - profile: { |
63 | | - name: 'Katie Peterson', |
64 | | - pictureId: picture._id |
65 | | - } |
66 | | - }); |
67 | | - |
68 | | - picture = importPictureFromUrl({ |
69 | | - name: 'man2.jpg', |
70 | | - url: 'https://randomuser.me/api/portraits/men/2.jpg' |
71 | | - }); |
72 | | - |
73 | | - Accounts.createUserWithPhone({ |
74 | | - phone: '+972540000005', |
75 | | - profile: { |
76 | | - name: 'Ray Edwards', |
77 | | - pictureId: picture._id |
78 | | - } |
79 | | - }); |
80 | 9 | }); |
81 | | - |
82 | | -function importPictureFromUrl(options: { name: string, url: string }): Picture { |
83 | | - const description = { name: options.name }; |
84 | | - |
85 | | - return Meteor.call('ufsImportURL', options.url, description, 'pictures'); |
86 | | -} |
0 commit comments