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: 'noreply@socially.com',
          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);
        
    },

/**
 * Created by it on 4/6/16.
 */
import {loadSongs} from './load-songs.ts';
import {Meteor} from 'meteor/meteor';

Meteor.startup(loadSongs);
Example #12
0
import {loadParties} from './load-parties.ts';
import {Meteor} from 'meteor/meteor';

Meteor.startup(loadParties);
Example #13
0
import { Meteor } from 'meteor/meteor';
import { Todos } from './collections';

Meteor.publish('todos', function () {
  return Todos.find();
});
import { Parties } from '../../collections/parties';
import { Meteor } from 'meteor/meteor';

/*
 * Removed Meteor Autopublish
 */

function buildQuery(partyId: string) {
    return {
        $and: [
            { _id: partyId },
            { _id: { $exists: true}}
        ]
    }
}

Meteor.publish('parties', function() {
    // Retrieve all Parties from Mongo DB to MiniMongo
    return Parties.find();
})

Meteor.publish('party', function(partyId: string) {
    return Parties.find(buildQuery(partyId));
})
Template['paraviewSharedSessionControls'].onDestroyed(function() {
  Meteor.setTimeout(() => initializedComputation && initializedComputation.stop(), 200);
});
          { owner: this.userId },
          { owner: { $exists: true } }
        ],
      },
      {
        $and: [
          { invited: this.userId },
          { invited: { $exists: true } }
        ]
      }
    ]
  };

  if (partyId) {
    return { $and: [{ _id: partyId }, isAvailable] };
  }

  let searchRegEx = { '$regex': '.*' + (location || '') + '.*', '$options': 'i' };

  return { $and: [{ 'location.name': searchRegEx }, isAvailable] };
}

Meteor.publish('parties', function(options: Object, location: string) {
  Counts.publish(this, 'numberOfParties',
    Parties.find(buildQuery.call(this, null, location)), { noReady: true });
  return Parties.find(buildQuery.call(this, null, location), options);
});

Meteor.publish('party', function(partyId: string) {
  return Parties.find(buildQuery.call(this, partyId));
});
const getPartnerId = function getPartnerId(): string {
  return Meteor.user() && Meteor.user().partnerUser() && Meteor.user().partnerUser() && Meteor.user().partnerUser()._id;
};
Example #18
0
import {Meteor} from 'meteor/meteor';

Meteor.publish('users.me', function() {
    if (!this.userId) {
        return this.ready();
    }

    return Meteor.users.find(this.userId, {
        fields: {
            'services.github.email': 1,
            'services.facebook.email': 1,
            'services.facebook.first_name': 1,
            'profile': 1,
            'verified_emails': 1,
            '_id': 1
        }
    });
});
Example #19
0
File: main.ts Project: yk/soggler
import 'zone.js';
import 'reflect-metadata';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { MeteorObservable } from 'meteor-rxjs';
import { Meteor } from 'meteor/meteor';
import { AppModule } from './imports/app/app.module';

Meteor.startup(() => {
    platformBrowserDynamic().bootstrapModule(AppModule);
});
Example #20
0
import {Meteor} from 'meteor/meteor';
import {Teams, IncompleteTeams, Submissions} from '../imports/collections/collections';
import * as _u from 'lodash';

Meteor.publish('userData', function(){
    return Meteor.users.find(this.userId, {fields: {acceptToc: true}});
});

Meteor.publish('teams', function(taskId){
    return Teams.find({taskId: taskId, members: this.userId});
});

Meteor.publish('incompleteteams', function(taskId){
    return IncompleteTeams.find({taskId: taskId, 'members.userId': this.userId});
});

Meteor.publish('submissions', function(taskId){
    return Submissions.find({taskId: taskId, teamId: {$in: Teams.find({taskId: taskId, members: this.userId}).map(t => t._id)}});
});

Meteor.publish('leaderboard', function(taskId){
    return Submissions.find({taskId: taskId, score: {$exists: true}}, {fields: {taskId: true, teamName: true, score: true, createdAt: true}});
});

//publish files maybe
//https://github.com/VeliovGroup/Meteor-Files
Example #21
0
export let Tasks = new MongoObservable.Collection<TodoTask>('tasks');

Meteor.methods({
  'tasks.addTask': function(text: string) {
    Tasks.insert({
      text: text,
      checked: false,
      private: false,
      createdAt: new Date()
    })
  },

  'tasks.deleteTask': function(taskId) {
    Tasks.remove(taskId);
  },

  'tasks.setChecked': function(taskId, setChecked) {
    let task = Tasks.findOne(taskId);
    Tasks.update(taskId, {
      $set: { checked: setChecked }
    });
  },

  'tasks.setPrivate': function(taskId, setToPrivate) {
    let task = Tasks.findOne(taskId);
    Tasks.update(taskId, {
      $set: { private: setToPrivate }
    });
  }
});

if (Meteor.isServer) {
Example #22
0
import {Meteor} from 'meteor/meteor';
import {FAQ} from '../collections/questions';

Meteor.methods({
  // Create new FAQ Question
  createQuestion: function(question_title:string, question_answer:string){
    FAQ.insert({
      'question':question_title,
      'answer':question_answer
    });
  },

  // Delete FAQ Question
  deleteQuestion: function(questionID:string){
    FAQ.remove({"_id":questionID});
  },

  // Update FAQ Question Information
  updateQuestion: function(questionID:string, question_title:string, question_answer:string){
    FAQ.update({'_id':questionID}, {$set:{
      'question':question_title,
      'answer':question_answer
    }});
  }

});
Example #23
0
 remove: function() {
   let user = Meteor.user();
   return !!user;
 }
  Meteor.publish('parties', function(options, searchString) {
    const selector = {
      $or: [{
        // the public parties
        $and: [{
          public: true
        }, {
          public: {
            $exists: true
          }
        }]
      }, {
        // when logged in user is the owner
        $and: [{
          owner: this.userId
        }, {
          owner: {
            $exists: true
          }
        }]
      }, {
        // when logged in user is one of invited
        $and: [{
          invited: this.userId
        }, {
          invited: {
            $exists: true
          }
        }]
      }]
    };

    if (typeof searchString === 'string' && searchString.length) {
      selector.name = {
        $regex: `.*${searchString}.*`,
        $options : 'i'
      };
    }

    Counts.publish(this, 'numberOfParties', Parties.find(selector), {
      noReady: true
    });

    return Parties.find(selector, options);
  });
Example #25
0
import {Meteor} from "meteor/meteor";
import * as Poem from "./poem";
import * as User from "../user/user";
const log = console;

Meteor.methods({
    getPoemById (id) {
        return Poem.getById(id);
    },
    commentPoem (poemId, data) {
        return Poem.comment(poemId, data);
    },
    async likePoem (poemId) {

        let currentUserId = Meteor.userId();

        let isUserLikedPoem = await User.isLikedPoem(poemId);

        let results = await Promise.all([
            Poem.estimate(poemId, isUserLikedPoem),
            User.linkToLiked(currentUserId, poemId, isUserLikedPoem)
        ]);

        return results;
    }
});
Example #26
0
import {Meteor} from 'meteor/meteor';
import * as userHelpers from "../../both/helpers/user";
import * as poemHelpers from "../../both/helpers/poem";

Meteor.publish('users.online', userHelpers.getOnlineUsers);

Meteor.publish('users.challenge', function (options) {
    if (this.userId) {
        return userHelpers.getChallengeUsers(this.userId, options);
    } else {
        return null;
    }
});

Meteor.publish('users.rate', function () {
    if (this.userId) {
        return poemHelpers.getFinishedPoemsByUserId(this.userId);
    } else {
        return null;
    }
});

Meteor.publish(null, function () {
    if (this.userId) {
        return userHelpers.getAdvancedUser(this.userId);
    } else {
        return null;
    }
});
Example #27
0
    return true;
}

export function throwUnlessAuthed(self, logData) {
    if (!isAuthed(self)) {
        Logger.error(self, {type: 'not-authorized', requested: logData});
        throw new Meteor.Error("not-authorized");
    }
}

const denyAll = {
    insert() { return true; },
    update() { return true; },
    remove() { return true; },
};
export function denyAllCollectionMethods(collection) {
    collection.deny(denyAll);
}

Meteor.startup(function () {
    MeteorMethodsUnsafe({
        isAuthed: function() {
            return isAuthed(this);
        },

        getMyEmail: function() {
            return getEmail(this);
        }
    });
});
Template['paraviewSharedSessionControls'].onCreated(function () {
  this.subscribe('PVW.users.online');
  this.subscribe('PVW.PVUserCameraSettings.all');
});

Template['paraviewSharedSessionControls'].onRendered(function () {
  // templateInstance = this; // set page-scoped var
  waitForTruthy(Meteor.user, listenForInitializedSharedState);
  this.autorun(() => listenAndSyncPartnerCameraChanges());
});

Template['paraviewSharedSessionControls'].helpers({
  areOtherUsers(): boolean {
    const otherUsers = Meteor.users.find({
      username: {$ne: Meteor.user().username},
      'status.online': true
    });
    return otherUsers.count() > 0;
  },
  shareableUsers(): Mongo.Cursor<Meteor.User> {
    return Meteor.users.find({
      username: {$ne: Meteor.user().username},
      'status.online': true,
      'sharing.status': SharedState.INITIALIZED
    });
  },
  isInitialized(): boolean {
    return Meteor.user() && Meteor.user().hasSharingState(SharedState.INITIALIZED)
  },
  isProposing(): boolean {
import { Meteor } from 'meteor/meteor';
import {Parties} from '../collections/parties';

Meteor.startup(() => {
    // code to run on server at startup



    if (Parties.find().count() === 0) {
        
        console.log("Updating Data");

        var parties = [
            {
                'title': 'Dubstep-Free Zone...ITS WORKING !!!',
                'message': 'Can we please just for an evening not listen to dubstep.',
            },
            {
                'title': 'All dubstep all the time',
                'message': 'Get it on!',
            }
        ];

        for (var i = 0; i < parties.length; i++) {
            Parties.insert(parties[i]);
        }
    }

});
	update: function(project: Object, fields: any, modifier: any) {
		var user = Meteor.user();
		return !!user;
	},