insert: function(project: Object) {
		var user = Meteor.user();
		return !!user;
	},
Example #2
0
Meteor.methods({
  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`
        });
      }
    }
  },
  reply: function(partyId: string, rsvp: string) {
    check(partyId, String);
    check(rsvp, String);

    if (!this.userId)
      throw new Meteor.Error('403', 'You must be logged-in to reply');
 
    if (['yes', 'no', 'maybe'].indexOf(rsvp) === -1)
      throw new Meteor.Error('400', 'Invalid RSVP');
 
    let party = Parties.findOne({ _id: partyId });
 
    if (!party)
      throw new Meteor.Error('404', 'No such party');
 
    if (party.owner === this.userId)
      throw new Meteor.Error('500', 'You are the owner!');
 
    if (!party.public && (!party.invited || party.invited.indexOf(this.userId) == -1))
      throw new Meteor.Error('403', 'No such party'); // its private, but let's not tell this to the user
 
    let rsvpIndex = party.rsvps ? party.rsvps.findIndex((rsvp) => rsvp.userId === this.userId) : -1;
 
    if (rsvpIndex !== -1) {
      // update existing rsvp entry
      if (Meteor.isServer) {
        // update the appropriate rsvp entry with $
        Parties.update(
          { _id: partyId, 'rsvps.userId': this.userId },
          { $set: { 'rsvps.$.response': rsvp } });
      } else {
        // minimongo doesn't yet support $ in modifier. as a temporary
        // workaround, make a modifier that uses an index. this is
        // safe on the client since there's only one thread.
        let modifier = { $set: {} };
        modifier.$set['rsvps.' + rsvpIndex + '.response'] = rsvp;
 
        Parties.update(partyId, modifier);
      }
    } else {
      // add new rsvp entry
      Parties.update(partyId,
        { $push: { rsvps: { userId: this.userId, response: rsvp } } });
    }
  }
});
import {Meteor} from 'meteor/meteor';
import {GamificationGrid, GamificationRecords} from './collection';


Meteor.publish('gamification.records', function () {
    console.log('publishing records')
    return GamificationRecords.find({
        user_id: this.userId
    });
});

Meteor.publish('gamification.grid', function() {
    console.log('publishing grid')
    return GamificationGrid.find({
        user_id: this.userId
    });
});
Example #4
0
 update: function() {
   let user = Meteor.user();
   return !!user;
 },
Example #5
0
 insert: function() {
   let user = Meteor.user();
   return !!user;
 },
const listenAndSyncPartnerCameraChanges = function listenAndSyncPartnerCameraChanges(): void {
  const userCameraSettings = PVUserCameraSettings.findOne({userId: getPartnerId()}),
        isUserCollaborating = Meteor.user() && Meteor.user().hasSharingState(SharedState.SHARED) || Meteor.user() && Meteor.user().hasSharingState(SharedState.JOINED);
  if (!isUserCollaborating || !userCameraSettings) return; // guard
  updateCamera(userCameraSettings.cameraSettings, cb('Error calling PV.updateCamera()', 'Successfully called PV.updateCamera()'));
};
Example #7
0
import {SNTgroups} from '../../both/collections/snt';
import {Meteor} from 'meteor/meteor';

// Return all snt groups
Meteor.publish('snt_groups', function(){
  return SNTgroups.find();
});
Example #8
0
import {Parties} from '../collections/parties';
import {Meteor} from 'meteor/meteor';

Meteor.publish('uninvited', function(partyId: string) {
    let party = Parties.findOne(partyId);

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

    return Meteor.users.find({
        _id: {
            $nin: party.invited || [],
            $ne: this.userId
        }
    });
});
Example #9
0
import { Meteor }     from 'meteor/meteor';
import { Quotes }     from '../collections/quotes';
import quotesData     from './quotes.data';

// Init Data if (Quotes) Collection is empty
Meteor.startup(() => {
  if (Quotes.find().count() == 0)
    quotesData.forEach(quote => Quotes.insert(quote) );
});
Example #10
0
import { Meteor } from 'meteor/meteor';
import {Locales} from '../imports/api/locales';


Meteor.publish('locales', function () {


    return Locales.find({});


});

Meteor.methods({


    'locales.insert'(locale) {
        var self = this;
        Locales.insert(locale);
    },
    'locales.remove'(localeId) {

        Locales.remove(localeId);
    },
    'locales.update'(localeId, action) {
        
        Locales.update(localeId, action);
        
    },