Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #1241

Merged
merged 6 commits into from
Dec 9, 2024
Merged

Release #1241

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: assorted bug fixes
  • Loading branch information
wwills2 committed Dec 6, 2024

Verified

This commit was signed with the committer’s verified signature.
wwills2 William "Zan" Wills
commit 1054730d1d7dfec2fffca772c753cdea9073c2ea
11 changes: 5 additions & 6 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
@@ -264,21 +264,20 @@ export const subscribeToOrganization = async (req, res) => {
export const deleteImportedOrg = async (req, res) => {
let transaction;
try {
const orgUid = req.body.orgUid;
await assertIfReadOnlyMode();
await assertWalletIsSynced();
await assertHomeOrgExists();
await assertCanDeleteOrg(req.body.orgUid);
await assertCanDeleteOrg(orgUid);

transaction = await sequelize.transaction();

await Organization.destroy({ where: { orgUid: req.body.orgUid } });
await Organization.destroy({ where: { orgUid } });

await Promise.all([
...Object.keys(ModelKeys).map(
async (key) =>
await ModelKeys[key].destroy({ where: { orgUid: req.body.orgUid } }),
async (key) => await ModelKeys[key].destroy({ where: { orgUid } }),
),
Audit.destroy({ where: { orgUid: req.body.orgUid } }),
Audit.destroy({ where: { orgUid } }),
]);

await transaction.commit();
5 changes: 4 additions & 1 deletion src/datalayer/persistance.js
Original file line number Diff line number Diff line change
@@ -542,7 +542,10 @@ const subscribeToStoreOnDataLayer = async (
return { success: true };
}

const { storeIds: subscriptions } = await getSubscriptions();
const { storeIds: subscriptions, success } = await getSubscriptions();
if (!success) {
return false;
}

if (subscriptions.includes(storeId)) {
logger.info(`Already subscribed to: ${storeId}`);
6 changes: 5 additions & 1 deletion src/datalayer/syncService.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,11 @@ const subscribeToStoreOnDataLayer = async (storeId) => {
};

const getSubscribedStoreData = async (storeId) => {
const { storeIds: subscriptions } = await dataLayer.getSubscriptions(storeId);
const { storeIds: subscriptions, success } =
await dataLayer.getSubscriptions();
if (!success) {
throw new Error('failed to retrieve subscriptions from datalayer');
}
const alreadySubscribed = subscriptions.includes(storeId);

if (!alreadySubscribed) {
5 changes: 4 additions & 1 deletion src/tasks/sync-registries.js
Original file line number Diff line number Diff line change
@@ -102,7 +102,10 @@ const processJob = async () => {
});

// verify that the latest organization root hash is up to date with the audit records. attempt correction.
if (mostRecentOrgAuditRecord?.rootHash !== organization?.registryHash) {
if (
mostRecentOrgAuditRecord &&
mostRecentOrgAuditRecord?.rootHash !== organization?.registryHash
) {
logger.warn(
`latest root hash in org table for organization ${organization.name} (orgUid ${organization.orgUid}) does not match the audit records. attempting to correct`,
);
2 changes: 1 addition & 1 deletion src/utils/data-assertions.js
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ export const assertRecordExistance = async (Model, pk) => {

export const assertCanDeleteOrg = async (orgUid) => {
const homeOrg = await Organization.getHomeOrg();
if (homeOrg.orgUid === orgUid) {
if (homeOrg?.orgUid === orgUid) {
throw new Error(`Cant delete your own organization`);
}
};