@openneuro/server 4.47.1 → 4.47.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openneuro/server",
3
- "version": "4.47.1",
3
+ "version": "4.47.3",
4
4
  "description": "Core service for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "src/server.js",
@@ -21,7 +21,7 @@
21
21
  "@elastic/elasticsearch": "8.13.1",
22
22
  "@graphql-tools/schema": "^10.0.0",
23
23
  "@keyv/redis": "^4.5.0",
24
- "@openneuro/search": "^4.47.1",
24
+ "@openneuro/search": "^4.47.3",
25
25
  "@sentry/node": "^10.37.0",
26
26
  "@sentry/profiling-node": "^10.37.0",
27
27
  "base64url": "^3.0.0",
@@ -89,5 +89,5 @@
89
89
  "publishConfig": {
90
90
  "access": "public"
91
91
  },
92
- "gitHead": "b588b9cef29fe2527ec37f3d71b8c6ee77a986cf"
92
+ "gitHead": "992909824c4900c9840183661c6ef6d88a0168fe"
93
93
  }
@@ -22,6 +22,7 @@ import notifications from "../../libs/notifications"
22
22
  import DataRetention from "../../models/dataRetention"
23
23
  import Permission from "../../models/permission"
24
24
  import User from "../../models/user"
25
+ import Deletion from "../../models/deletion"
25
26
  import { checkDataRetentionNotifications } from "../dataRetentionNotifications"
26
27
  import * as draftModule from "../draft"
27
28
  import * as snapshotsModule from "../snapshots"
@@ -55,6 +56,7 @@ describe("checkDataRetentionNotifications", () => {
55
56
 
56
57
  beforeEach(async () => {
57
58
  await DataRetention.deleteMany({})
59
+ await Deletion.deleteMany({})
58
60
  await Permission.deleteMany({})
59
61
  await User.deleteMany({})
60
62
  vi.mocked(notifications.send).mockClear()
@@ -81,6 +83,19 @@ describe("checkDataRetentionNotifications", () => {
81
83
  )
82
84
  }
83
85
 
86
+ it("skips notifications for deleted datasets", async () => {
87
+ await Deletion.create({
88
+ datasetId: TEST_DATASET,
89
+ reason: "test deletion",
90
+ user: { _id: TEST_USER.id },
91
+ })
92
+ mockDraft(daysAgo(15))
93
+ mockSnapshots([{ hexsha: "other" }])
94
+
95
+ await checkDataRetentionNotifications(TEST_DATASET)
96
+ expect(notifications.send).not.toHaveBeenCalled()
97
+ })
98
+
84
99
  it("does nothing when draft matches the latest snapshot", async () => {
85
100
  mockDraft(daysAgo(30), TEST_HEXSHA)
86
101
  mockSnapshots([{ hexsha: TEST_HEXSHA }])
@@ -3,6 +3,7 @@ import notifications from "../libs/notifications"
3
3
  import User from "../models/user"
4
4
  import Permission from "../models/permission"
5
5
  import DataRetention from "../models/dataRetention"
6
+ import Deletion from "../models/deletion"
6
7
  import { getDraftInfo } from "./draft"
7
8
  import { getSnapshots } from "./snapshots"
8
9
  import { draftRetentionWarning } from "../libs/email/templates/draft-retention-warning"
@@ -40,6 +41,10 @@ async function notifyWriteUsers(
40
41
  export async function checkDataRetentionNotifications(
41
42
  datasetId: string,
42
43
  ): Promise<void> {
44
+ // Skip datasets that have been marked as deleted
45
+ const deleted = await Deletion.findOne({ datasetId }).exec()
46
+ if (deleted) return
47
+
43
48
  const draft = await getDraftInfo(datasetId)
44
49
  const snapshots = await getSnapshots(datasetId)
45
50
  const lastSnapshot = snapshots?.length