Example #1
0
  invite: function (partyId:string, userId:string) {
    check(partyId, String);
    check(userId, String);
 
    let party = Parties.findOne(partyId);
 
    if (!party)
      throw new Meteor.Error('404', 'No such party!');
 
    if (party.public)
      throw new Meteor.Error('400', 'That party is public. No need to invite people.');
 
    if (party.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');
 
    if (userId !== party.owner && (party.invited || []).indexOf(userId) == -1) {
      Parties.update(partyId, {$addToSet: {invited: userId}});
 
      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));
 
      if (Meteor.isServer && to) {
        Email.send({
          from: '*****@*****.**',
          to: to,
          replyTo: from || undefined,
          subject: 'PARTY: ' + party.name,
          text: `Hi, I just invited you to ${party.name} on Socially.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
  invite: function (trackId:string, userId:string) {
    check(trackId, String);
    check(userId, String);

    let track = Tracks.collection.findOne(trackId);

    if (!track)
      throw new Meteor.Error('404', 'No such track!');

    if (track.public)
      throw new Meteor.Error('400', 'That track is public. No need to invite people.');

    if (track.owner !== this.userId)
      throw new Meteor.Error('403', 'No permissions!');

    if (userId !== track.owner && (track.invited || []).indexOf(userId) == -1) {
      Tracks.collection.update(trackId, {$addToSet: {invited: userId}});

      let from = getContactEmail(Meteor.users.findOne(this.userId));
      let to = getContactEmail(Meteor.users.findOne(userId));

      if (Meteor.isServer && to) {
        Email.send({
          from: '*****@*****.**',
          to: to,
          replyTo: from || undefined,
          subject: 'TRACK: ' + track.name,
          text: `Hi, I just invited you to ${track.name} on Beetrut.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}\n`
        });
      }
    }
  },
  invite: function (user: Invitation) {
    // check(partyId, String);
    // check(userId, String);

    // let party = Parties.findOne(partyId);

    // if (!party)
    //   throw new Meteor.Error('404', 'No such party!');

    // if (party.public)
    //   throw new Meteor.Error('400', 'That party is public. No need to invite people.');

    // if (party.owner !== this.userId)
    //   throw new Meteor.Error('403', 'No permissions!');

      // Parties.update(partyId, {$addToSet: {invited: userId}});
      let token = Random.hexString( 16 );
      let message = {
        subject: "Invitation",
        text: `Hi, I just invited you to be an user in my brand new app!.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}acceptinvitation/${token}\n`
      };

      Invitations.insert({
      // company: ['', Validators.required],
      company: user.company,
      name: user.name,
      last_name: user.last_name,
      email: user.email,
      role: user.role,
      phone: user.phone,
      address: user.address,
      city: user.city,
      state: user.state,
      postal_code: user.postal_code,
      token: token,
      invitation_date: user.invitation_date,
      message: message,
      invited_by: Meteor.userId
    });
      let _from = "*****@*****.**";
      let to = user.email;
      
      // console.log(to, Meteor.isServer, user, token);
      if (Meteor.isServer && to) {
        Email.send({
          from: _from,
          to: to,
          replyTo: _from || undefined,
          subject: message.subject,
          text: message.text
        });
        // console.log(token);
      }
  },
 this.autorun(() => {
   const found = Images.findOne(imageId);
   if (found) {
     // XXX Make sure to use proper absolute url of an image
     // jalik:ufs sets an absolute path of a file (let's say localhost:3000)
     // Might be a problem when running an app in a different port (development)
     if (!Meteor.isCordova) {
       imageUrl = found.url;
     } else {
       const path = `ufs/${found.store}/${found._id}/${found.name}`;
       imageUrl = Meteor.absoluteUrl(path);
     }
   }
 }, true);
function DisplayImageFilter(image) {
  if (!image) {
    return image;
  }

  // leave it as it is for the web view
  if (!Meteor.isCordova) {
    return image.url;
  }

  // create new path of an image
  const path = `ufs/${image.store}/${image._id}/${image.name}`;
  return Meteor.absoluteUrl(path);
}
export function invite(partyId, userId) {
  check(partyId, String);
  check(userId, String);

  if (!this.userId) {
    throw new Meteor.Error(400, 'You have to be logged in!');
  }

  const party = Parties.findOne(partyId);

  if (!party) {
    throw new Meteor.Error(404, 'No such party!');
  }

  if (party.owner !== this.userId) {
    throw new Meteor.Error(404, 'No permissions!');
  }

  if (party.public) {
    throw new Meteor.Error(400, 'That party is public. No need to invite people.');
  }

  if (userId !== party.owner && ! _.contains(party.invited, userId)) {
    Parties.update(partyId, {
      $addToSet: {
        invited: userId
      }
    });

    const replyTo = getContactEmail(Meteor.users.findOne(this.userId));
    const to = getContactEmail(Meteor.users.findOne(userId));

    if (Meteor.isServer && to) {
      Email.send({
        to,
        replyTo,
        from: '*****@*****.**',
        subject: `PARTY: ${party.title}`,
        text: `
          Hey, I just invited you to ${party.title} on Socially.
          Come check it out: ${Meteor.absoluteUrl()}
        `
      });
    }
  }
}
 private static _getServerURL():{result: string, fromMeteor: boolean} {
   let result = '';
   let configured = '';
   let fromMeteor = false;
   if (typeof __meteor_runtime_config__ === 'undefined') {
     console.warn(' __meteor_runtime_config__ is undefined')
   } else {
     if ( typeof __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL !== 'undefined')
       configured =  __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL;
   }
   try {
     result = Meteor.absoluteUrl();
     fromMeteor = true;
   } catch (e) {
     result = configured;
   }
   return {result, fromMeteor};
 }
  transform(party: Party) {
    if (!party) {
      return;
    }

    let imageUrl: string;
    let imageId: string = (party.images || [])[0];

    const found = Images.findOne(imageId);

    if (found) {
      if (!Meteor.isCordova) {
        imageUrl = found.url;
      } else {
        const path = `ufs/${found.store}/${found._id}/${found.name}`;
        imageUrl = Meteor.absoluteUrl(path);
      }
    }

    return imageUrl;
  }
export let generateData = Promise.denodeify((cb) => {
  const testConnection = Meteor.connect(Meteor.absoluteUrl());
  testConnection.call('tasks', cb);
});
Example #10
0

// Covers https://github.com/meteor-typings/meteor/issues/20
Rooms.find().count(true);


// Covers https://github.com/meteor-typings/meteor/issues/21
if (Meteor.isTest) {
    // do something
}

DDPRateLimiter.addRule({ userId: 'foo' }, 5, 1000);

DDPRateLimiter.addRule({ userId: userId => userId == 'foo' }, 5, 1000);

Template.instance().autorun(() => { }).stop();

// Mongo Collection without connection (local collection)
const collectionWithoutConnection = new Mongo.Collection<MonkeyDAO>("monkey", {
    connection: null
});

}  // End of namespace

// absoluteUrl
Meteor.absoluteUrl('/sub', {rootUrl: 'http://wonderful.com'});
Meteor.absoluteUrl.defaultOptions = {
  rootUrl: 'http://123.com',
  secure: false
};