Image support!
This commit is contained in:
@@ -21,6 +21,26 @@ async function noteFolderFor(folderId, campaignId) {
|
||||
return Folder.belongsToSection(folderId, campaignId, 'note');
|
||||
}
|
||||
|
||||
// Every media row of a campaign, so a note can link to an upload by name (`[[harbour.png]]`) or
|
||||
// display it (`![[harbour.png]]`).
|
||||
router.get('/list', async (req, res) => {
|
||||
try {
|
||||
const { campaign } = req.query;
|
||||
if (!campaign) return res.json({ status: 'error', msg: 'errors.missing-data' });
|
||||
|
||||
if (!(await userOwnsCampaign(campaign, req.user.id))) return res.json({ status: 'error', msg: 'unauthorized' });
|
||||
|
||||
const media = await Media.find({ campaign })
|
||||
.select('_id name file mimeType date')
|
||||
.sort({ name: 1 })
|
||||
.lean();
|
||||
res.json({ status: 'ok', media });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.json({ status: 'error', msg: 'errors.internal' });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/upload', upload.single('file'), async (req, res) => {
|
||||
try {
|
||||
const { campaign, folder } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user