diff --git a/website/src/controllers/api-v2/groups.js b/website/src/controllers/api-v2/groups.js index de4d21022c..5f840c4330 100644 --- a/website/src/controllers/api-v2/groups.js +++ b/website/src/controllers/api-v2/groups.js @@ -1101,6 +1101,7 @@ api.questLeave = function(req, res, next) { }); } +// TODO port to api v3? in tojson? function _purgeFlagInfoFromChat(group, user) { group.chat = _.filter(group.chat, function(message) { return !message.flagCount || message.flagCount < 2; }); _.each(group.chat, function (message) { diff --git a/website/src/controllers/api-v3/groups.js b/website/src/controllers/api-v3/groups.js index 0373d02984..8f96cc09ae 100644 --- a/website/src/controllers/api-v3/groups.js +++ b/website/src/controllers/api-v3/groups.js @@ -567,7 +567,7 @@ function _inviteByEmails (emails, group, inviter, req, res, next) { * * @apiSuccess {Object} empty An empty object */ -/* api.inviteToGroup = { +api.inviteToGroup = { method: 'POST', url: '/groups/:groupId/invite', middlewares: [authWithHeaders(), cron], @@ -598,6 +598,6 @@ function _inviteByEmails (emails, group, inviter, req, res, next) { }) .catch(next); }, -};*/ +}; export default api; diff --git a/website/src/models/group.js b/website/src/models/group.js index fd79686977..95f5a82b94 100644 --- a/website/src/models/group.js +++ b/website/src/models/group.js @@ -94,16 +94,6 @@ schema.statics.sanitizeUpdate = function sanitizeUpdate (updateObj) { } }*/ -// FIXME this isn't always triggered, since we sometimes use update() or findByIdAndUpdate() -// @see https://github.com/LearnBoost/mongoose/issues/964 -> Add update pre? -// TODO necessary? -schema.pre('save', function preSaveGroup (next) { - // removeDuplicates(this); - this.memberCount = _.size(this.members); - this.challengeCount = _.size(this.challenges); - return next(); -}); - // TODO test schema.pre('remove', true, function preRemoveGroup (next, done) { next(); @@ -135,24 +125,6 @@ schema.post('remove', function postRemoveGroup (group) { firebase.deleteGroup(group._id); }); -/* schema.methods.toJSON = function groupToJSON () { - let doc = this.toObject(); - // removeDuplicates(doc); - doc._isMember = this._isMember; // TODO ? - - // TODO migration - // fix(groups): temp fix to remove chat entries stored as strings (not sure why that's happening..). - // Required as angular 1.3 is strict on dupes, and no message.id to `track by` - _.remove(doc.chat, msg => !msg.id); - - // TODO should not be needed here - // @see pre('save') comment above - this.memberCount = _.size(this.members); - this.challengeCount = _.size(this.challenges); - - return doc; -};*/ - // TODO populate (invites too), isMember? schema.statics.getGroup = function getGroup (user, groupId, fields) { let query; @@ -170,7 +142,7 @@ schema.statics.getGroup = function getGroup (user, groupId, fields) { .select(fields) .exec(); // TODO catch errors here? - // TODO purge chat flags info? + // TODO purge chat flags info? in tojson? }; // TODO move to its own model