Skip to content

Commit

Permalink
feature/deseng751: Removed unneeded comments, unneeded method removed…
Browse files Browse the repository at this point in the history
… from externalLink controller.
  • Loading branch information
jareth-whitney committed Jan 14, 2025
1 parent 7afe579 commit 46d931d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
51 changes: 0 additions & 51 deletions api/controllers/externalLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,52 +66,6 @@ exports.publicGet = async (args, res) => {
}
};

exports.unProtectedPost = async (args, res) => {
defaultLog.info('EXTERNAL LINK PUBLIC POST');
const _comment = args.swagger.params._comment.value;
const project = args.swagger.params.project.value;
try {
Promise.resolve()
.then(async function () {
defaultLog.info('Now saving external link in DB.');
const ExternalLink = mongoose.model('ExternalLink');
const extLink = new ExternalLink();
// Define security tag defaults
extLink.project = mongoose.Types.ObjectId(project);
extLink._comment = _comment;
extLink._addedBy = 'public';
extLink._createdDate = new Date();
extLink.read = ['sysadmin', 'staff'];
extLink.write = ['sysadmin', 'staff'];
extLink.delete = ['sysadmin', 'staff'];
extLink.displayName = args.body.displayName;
extLink.dateAdded = new Date();
extLink.dateUpdated = new Date();
extLink.externalLink = args.body.externalLink;
extLink.projectPhase = args.body.projectPhase;
extLink.checkbox = 'true' === args.body.checkbox ? true : false;
extLink.save()
.then(async function (link) {
defaultLog.info("Saved new external link object:", link._id);
const Comment = mongoose.model('Comment');
const c = await Comment.update({ _id: _comment }, { $addToSet: { documents: link._id } });
defaultLog.info('External link updated:', c);
Utils.recordAction('Post', 'ExternalLink', 'public', link._id);
return Actions.sendResponse(res, 200, link);
})
.catch(async function (error) {
defaultLog.error(error);
return Actions.sendResponse(res, 400, error);
});
});
} catch (e) {
defaultLog.error(e);
// Delete the path details before we return to the caller.
delete e['path'];
return Actions.sendResponse(res, 400, e);
}
};

exports.protectedHead = (args, res) => {
defaultLog.info('EXTERNAL LINK PROTECTED HEAD');
// Build match query if on exLinkId route
Expand Down Expand Up @@ -141,7 +95,6 @@ exports.protectedHead = (args, res) => {
true) // count
.then((data) => {
Utils.recordAction('Head', 'ExternalLink', args.swagger.params.auth_payload.preferred_username, args.swagger.params.exLinkId?.value || null);
// /api/commentperiod/ route, return 200 OK with 0 items if necessary
if (!(args.swagger.params.exLinkId && args.swagger.params.exLinkId.value) || (data && data.length > 0)) {
res.setHeader('x-total-count', data?.length > 0 ? data[0].total_items : 0);
return Actions.sendResponse(res, 200, data);
Expand Down Expand Up @@ -191,7 +144,6 @@ exports.protectedPost = async (args, res, next) => {
defaultLog.info('EXTERNAL LINK PROTECTED POST');
try {
const project = args.swagger.params.project?.value;
// const _comment = args.swagger.params._comment.value;
defaultLog.info('Section value:', args.swagger.params.section?.value);
Promise.resolve()
.then(async () => {
Expand All @@ -214,9 +166,6 @@ exports.protectedPost = async (args, res, next) => {
extLink.description = args.swagger.params.description.value;
extLink.projectPhase = args.swagger.params.projectPhase.value;
extLink.checkbox = 'true' === args.body.checkbox ? true : false;
// extLink._comment = _comment;
// extLink.alt = args.swagger.params.alt?.value || null;
// extLink.documentAuthor = args.swagger.params.documentAuthor?.value || null;
extLink.save()
.then((exl) => {
Utils.recordAction('Post', 'ExternalLink', args.swagger.params.auth_payload.preferred_username, exl._id);
Expand Down
3 changes: 0 additions & 3 deletions api/helpers/models/externalLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ module.exports = require('../models')('ExternalLink', {
description: { type: String, default: '' },
projectPhase: { type: String, default: '' },
checkbox: { type: Boolean, default: false },

// alt: { type: String, default: '' },
// documentAuthor: { type: String, default: '' },
}, 'lup');

0 comments on commit 46d931d

Please sign in to comment.