Cover photo removal for groups, #3832

v1.18.x
Julian Lam 9 years ago
parent 92be63ebe6
commit 2830538835

@ -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",

@ -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;
});

@ -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();

@ -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;

Loading…
Cancel
Save