diff --git a/TODO b/TODO index 32ea4f7..e342d28 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,18 @@ + Browse/search users -User geolocalisation. Make sure logout users are redirected to the front page, always. -Check user security: do not allow user to change all their profile. Check filepicker secret/security thingy. Not sure it's cool. - Setting page -Thing needs serious design work. Finish notification template (for single notification) Complete Lexicon... Subscription process + email validation. + Check input security (not too long, invalid characters, injection...). -Fix Bug in Profile page. -Find a way to factorize some client code. \ No newline at end of file +Find a way to factorize some client code. + +Still have some presence with empty users!!! \ No newline at end of file diff --git a/client/main.js b/client/main.js index 570c059..af39fb5 100644 --- a/client/main.js +++ b/client/main.js @@ -35,5 +35,9 @@ Meteor.startup(function(){ }, Activities.activitiesPerPage); }); + Deps.autorun(function(){ + searchHandle = Meteor.subscribe("searchResults", Session.get("searchQuery", Meteor.user.searchResultsLimit)); + }); + // Meteor.subscribe('adminShowEveryone'); }); diff --git a/lib/collections/users.js b/lib/collections/users.js new file mode 100644 index 0000000..51a0c02 --- /dev/null +++ b/lib/collections/users.js @@ -0,0 +1,11 @@ +//User collection defined by default + +Meteor.users.allow({ + update: function(){ return false ;}, + remove: function(){ return false ;}, + insert: function(){ return false ;} +}); + +if(Meteor.isServer){ + Meteor.users._ensureIndex({'loc':"2d"}); +} diff --git a/server/fixtures.js b/server/fixtures.js index b799fa0..de64025 100644 --- a/server/fixtures.js +++ b/server/fixtures.js @@ -69,8 +69,40 @@ if(Questions.find().count() == 0){ "validation": {}, "value": "" }); +} + +if(Meteor.users.find({}).count() <= 2){ + var gender = "F"; + for(var i = 1 ; i < 10 ; i++){ + gender = (i % 2) ? "F" : "M"; + Meteor.users.insert({ + "createdAt": 1372216131137, + "emails": [ + { + "address": "user"+i+"@test.com", + "verified": false + } + ], + "lastseen": 1473524657763, + "online": 1, + "profile": { + "dob": "08-11-1982", + "gender": gender, + "name": "Fake User"+i + }, + "services": { + }, + "settings": { + "invisible": false + }, + "visible": 1, + "profile_complete": 1, + "loc": [22.2861678+Math.random(),114.1425153+Math.random()] + }); + } } + //if(Meteor.users.find({}).count() <= 4){ //// Meteor.users.insert({ //// "createdAt": 1372216131137, diff --git a/server/publications.js b/server/publications.js index 5701aa5..0def808 100644 --- a/server/publications.js +++ b/server/publications.js @@ -162,6 +162,36 @@ Meteor.publish('oneUserActivities', function(userId, limit){ } }); +Meteor.publish('searchResults', function(options,limit){ + if(!options||!this.userId){ + return false; + } + + var user = Meteor.users.findOne(this.userId); + var userloc = user.loc; + var friends = Friends.find({me: this.userId}); + var friendlist = []; + friends.forEach(function(f){ + friendlist.push(f.target); + }); + + options._id = {$nin: friendlist}; + if(userloc){ + options.loc = { + $near: { + $geometry: { + type: 'Point', + coordinates: userloc + } + } + }; + } + + options.visible = 1; + return Meteor.users.find(options, {sort: {lastseen: -1}, limit: limit, fields: Meteor.users.publicProfileInformation}); +}); + + /****************************** diff --git a/server/users.js b/server/users.js index 7c9b1e1..c37aebd 100644 --- a/server/users.js +++ b/server/users.js @@ -35,18 +35,21 @@ Meteor.methods({ if(!valid){ throw new Meteor.Error(400, 'Invalid Data'); } else { - // Account only visible if at least those two information are made available. - var visible = 0; - if(cleaned.name && cleaned.gender){ - visible = 1; - } - Meteor.users.update(Meteor.userId(), { + var change = { $set: { - profile : cleaned, - visible: visible + profile : cleaned } - }); + }; + // Update location if specify, set mongo 2d coordinates. + if(cleaned && cleaned.location){ + var loc = cleaned.location.split(','); + change.$set.loc = [parseFloat(loc[0]), parseFloat(loc[1])] + } + + Meteor.users.update(Meteor.userId(), change); + + Activities.insertActivity({ type: 'update_profile', diff --git a/test/unit/client/message.js b/test/unit/client/message.js deleted file mode 100644 index e69de29..0000000