diff --git a/package.json b/package.json index 8e01a12ef2..08cea4a25e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "nodebb-plugin-spam-be-gone": "0.4.2", "nodebb-rewards-essentials": "0.0.5", "nodebb-theme-lavender": "2.0.13", - "nodebb-theme-persona": "4.0.24", + "nodebb-theme-persona": "4.0.25", "nodebb-theme-vanilla": "5.0.9", "nodebb-widget-essentials": "2.0.3", "npm": "^2.1.4", diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index 2169fd07f5..de2fccd842 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -33,7 +33,8 @@ define('forum/groups/details', [ uploader.open(RELATIVE_PATH + '/api/groups/uploadpicture', { groupName: groupName }, 0, function(imageUrlOnServer) { components.get('groups/cover').css('background-image', 'url(' + imageUrlOnServer + ')'); }); - } + }, + removeCover ); } @@ -241,5 +242,17 @@ define('forum/groups/details', [ } } + function removeCover() { + socket.emit('groups.cover.remove', { + groupName: ajaxify.data.group.name + }, function(err) { + if (!err) { + ajaxify.refresh(); + } else { + app.alertError(err.message); + } + }); + } + return Details; }); \ No newline at end of file diff --git a/src/groups/update.js b/src/groups/update.js index a47198cb19..b239df39de 100644 --- a/src/groups/update.js +++ b/src/groups/update.js @@ -181,6 +181,10 @@ module.exports = function(Groups) { }); }; + Groups.removeCover = function(data, callback) { + db.deleteObjectField('group:' + data.groupName, 'cover:url', callback); + }; + function updatePrivacy(groupName, newValue, callback) { if (!newValue) { return callback(); diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index d5d2cc926f..3b12693be0 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -242,4 +242,18 @@ SocketGroups.cover.update = function(socket, data, callback) { }); }; +SocketGroups.cover.remove = function(socket, data, callback) { + if (!socket.uid) { + return callback(new Error('[[error:no-privileges]]')); + } + + groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) { + if (!isOwner) { + return callback(new Error('[[error:no-privileges]]')); + } + + groups.removeCover(data, callback); + }); +} + module.exports = SocketGroups;