mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 07:26:13 +02:00
@@ -2,12 +2,10 @@
|
||||
|
||||
var async = require('async');
|
||||
var path = require('path');
|
||||
var mime = require('mime');
|
||||
|
||||
var db = require('../database');
|
||||
var image = require('../image');
|
||||
var file = require('../file');
|
||||
var uploadsController = require('../controllers/uploads');
|
||||
|
||||
module.exports = function (Groups) {
|
||||
Groups.updateCoverPosition = function (groupName, position, callback) {
|
||||
@@ -25,7 +23,7 @@ module.exports = function (Groups) {
|
||||
|
||||
var tempPath = data.file ? data.file : '';
|
||||
var url;
|
||||
var type = data.file ? mime.getType(data.file) : 'image/png';
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (tempPath) {
|
||||
@@ -36,10 +34,10 @@ module.exports = function (Groups) {
|
||||
function (_tempPath, next) {
|
||||
tempPath = _tempPath;
|
||||
|
||||
uploadsController.uploadGroupCover(uid, {
|
||||
name: 'groupCover' + path.extname(tempPath),
|
||||
const filename = 'groupCover-' + data.groupName + path.extname(tempPath);
|
||||
image.uploadImage(filename, 'files', {
|
||||
path: tempPath,
|
||||
type: type,
|
||||
uid: uid,
|
||||
}, next);
|
||||
},
|
||||
function (uploadData, next) {
|
||||
@@ -53,10 +51,9 @@ module.exports = function (Groups) {
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
uploadsController.uploadGroupCover(uid, {
|
||||
name: 'groupCoverThumb' + path.extname(tempPath),
|
||||
image.uploadImage('groupCoverThumb-' + data.groupName + path.extname(tempPath), 'files', {
|
||||
path: tempPath,
|
||||
type: type,
|
||||
uid: uid,
|
||||
}, next);
|
||||
},
|
||||
function (uploadData, next) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
var async = require('async');
|
||||
var validator = require('validator');
|
||||
var nconf = require('nconf');
|
||||
|
||||
var db = require('../database');
|
||||
var plugins = require('../plugins');
|
||||
@@ -91,8 +92,20 @@ function modifyGroup(group, fields) {
|
||||
group.createtimeISO = utils.toISOString(group.createtime);
|
||||
group.private = ([null, undefined].includes(group.private)) ? 1 : group.private;
|
||||
|
||||
group['cover:url'] = group['cover:url'] || require('../coverPhoto').getDefaultGroupCover(group.name);
|
||||
group['cover:thumb:url'] = group['cover:thumb:url'] || group['cover:url'];
|
||||
|
||||
if (group['cover:url']) {
|
||||
group['cover:url'] = group['cover:url'].startsWith('http') ? group['cover:url'] : (nconf.get('relative_path') + group['cover:url']);
|
||||
} else {
|
||||
group['cover:url'] = require('../coverPhoto').getDefaultGroupCover(group.name);
|
||||
}
|
||||
|
||||
if (group['cover:thumb:url']) {
|
||||
group['cover:thumb:url'] = group['cover:thumb:url'].startsWith('http') ? group['cover:thumb:url'] : (nconf.get('relative_path') + group['cover:thumb:url']);
|
||||
} else {
|
||||
group['cover:thumb:url'] = require('../coverPhoto').getDefaultGroupCover(group.name);
|
||||
}
|
||||
|
||||
group['cover:position'] = validator.escape(String(group['cover:position'] || '50% 50%'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user