Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9813daa
Convert queries to promises, useMasterKey() method => { useMasterKey:…
Jan 18, 2017
9fb9ca1
Convert find/first methods to promise formatting (part 2)
Jan 19, 2017
4d26d7a
remove extraneous method argument
Jan 19, 2017
59a0f94
/parse on server url
Jan 19, 2017
5a3d85d
fixed the SERVER_URL on heroku
Jan 19, 2017
bca2eab
Convert find method to promise styling
Jan 19, 2017
d7ff562
Commenting out push notifications for startDriving & stopDriving endp…
Jan 19, 2017
8fbc3f1
removed extraneous masterKey input arg
Jan 19, 2017
650e59b
Convert Save method to promise format
Jan 19, 2017
8b73244
Convert fetch to promise format (plus two missing save method calls)
Jan 19, 2017
fadb5fb
Convert destroyAll method to promise format
Jan 19, 2017
4453a5e
Convert Get method to promise format
Jan 20, 2017
6b533f4
FIREBASE CONFIG
Jan 20, 2017
62ba182
renabled push notifications in Driving.js (removed earlier for debugg…
Jan 20, 2017
6a47195
Push notification method upgraded to include master key
Jan 21, 2017
e90fbd2
Commented out iOS push notif for friends request, pushCallbackCounter…
Jan 21, 2017
810273b
Replaced two remaining instances of Parse.Cloud.useMasterKey with new…
Jan 23, 2017
7664b95
tiny push to force bcrypt update
Jan 23, 2017
5dba733
Added masterKey to friend request save(..) method call
Jan 23, 2017
d482468
output Role in afterSave for friend request
Jan 23, 2017
5664fd0
Inspect Requested User in friend request
Jan 23, 2017
c58a72f
Missing first param in save method call
Jan 23, 2017
2a39818
Updated any save(..) method calls to use the masterKey
Jan 23, 2017
e2d1706
Enabled VERBOSE logging, commented out Morgon (for now)
Jan 23, 2017
001abfa
Update to sendPush method; includes some debug calls
Jan 23, 2017
37ee1c4
Removed debug comments
Jan 23, 2017
f28ad88
Comment out push notif success logging
Jan 23, 2017
f4dc9c3
multiple friend request debugging
Jan 23, 2017
31ddb41
MasterKey in returned query call
Jan 24, 2017
8acb746
Update to verifyPhoneShortCode method: useMasterKey flag
Jan 24, 2017
b42d949
POFriendRequest: added masterKey to inner query
Jan 24, 2017
5c969bd
MasterKey updates, renamed result => res to avoid conflicts
Jan 24, 2017
b192f96
serverShortCode debug code
Jan 24, 2017
8345709
sendPhoneShortCode testing
Jan 24, 2017
6389981
sendPhoneShortCode testing
Jan 24, 2017
2277032
Twilio sendSMS => sendMessage
Jan 24, 2017
da01dac
Twilio promise format
Jan 24, 2017
1005c27
Updated Save method call in POFriendRelation; removed some debug comm…
Jan 25, 2017
e13ff23
masterKey on destroy method calls for Friend Requests and for Friend …
Jan 25, 2017
2d4552f
added a success reponse to sendPush method
Jan 25, 2017
5b800fe
debugging for multi push notifications
Jan 25, 2017
e77cc18
Push notif callbackCounter readded
Jan 25, 2017
277b468
Added MasterKey to userTotals find() method call; removed debug comments
Jan 25, 2017
a3a64c2
Mailgun Adapter config
Jan 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cloud/Community.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ function incrementCommunityTotalsForKey(community, key, response) {

CommunityTotals.getAllTimeTotals(community, function(allTimeTotals) {
allTimeTotals.increment(key);
allTimeTotals.save();
allTimeTotals.save({},{ useMasterKey: true });
if (--queryCount == 0) {
response.success();
}
});
CommunityTotals.getDailyTotals(community, currDate, function(dailyTotals) {
dailyTotals.increment(key);
dailyTotals.save();
dailyTotals.save({},{ useMasterKey: true });
if (--queryCount == 0) {
response.success();
}
});
CommunityTotals.getMonthlyTotals(community, currDate, function(monthlyTotals) {
monthlyTotals.increment(key);
monthlyTotals.save();
monthlyTotals.save({},{ useMasterKey: true });
if (--queryCount == 0) {
response.success();
}
Expand Down
32 changes: 16 additions & 16 deletions cloud/CommunityTotals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ exports.getAllTimeTotals = function(community, callback) {
var CommunityAllTimeTotals = Parse.Object.extend("CommunityAllTimeTotals");
var totalQuery = new Parse.Query(CommunityAllTimeTotals);
totalQuery.equalTo("community", community);
totalQuery.first({
success: function(object) {
totalQuery.first().then(
function(object) { // success
var allTimeTotals = object;
if (!allTimeTotals) {
console.log("CommunityAllTimeTotals not found, creating");
Expand All @@ -20,14 +20,14 @@ exports.getAllTimeTotals = function(community, callback) {
allTimeTotals.set("missedCallCount", 0);
allTimeTotals.set("missedOtherCount", 0);
allTimeTotals.set("community", community);
allTimeTotals.save();
allTimeTotals.save({},{ useMasterKey: true });
}
callback(allTimeTotals);
},
error: function(error) {
function(error) { // error
console.error("Got an error " + error.code + " : " + error.message);
}
});
);
}

exports.getDailyTotals = function(community, date, callback, failCallback) {
Expand All @@ -38,8 +38,8 @@ exports.getDailyTotals = function(community, date, callback, failCallback) {
queryDate.setHours(0, 0, 0, 0); //only year, month, day remain
totalQuery.equalTo("date", queryDate);
totalQuery.equalTo("community", community);
totalQuery.first({
success: function(object) {
totalQuery.first().then(
function(object) { //success
var dailyTotals = object;
if (!dailyTotals) {
console.log("CommunityDailyTotals not found, creating");
Expand All @@ -54,18 +54,18 @@ exports.getDailyTotals = function(community, date, callback, failCallback) {
dailyTotals.set("missedCallCount", 0);
dailyTotals.set("missedOtherCount", 0);
dailyTotals.set("community", community);
dailyTotals.save();
dailyTotals.save({},{ useMasterKey: true });
}
callback(dailyTotals);
},
error: function(error) {
function(error) { // error
console.error("Got an error " + error.code + " : " + error.message);

if (failCallback) {
failCallback(error);
}
}
});
);
}

exports.getMonthlyTotals = function(community, date, callback, failCallback) {
Expand All @@ -77,8 +77,8 @@ exports.getMonthlyTotals = function(community, date, callback, failCallback) {
queryDate.setDate(1); //only year, month remain
totalQuery.equalTo("date", queryDate);
totalQuery.equalTo("community", community);
totalQuery.first({
success: function(object) {
totalQuery.first().then(
function(object) {
var monthlyTotals = object;
if (!monthlyTotals) {
console.log("CommunityMonthlyTotals not found, creating");
Expand All @@ -93,18 +93,18 @@ exports.getMonthlyTotals = function(community, date, callback, failCallback) {
monthlyTotals.set("missedCallCount", 0);
monthlyTotals.set("missedOtherCount", 0);
monthlyTotals.set("community", community);
monthlyTotals.save();
monthlyTotals.save({},{ useMasterKey: true });
}
callback(monthlyTotals);
},
error: function(error) {
function(error) {
console.error("Got an error " + error.code + " : " + error.message);

if (failCallback) {
failCallback(error);
}
}
});
);
}

exports.updateTotals = function(trip, totals) {
Expand Down Expand Up @@ -136,6 +136,6 @@ exports.updateTotals = function(trip, totals) {
if (missedOtherCount) {
totals.increment("missedOtherCount", missedOtherCount);
}
totals.save();
totals.save({},{ useMasterKey: true });
}
}
11 changes: 5 additions & 6 deletions cloud/Installation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ Parse.Cloud.beforeSave(Parse.Installation, function(request, response) {
id: installation.get("user").id
});

userPointer.fetch({
success: function(user) {
userPointer.fetch({ useMasterKey: true }).then(
function(user) {
installation.set("channels", user.get("channels"));
response.success();
},
error: function(myObject, error) {
function(myObject, error) {
console.error("Unable to find user " + userPointer.id + " " + error.code + " : " + error.message);
response.error();
},
useMasterKey:true
});
}
);
} else {
response.success();
}
Expand Down
91 changes: 42 additions & 49 deletions cloud/POFriendRelation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ Parse.Cloud.beforeSave("POFriendRelation", function(request, response) {

var friendUser = request.object.get("friendUser");

var saveOptions = {
success: function(user) {
response.success();
},
error: function(user, error) {
response.error("Unable to save the user");
}
}

function addAndRemoveChannels(addedChannel, removedChannel) {
request.user.remove("channels", removedChannel);
request.user.save(null, {
success: function(user) {
request.user.save({},{ useMasterKey: true }).then(
function(user) {
request.user.addUnique("channels", addedChannel);
request.user.save(null, saveOptions);
request.user.save(null, { useMasterKey: true }).then(
function(user) {
response.success();
},
function(user, error) {
response.error("Unable to save the user");
}
);
},
error: function(user, error) {
function(user, error) {
response.error("Unable to save the user");
}
});
);
}

function updateChannelsIfNeeded() {
Expand All @@ -49,25 +47,23 @@ Parse.Cloud.beforeSave("POFriendRelation", function(request, response) {
if (request.user.id != friendUser.id) {
var roleQuery = new Parse.Query(Parse.Role);
roleQuery.equalTo("name", "user-" + request.user.id);
roleQuery.first({
success: function(role) {
Parse.Cloud.useMasterKey();
roleQuery.first({ useMasterKey: true }).then(
function(role) {
role.relation("users").add(friendUser);
role.save(null, {
success: function(user) {
role.save({},{ useMasterKey: true }).then(
function(user) {
updateChannelsIfNeeded();
},
error: function(user, error) {
function(user, error) {
response.error("Unable to save the role");
}
});
);
},
error: function(error) {
function(error) {
console.log("Failed to save role for friend relation with error " + error.code + " : " + error.message);
response.error("Unable to find the role");
},
useMasterKey:true
});
}
);
} else {
response.success();
}
Expand All @@ -85,34 +81,34 @@ Parse.Cloud.afterSave("POFriendRelation", function(request) {
var query = new Parse.Query("POFriendRequest");
query.equalTo("requestingUser", user);
query.equalTo("requestedUser", friendUser);
query.find({
success: function(results) {
query.find({ useMasterKey: true }).then(
function(results) {
if (results.length > 0) {
for (var i = 0; i < results.length; i++) {
results[i].destroy();
results[i].destroy({ useMasterKey: true });
}
}

var friendQuery = new Parse.Query("POFriendRequest");
friendQuery.equalTo("requestingUser", friendUser);
friendQuery.equalTo("requestedUser", user);
friendQuery.find({
success: function(results) {
friendQuery.find({ useMasterKey: true }).then(
function(results) {
if (results.length > 0) {
for (var i = 0; i < results.length; i++) {
results[i].destroy();
results[i].destroy({ useMasterKey: true });
}
}
},
error: function(error) {
function(error) {
console.log("error when destroying friend request");
}
});
);
},
error: function(error) {
function(error) {
console.log("error when destroying friend request");
}
});
);
});


Expand All @@ -122,27 +118,24 @@ Parse.Cloud.afterDelete("POFriendRelation", function(request) {
var userPointer = request.object.get("user");
var friendUserPointer = request.object.get("friendUser");

userPointer.fetch({
success: function(user) {
userPointer.fetch({ useMasterKey: true }).then(
function(user) {
var roleQuery = new Parse.Query(Parse.Role);
roleQuery.equalTo("name", "user-" + user.id);
roleQuery.first({
success: function(role) {
Parse.Cloud.useMasterKey();
roleQuery.first({ useMasterKey: true }).then(
function(role) {
role.relation("users").remove(friendUserPointer);
role.save();
role.save({},{ useMasterKey: true });
},
error: function(error) {
function(error) {
console.log("Failed to remove role for friend relation with error " + error.code + " : " + error.message);
},
useMasterKey:true
});
}
);
user.remove("channels", "friend-" + friendUserPointer.id);
user.save(null, {useMasterKey:true});
},
error: function(myObject, error) {
function(myObject, error) {
console.error("Unable to find user " + userPointer.id + " " + error.code + " : " + error.message);
},
useMasterKey: true
});
}
);
});
Loading