mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	Cover photo removal for groups, #3832
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user