Skip to content

Commit

Permalink
switching up where we get the copy attachment id from
Browse files Browse the repository at this point in the history
  • Loading branch information
andieswift committed Jan 22, 2025
1 parent df9b92f commit af600ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
26 changes: 12 additions & 14 deletions lib/lambda/adminActions/submitNOSO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,29 @@ import { submitNOSOAdminSchema } from "./adminSchemas";

export const copyAttachments = async (data: any) => {
console.log("ANDIE******:", data, data.copyAttachmentsFromId);
//ANDIE: change type not any
// change any
if (!data.copyAttachmentsFromId) return data;
const copyAttachmentsFromId = data.copyAttachmentsFromId;

console.log("copyAttachmentsFromId", copyAttachmentsFromId);
console.log("id:", data.id);
const currentPackage = await getPackage(data.id);
const currentPackageChangelog = await getPackageChangelog(data.id);

console.log("andie", currentPackage);
if (!currentPackage || currentPackage.found == false) {
console.error(`Current package id: ${currentPackage} not found`);
return data;
}

//@ts-ignore
const copyAttachmentsFromId = currentPackage?._source.copyAttachmentsFromId;
console.log(`atempting to copy attachments from ${copyAttachmentsFromId}...`);

// get the attachementPackage
const attachPackage = await getPackage(copyAttachmentsFromId);
const attachPackageChangelog = await getPackageChangelog(copyAttachmentsFromId);

const currentPackage = await getPackage(data.id);
const currentPackageChangelog = await getPackageChangelog(data.id);

if (!attachPackage || attachPackage.found == false) {
console.error(`Copy Attachment Package of id: ${copyAttachmentsFromId} not found`);
return data;
}

if (!currentPackage || currentPackage.found == false) {
console.error(`Current package id: ${currentPackage} not found`);
return data;
}

// check if the authorities match
if (attachPackage?._source.authority !== currentPackage._source.authority) {
console.error(
Expand Down
4 changes: 2 additions & 2 deletions lib/lambda/sinkChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const processAndIndex = async ({
packageId: result.data.id,
});
});
} else if (result.data.adminChangeType === "NOSO" && result.data.copyAttachmentsFromId) {
console.log("attempting to copy attachments...");
} else if (result.data.adminChangeType === "NOSO") {
console.log("checking if we need to copy attachments...");
try {
const data = await copyAttachments(result.data);
docs.push(data);
Expand Down

0 comments on commit af600ab

Please sign in to comment.