Skip to content

Commit

Permalink
Merge branch 'release.24.10' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ar2rsawseen committed Nov 28, 2024
2 parents 2849195 + 0378d39 commit e1a67ce
Show file tree
Hide file tree
Showing 7 changed files with 918 additions and 1,230 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## Version 24.10.x

Dependencies:
- Bump puppeteer from 23.8.0 to 23.9.0
- Bump nodemailer from 6.9.15 to 6.9.16
- Bump countly-sdk-web from 24.4.1 to 24.11.0
- Bump tslib from 2.7.0 to 2.8.1
- Bump form-data from 4.0.0 to 4.0.1
- Bump jimp from 0.22.12 to 1.6.0
- Bump jsdoc from 4.0.3 to 4.0.4
- Bump countly-sdk-nodejs from 22.6.0 to 24.10.0

## Version 24.10.3
Fixes:
- [dashboards] Fixing issue where dashboard widgets go into single column
Expand Down
23 changes: 8 additions & 15 deletions api/parts/mgmt/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ appsApi.getAppsDetails = function(params) {
* @param {params} params - params object with args to create app
* @return {object} return promise object;
**/
const iconUpload = function(params) {
const iconUpload = async function(params) {
const appId = params.app_id || common.sanitizeFilename(params.qstring.args.app_id);
if (params.files && params.files.app_image) {
const tmp_path = params.files.app_image.path,
Expand All @@ -183,25 +183,18 @@ const iconUpload = function(params) {
return Promise.reject();
}
try {
return jimp.read(tmp_path, function(err, icon) {
if (err) {
log.e(err, err.stack);
fs.unlink(tmp_path, function() {});
return true;
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("appimages", target_path, buffer, {id: appId + ".png", writeMode: "overwrite"}, function(err3) {
if (err3) {
log.e(err3, err3.stack);
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("appimages", target_path, buffer, {id: appId + ".png", writeMode: "overwrite"}, function(err3) {
if (err3) {
log.e(err3, err3.stack);
}
fs.unlink(tmp_path, function() {});
});
});
});
}
catch (e) {
log.e(e.stack);
console.log("Problem uploading app icon", e);
}
fs.unlink(tmp_path, function() {});
}
};

Expand Down
47 changes: 18 additions & 29 deletions frontend/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ Promise.all([plugins.dbConnection(countlyConfig), plugins.dbConnection("countly_
req.body.app_id = req.body.app_image_id;
}
var params = paramsGenerator({req, res});
validateCreate(params, 'global_upload', function() {
validateCreate(params, 'global_upload', async function() {
if (!req.session.uid && !req.body.app_image_id) {
res.end();
return false;
Expand All @@ -1635,25 +1635,18 @@ Promise.all([plugins.dbConnection(countlyConfig), plugins.dbConnection("countly_
}
plugins.callMethod("iconUpload", {req: req, res: res, next: next, data: req.body});
try {
jimp.read(tmp_path, function(err, icon) {
if (err) {
console.log(err, err.stack);
fs.unlink(tmp_path, function() {});
res.status(400).send(false);
return true;
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("appimages", target_path, buffer, {id: req.body.app_image_id + ".png", writeMode: "overwrite"}, function() {
fs.unlink(tmp_path, function() {});
res.send("appimages/" + req.body.app_image_id + ".png");
countlyDb.collection('apps').updateOne({_id: countlyDb.ObjectID(req.body.app_image_id)}, {'$set': {'has_image': true}}, function() {});
});
}); // save
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("appimages", target_path, buffer, {id: req.body.app_image_id + ".png", writeMode: "overwrite"}, function() {
res.send("appimages/" + req.body.app_image_id + ".png");
countlyDb.collection('apps').updateOne({_id: countlyDb.ObjectID(req.body.app_image_id)}, {'$set': {'has_image': true}}, function() {});
});
}
catch (e) {
console.log(e.stack);
console.log("Problem uploading app icon", e);
res.status(400).send(false);
}
fs.unlink(tmp_path, function() {});
});
});

Expand Down Expand Up @@ -1695,23 +1688,19 @@ Promise.all([plugins.dbConnection(countlyConfig), plugins.dbConnection("countly_
}
plugins.callMethod("iconUpload", {req: req, res: res, next: next, data: req.body});
try {
jimp.read(tmp_path, function(err, icon) {
if (err) {
console.log(err, err.stack);
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("memberimages", target_path, buffer, {id: req.body.member_image_id + ".png", writeMode: "overwrite"}, function() {
fs.unlink(tmp_path, function() {});
countlyDb.collection('members').updateOne({_id: countlyDb.ObjectID(req.body.member_image_id + "")}, {'$set': {'member_image': "memberimages/" + req.body.member_image_id + ".png"}}, function() {
res.send("memberimages/" + req.body.member_image_id + ".png");
});
});
}); // save
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("memberimages", target_path, buffer, {id: req.body.member_image_id + ".png", writeMode: "overwrite"}, function() {
countlyDb.collection('members').updateOne({_id: countlyDb.ObjectID(req.body.member_image_id + "")}, {'$set': {'member_image': "memberimages/" + req.body.member_image_id + ".png"}}, function() {
res.send("memberimages/" + req.body.member_image_id + ".png");
});
});
}
catch (e) {
console.log(e.stack);
console.log("Problem uploading member icon", e);
res.status(400).send(false);
}
fs.unlink(tmp_path, function() {});
});
});

Expand Down
Loading

0 comments on commit e1a67ce

Please sign in to comment.