Fix bug and update
This commit is contained in:
@@ -33,13 +33,12 @@ module.exports.create = [
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
const { title, caption, expireDate, isForAgents } = req.body
|
||||
const { title, caption, expireDate, isForAgents, publicx } = req.body
|
||||
const { user_id } = req
|
||||
const data = { title, caption, expireDate, isForAgents, _creator: user_id }
|
||||
|
||||
const data = { title, caption, expireDate, isForAgents, public: publicx, _creator: user_id }
|
||||
if (req.files?.image) {
|
||||
const image = req.files.image
|
||||
const fileName = 'TicketAttachment_' + Date.now() + '.' + image.mimetype.split('/')[1]
|
||||
const fileName = 'announcement' + Date.now() + '.' + image.name
|
||||
const acceptableFormats = ['png', 'jpg', 'jpeg', 'webp']
|
||||
if (!acceptableFormats.includes(image.mimetype.split('/')[1]))
|
||||
return res.status(422).json({ validation: { image: { msg: _faSr.format.image } } })
|
||||
@@ -97,6 +96,19 @@ module.exports.getNotifsForUsers = [
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getNotifsForSite = [
|
||||
async (req, res) => {
|
||||
try {
|
||||
|
||||
const announcements = await Announcement.find({ public:true })
|
||||
|
||||
return res.json(announcements)
|
||||
} catch (e) {
|
||||
return res500(res, e)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.deleteAnnouncement = [
|
||||
(req, res) => {
|
||||
Announcement.findByIdAndRemove(req.params.id, (err, oldData) => {
|
||||
|
||||
Reference in New Issue
Block a user