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(err) throw err;
|
||||||
|
|
||||||
// If leader has deleted account
|
// If leader has deleted account
|
||||||
if(count < 1) {
|
if(count < 1 && (group._id !== 'habitrpg')) {
|
||||||
dbGroups.update({
|
dbGroups.update({
|
||||||
_id: group._id
|
_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){
|
dbUsers.count({_id: member}, function(err, count){
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
|
||||||
if(count < 1) {
|
if(count < 1 && (group._id !== 'habitrpg')) {
|
||||||
countUsers++;
|
countUsers++;
|
||||||
console.log('User: ', 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){
|
dbGroups.findEach({}, {_id: 1, members: 1}, {batchSize: 100}, function(err, group){
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
if(group._id !== 'habitrpg') return;
|
||||||
|
|
||||||
countGroups++;
|
countGroups++;
|
||||||
console.log('Group: ', countGroups);
|
console.log('Group: ', countGroups);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ var api = module.exports = {};
|
|||||||
api.updateGroupData = function(group){
|
api.updateGroupData = function(group){
|
||||||
if(!isProd) return;
|
if(!isProd) return;
|
||||||
if(!group) throw new Error('group is required.');
|
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)
|
firebaseRef.child('rooms/' + group._id)
|
||||||
.set({
|
.set({
|
||||||
@@ -30,6 +32,7 @@ api.addUserToGroup = function(groupId, userId){
|
|||||||
if(!isProd) return;
|
if(!isProd) return;
|
||||||
// TODO is throw ok? we don't have callbacks
|
// TODO is throw ok? we don't have callbacks
|
||||||
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
||||||
|
if(groupId === 'habitrpg') return;
|
||||||
|
|
||||||
firebaseRef.child('members/' + groupId + '/' + userId)
|
firebaseRef.child('members/' + groupId + '/' + userId)
|
||||||
.set(true);
|
.set(true);
|
||||||
@@ -41,6 +44,7 @@ api.addUserToGroup = function(groupId, userId){
|
|||||||
api.removeUserFromGroup = function(groupId, userId){
|
api.removeUserFromGroup = function(groupId, userId){
|
||||||
if(!isProd) return;
|
if(!isProd) return;
|
||||||
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
if(!userId || !groupId) throw new Error('groupId, userId are required.');
|
||||||
|
if(groupId === 'habitrpg') return;
|
||||||
|
|
||||||
firebaseRef.child('members/' + groupId + '/' + userId)
|
firebaseRef.child('members/' + groupId + '/' + userId)
|
||||||
.remove();
|
.remove();
|
||||||
@@ -51,7 +55,8 @@ api.removeUserFromGroup = function(groupId, userId){
|
|||||||
|
|
||||||
api.deleteGroup = function(groupId){
|
api.deleteGroup = function(groupId){
|
||||||
if(!isProd) return;
|
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)
|
firebaseRef.child('rooms/' + groupId)
|
||||||
.remove();
|
.remove();
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ GroupSchema.methods.leave = function(user, keep, mainCb){
|
|||||||
}
|
}
|
||||||
|
|
||||||
update['$inc'] = {memberCount: -1};
|
update['$inc'] = {memberCount: -1};
|
||||||
Group.update({_id:group._id}, update, cb);
|
Group.update({_id: group._id}, update, cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
], function(err){
|
], function(err){
|
||||||
@@ -473,14 +473,15 @@ module.exports.schema = GroupSchema;
|
|||||||
var Group = module.exports.model = mongoose.model("Group", GroupSchema);
|
var Group = module.exports.model = mongoose.model("Group", GroupSchema);
|
||||||
|
|
||||||
// initialize tavern if !exists (fresh installs)
|
// initialize tavern if !exists (fresh installs)
|
||||||
Group.count({_id:'habitrpg'},function(err,ct){
|
Group.count({_id: 'habitrpg'}, function(err, ct){
|
||||||
if (ct > 0) return;
|
if (ct > 0) return;
|
||||||
|
|
||||||
new Group({
|
new Group({
|
||||||
_id: 'habitrpg',
|
_id: 'habitrpg',
|
||||||
chat: [],
|
chat: [],
|
||||||
leader: '9',
|
leader: '9',
|
||||||
name: 'HabitRPG',
|
name: 'HabitRPG',
|
||||||
type: 'guild',
|
type: 'guild',
|
||||||
privacy:'public'
|
privacy: 'public'
|
||||||
}).save();
|
}).save();
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user