diff --git a/api/server/main.ts b/api/server/main.ts index dcd79c4bc..209145d4e 100644 --- a/api/server/main.ts +++ b/api/server/main.ts @@ -1,6 +1,5 @@ import { Meteor } from 'meteor/meteor'; -import { Chats, Messages } from "../collections/whatsapp-collections"; -import * as moment from "moment"; +import { Users } from "../collections/whatsapp-collections"; import { initMethods } from "./methods"; import { Accounts } from 'meteor/accounts-base'; @@ -14,62 +13,39 @@ Meteor.startup(() => { SMS.twilio = Meteor.settings['twilio']; } - if (Chats.find({}).cursor.count() === 0) { - let chatId; + if (Users.collection.find().count()) return; - chatId = Chats.collection.insert({ - title: 'Ethan Gonzalez', + [{ + phone: '+972540000001', + profile: { + name: 'Ethan Gonzalez', picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg' - }); - - Messages.collection.insert({ - chatId: chatId, - content: 'You on your way?', - createdAt: moment().subtract(1, 'hours').toDate() - }); - - chatId = Chats.collection.insert({ - title: 'Bryan Wallace', + } + }, { + phone: '+972540000002', + profile: { + name: 'Bryan Wallace', picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg' - }); - - Messages.collection.insert({ - chatId: chatId, - content: 'Hey, it\'s me', - createdAt: moment().subtract(2, 'hours').toDate() - }); - - chatId = Chats.collection.insert({ - title: 'Avery Stewart', + } + }, { + phone: '+972540000003', + profile: { + name: 'Avery Stewart', picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg' - }); - - Messages.collection.insert({ - chatId: chatId, - content: 'I should buy a boat', - createdAt: moment().subtract(1, 'days').toDate() - }); - - chatId = Chats.collection.insert({ - title: 'Katie Peterson', + } + }, { + phone: '+972540000004', + profile: { + name: 'Katie Peterson', picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg' - }); - - Messages.collection.insert({ - chatId: chatId, - content: 'Look at my mukluks!', - createdAt: moment().subtract(4, 'days').toDate() - }); - - chatId = Chats.collection.insert({ - title: 'Ray Edwards', + } + }, { + phone: '+972540000005', + profile: { + name: 'Ray Edwards', picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg' - }); - - Messages.collection.insert({ - chatId: chatId, - content: 'This is wicked good ice cream.', - createdAt: moment().subtract(2, 'weeks').toDate() - }); - } + } + }].forEach(user => { + Accounts.createUserWithPhone(user); + }); });