<commit_before>Items = new Meteor.Collection('items');

Meteor.methods({
	addPost: function(p) {
		console.log('called');
		p.sellerId = this.userId;
		p.seller = Meteor.users.findOne({
			_id: Meteor.userId()
		}).profile.name;
		p.sold = false;
                p.fbId = Meteor.user().services.facebook.id;
		p.time = new Date();
		p.score = p.time.getTime();
		//p.imageUrl = s3ImageUpload(this.userId, p.image);
		var temp = Items.insert(p);
		//	if (p.imageUrl == null)
		//		return -1;
		if (p.title == null)
			return -2;
		else if (p.description == null)
			return -3;
		else if (p.feeds == null)
			return -4;
		/*
			es.create({
				index: 'base',
				type: 'item',
				body: {
					name: p.title,
					desc: p.description,
					image: p.imageUrl
				}
			});
			*/
		console.log(temp);
		//linker. pushes the id of the item, and the id of the category
		_.each(p.feeds, function(feed) {
			Feeds.update({
				_id: feed
			}, {
				$push: {
					items: temp
				}
			});
		});
		return temp;
	},
	addPostImage: function(id, url) {
		return Items.update({
			_id: feed
		}, {
			$set: {
				imageUrl: url
			}
		});
	},
	addRequest: function(p) {
		p.sellerId = this.userId;
		p.seller = Meteor.users.findOne({
			_id: Meteor.userId()
		}).profile.name;
		p.time = new Date();
		p.score = p.time.getTime();
                p.fbId = Meteor.user().services.facebook.id;
		if (p.description == null)
			return -3;
		else if (p.feeds == null)
			return -4;
		var temp = Items.insert(p);
		_.each(p.feeds, function(feed) {
			Feeds.update({
				_id: feed
			}, {
				$push: {
					items: temp
				}
			});
		});
		return temp;
	},
	addComment: function(t, id) {
		item = Items.findOne({
			_id: id
		});
		comments = item.comments;
		if (comments == undefined)
			comments = [];
		url = Meteor.users.findOne({
			_id: this.userId
		}).profile.img;
		toAdd = [this.userId, t, url, new Date()];<commit_msg>Fixed facebook undefined because services isn't published to client<commit_after>Items = new Meteor.Collection('items');

Meteor.methods({
	addPost: function(p) {
		console.log('called');
		p.sellerId = this.userId;
		p.seller = Meteor.users.findOne({
			_id: Meteor.userId()
		}).profile.name;
		p.sold = false;
		p.fbId = Meteor.user().profile.fbId;
		p.time = new Date();
		p.score = p.time.getTime();
		//p.imageUrl = s3ImageUpload(this.userId, p.image);
		var temp = Items.insert(p);
		//	if (p.imageUrl == null)
		//		return -1;
		if (p.title == null)
			return -2;
		else if (p.description == null)
			return -3;
		else if (p.feeds == null)
			return -4;
		/*
			es.create({
				index: 'base',
				type: 'item',
				body: {
					name: p.title,
					desc: p.description,
					image: p.imageUrl
				}
			});
			*/
		console.log(temp);
		//linker. pushes the id of the item, and the id of the category
		_.each(p.feeds, function(feed) {
			Feeds.update({
				_id: feed
			}, {
				$push: {
					items: temp
				}
			});
		});
		return temp;
	},
	addPostImage: function(id, url) {
		return Items.update({
			_id: feed
		}, {
			$set: {
				imageUrl: url
			}
		});
	},
	addRequest: function(p) {
		p.sellerId = this.userId;
		p.seller = Meteor.users.findOne({
			_id: Meteor.userId()
		}).profile.name;
		p.time = new Date();
		p.score = p.time.getTime();
		p.fbId = Meteor.user().profile.fbId;
		if (p.description == null)
			return -3;
		else if (p.feeds == null)
			return -4;
		var temp = Items.insert(p);
		_.each(p.feeds, function(feed) {
			Feeds.update({
				_id: feed
			}, {
				$push: {
					items: temp
				}
			});
		});
		return temp;
	},
	addComment: function(t, id) {
		item = Items.findOne({
			_id: id
		});
		comments = item.comments;
		if (comments == undefined)
			comments = [];
		url = Meteor.users.findOne({
			_id: this.userId
		}).profile.img;
		toAdd = [this.userId, t, url, new Date()];
{'fraction_non_alphanumeric': 0.1759937238493724, 'fraction_numerical': 0.0036610878661087866, 'mean_word_length': 2.442844284428443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3700782', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1489, 'n_words': 329}