Skip to content

Commit

Permalink
sending user, post, and comment count back to server when phoning home
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Sep 20, 2014
1 parent 8625e06 commit 0f00fad
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
10 changes: 10 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.9.5 “FixScope”

* Fixed `/settings` bug (thanks @steffenstraetz!).
* Code cleanup (thanks @wulfmeister!).
* Fixed upvote/downvote concurrency bug (thanks @spifd!).
* Renamed `SubmitServerCallbacks` to `SubmitMethodCallbacks` for posts and comments.
* Added `AfterSubmitMethodCallbacks` for posts and comments.
* Made notifications into their own `telescope-notifications` package.
* `telescope-update-prompt` package now sends user, post, and comment count when phoning home.

## v0.9.4 “UpdateScope”

* Removed unneeded allow insert on Posts and Comments.
Expand Down
2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
telescopeVersion = "0.9.4";
telescopeVersion = "0.9.5";
30 changes: 11 additions & 19 deletions packages/telescope-update-prompt/lib/client/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@ compareVersions = function (v1, v2) { // return true if v2 is newer than v1
Meteor.startup(function () {
Session.set('updateVersion', null);

if(Meteor.user() && isAdmin(Meteor.user())){
var url = 'http://version.telescopeapp.org/';
HTTP.get(url, {
params: {
currentVersion: telescopeVersion,
siteTitle: getSetting('title'),
siteUrl: getSiteUrl()
Meteor.call('phoneHome', function (error, result) {
// console.log(error)
// console.log(result)
if(result){
var currentVersion = telescopeVersion;
var newVersion = result.content;
var message = "";
if (compareVersions(currentVersion, newVersion)){
Session.set('updateVersion', newVersion);
}
}, function (error, result) {
if(result){
// console.log(result);
var currentVersion = telescopeVersion;
var newVersion = result.content;
var message = "";
if (compareVersions(currentVersion, newVersion)){
Session.set('updateVersion', newVersion);
}
}
});
}
}
});
});

heroModules.push({
Expand Down
27 changes: 27 additions & 0 deletions packages/telescope-update-prompt/lib/server/phone_home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Meteor.methods({
phoneHome: function () {

var url = 'http://version.telescopeapp.org/';

if(Meteor.user() && isAdmin(Meteor.user())){

this.unblock();
try {
var result = HTTP.get(url, {
params: {
currentVersion: telescopeVersion,
siteTitle: getSetting('title'),
siteUrl: getSiteUrl(),
users: Meteor.users.find().count(),
posts: Posts.find().count(),
comments: Comments.find().count()
}
})
return result;
} catch (e) {
// Got a network error, time-out or HTTP error in the 400 or 500 range.
return false;
}
}
}
})
4 changes: 4 additions & 0 deletions packages/telescope-update-prompt/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Package.onUse(function (api) {
'lib/client/templates/update_banner.css'
], ['client']);

api.add_files([
'lib/server/phone_home.js'
], ['server']);

api.export([
'compareVersions'
]);
Expand Down

0 comments on commit 0f00fad

Please sign in to comment.