mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
disable firebase syncing for tavern
This commit is contained in:
@@ -29,7 +29,7 @@ dbGroups.findEach({}, {_id: 1, members: 1, leader: 1}, {batchSize: 500}, functio
|
||||
if(err) throw err;
|
||||
|
||||
// If leader has deleted account
|
||||
if(count < 1) {
|
||||
if(count < 1 && (group._id !== 'habitrpg')) {
|
||||
dbGroups.update({
|
||||
_id: group._id
|
||||
}, {
|
||||
|
||||
@@ -29,7 +29,7 @@ dbGroups.findEach({}, {_id: 1, members: 1}, {batchSize: 500}, function(err, grou
|
||||
dbUsers.count({_id: member}, function(err, count){
|
||||
if(err) throw err;
|
||||
|
||||
if(count < 1) {
|
||||
if(count < 1 && (group._id !== 'habitrpg')) {
|
||||
countUsers++;
|
||||
console.log('User: ', countUsers);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ firebaseRef.authWithCustomToken('firebase-secret', function(err, authData){
|
||||
|
||||
dbGroups.findEach({}, {_id: 1, members: 1}, {batchSize: 100}, function(err, group){
|
||||
if(err) throw err;
|
||||
if(group._id !== 'habitrpg') return;
|
||||
|
||||
countGroups++;
|
||||
console.log('Group: ', countGroups);
|
||||
|
||||
@@ -19,6 +19,8 @@ var api = module.exports = {};
|
||||
api.updateGroupData = function(group){
|
||||
if(!isProd) return;
|
||||
if(!group) throw new Error('group is required.');
|
||||
// Return in case of tavern (comparison working because we use string for _id)
|
||||
if(group._id === 'habitrpg') return;
|
||||
|
||||
firebaseRef.child('rooms/' + group._id)
|
||||
.set({
|
||||
@@ -30,6 +32,7 @@ api.addUserToGroup = function(groupId, userId){
|
||||
if(!isProd) return;
|
||||
// TODO is throw ok? we don't have callbacks
|
||||
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
||||
if(groupId === 'habitrpg') return;
|
||||
|
||||
firebaseRef.child('members/' + groupId + '/' + userId)
|
||||
.set(true);
|
||||
@@ -41,6 +44,7 @@ api.addUserToGroup = function(groupId, userId){
|
||||
api.removeUserFromGroup = function(groupId, userId){
|
||||
if(!isProd) return;
|
||||
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
||||
if(groupId === 'habitrpg') return;
|
||||
|
||||
firebaseRef.child('members/' + groupId + '/' + userId)
|
||||
.remove();
|
||||
@@ -51,7 +55,8 @@ api.removeUserFromGroup = function(groupId, userId){
|
||||
|
||||
api.deleteGroup = function(groupId){
|
||||
if(!isProd) return;
|
||||
if(!groupId) throw new Error('groupId is required.');7
|
||||
if(!groupId) throw new Error('groupId is required.');
|
||||
if(groupId === 'habitrpg') return;
|
||||
|
||||
firebaseRef.child('rooms/' + groupId)
|
||||
.remove();
|
||||
|
||||
@@ -444,7 +444,7 @@ GroupSchema.methods.leave = function(user, keep, mainCb){
|
||||
}
|
||||
|
||||
update['$inc'] = {memberCount: -1};
|
||||
Group.update({_id:group._id}, update, cb);
|
||||
Group.update({_id: group._id}, update, cb);
|
||||
}
|
||||
}
|
||||
], function(err){
|
||||
@@ -473,14 +473,15 @@ module.exports.schema = GroupSchema;
|
||||
var Group = module.exports.model = mongoose.model("Group", GroupSchema);
|
||||
|
||||
// initialize tavern if !exists (fresh installs)
|
||||
Group.count({_id:'habitrpg'},function(err,ct){
|
||||
Group.count({_id: 'habitrpg'}, function(err, ct){
|
||||
if (ct > 0) return;
|
||||
|
||||
new Group({
|
||||
_id: 'habitrpg',
|
||||
chat: [],
|
||||
leader: '9',
|
||||
name: 'HabitRPG',
|
||||
type: 'guild',
|
||||
privacy:'public'
|
||||
privacy: 'public'
|
||||
}).save();
|
||||
});
|
||||
Reference in New Issue
Block a user