0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 00:12:56 +00:00

Merge branch 'master' into experimentalNotificationDB

This commit is contained in:
G.Ambatte
2023-02-14 13:00:02 +13:00
committed by GitHub
45 changed files with 4124 additions and 3962 deletions

View File

@@ -294,7 +294,15 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
sanitizeBrew(req.brew, 'share');
splitTextStyleAndMetadata(req.brew);
req.brew.title = `CLONE - ${req.brew.title}`;
const brew = {
shareId : req.brew.shareId,
title : `CLONE - ${req.brew.title}`,
text : req.brew.text,
style : req.brew.style,
renderer : req.brew.renderer,
theme : req.brew.theme
};
req.brew = _.defaults(brew, DEFAULT_BREW);
req.ogMeta = { ...defaultMetaTags,
title : 'New',

View File

@@ -16,6 +16,7 @@ const DEFAULT_BREW = {
tags : [],
systems : [],
thumbnail : '',
views : 0,
published : false,
pageCount : 1,
gDrive : false,

View File

@@ -338,6 +338,7 @@ If you believe you should have access to this brew, ask the file owner to invite
}
};
router.use('/api', require('./middleware/check-client-version.js'));
router.post('/api', asyncHandler(api.newBrew));
router.put('/api/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));

View File

@@ -71,7 +71,8 @@ describe('Tests for api', ()=>{
lastViewed : new Date(),
version : 1,
pageCount : 1,
textBin : ''
textBin : '',
views : 0
};
googleBrew = {
...hbBrew,
@@ -261,7 +262,8 @@ If you believe you should have access to this brew, ask the file owner to invite
gDrive : false,
style : undefined,
trashed : false,
updatedAt : undefined
updatedAt : undefined,
views : 0
});
expect(next).toHaveBeenCalled();
expect(api.getId).toHaveBeenCalledWith(req);
@@ -452,7 +454,8 @@ brew`);
thumbnail : '',
title : 'asdf',
trashed : false,
updatedAt : undefined
updatedAt : undefined,
views : 0
});
});
@@ -510,7 +513,8 @@ brew`);
thumbnail : '',
title : 'asdf',
trashed : false,
updatedAt : undefined
updatedAt : undefined,
views : 0
});
});

View File

@@ -0,0 +1,12 @@
module.exports = (req, res, next)=>{
const userVersion = req.get('Homebrewery-Version');
const version = require('../../package.json').version;
if(userVersion != version) {
return res.status(412).send({
message : `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
next();
};