-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OFMCC-5947 - Message screenshots (#424)
* OFMCC-5947 initial commit. * Removed unused import. * Refined code. Removed images that can't be replaced. Removed hyperlinks to CRM attachments. * Minor update. --------- Co-authored-by: weskubo-cgi <Wesley.Kubo@gov.bc.ca>
- Loading branch information
1 parent
5950e8d
commit 60ccb1a
Showing
7 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
const { getOperation, handleError } = require('./utils') | ||
const HttpStatus = require('http-status-codes') | ||
|
||
async function getFile(req, res) { | ||
try { | ||
let operation = `msdyn_richtextfiles(${req.params.fileId})/` | ||
if (req.query.image) { | ||
operation += 'msdyn_imageblob/$value?size=full' | ||
} else { | ||
operation += 'msdyn_fileblob' | ||
} | ||
const response = await getOperation(operation) | ||
return res.status(HttpStatus.OK).json(response?.value) | ||
} catch (e) { | ||
handleError(res, e) | ||
} | ||
} | ||
|
||
module.exports = { | ||
getFile, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const express = require('express') | ||
const passport = require('passport') | ||
const router = express.Router() | ||
const auth = require('../components/auth') | ||
const isValidBackendToken = auth.isValidBackendToken() | ||
const { getFile } = require('../components/files') | ||
const { param, query, validationResult } = require('express-validator') | ||
const validatePermission = require('../middlewares/validatePermission.js') | ||
const { PERMISSIONS } = require('../util/constants') | ||
|
||
module.exports = router | ||
|
||
/** | ||
* Get the file by id | ||
*/ | ||
router.get( | ||
'/:fileId', | ||
passport.authenticate('jwt', { session: false }), | ||
isValidBackendToken, | ||
[param('fileId', 'URL param: [fileId] is required').notEmpty().isUUID()], | ||
query('image').optional().isBoolean(), | ||
validatePermission(PERMISSIONS.MANAGE_NOTIFICATIONS), | ||
(req, res) => { | ||
validationResult(req).throw() | ||
return getFile(req, res) | ||
}, | ||
) | ||
module.exports = router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import ApiService from '@/common/apiService' | ||
import { ApiRoutes } from '@/utils/constants' | ||
|
||
export default { | ||
async getFile(fileId, image = false) { | ||
try { | ||
if (!fileId) return null | ||
const response = await ApiService.apiAxios.get(`${ApiRoutes.FILES}/${fileId}?image=${image}`) | ||
return response.data | ||
} catch (error) { | ||
console.log(`Failed to get file - ${error}`) | ||
throw error | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters