Compare commits

..

1 Commits

Author SHA1 Message Date
Jonathan Jogenfors 43d66c7a36 ignore perm errors 2025-02-07 00:30:28 +01:00
185 changed files with 5782 additions and 8261 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ jobs:
type=raw,value=latest,enable=${{ github.event_name == 'release' }} type=raw,value=latest,enable=${{ github.event_name == 'release' }}
- name: Build and push image - name: Build and push image
uses: docker/build-push-action@v6.13.0 uses: docker/build-push-action@v6.12.0
with: with:
file: cli/Dockerfile file: cli/Dockerfile
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
+2 -2
View File
@@ -174,7 +174,7 @@ jobs:
fi fi
- name: Build and push image - name: Build and push image
uses: docker/build-push-action@v6.13.0 uses: docker/build-push-action@v6.12.0
with: with:
context: ${{ env.context }} context: ${{ env.context }}
file: ${{ env.file }} file: ${{ env.file }}
@@ -265,7 +265,7 @@ jobs:
fi fi
- name: Build and push image - name: Build and push image
uses: docker/build-push-action@v6.13.0 uses: docker/build-push-action@v6.12.0
with: with:
context: ${{ env.context }} context: ${{ env.context }}
file: ${{ env.file }} file: ${{ env.file }}
+8 -8
View File
@@ -1,12 +1,12 @@
{ {
"name": "@immich/cli", "name": "@immich/cli",
"version": "2.2.50", "version": "2.2.48",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@immich/cli", "name": "@immich/cli",
"version": "2.2.50", "version": "2.2.48",
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
@@ -24,7 +24,7 @@
"@types/cli-progress": "^3.11.0", "@types/cli-progress": "^3.11.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/mock-fs": "^4.13.1", "@types/mock-fs": "^4.13.1",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@typescript-eslint/eslint-plugin": "^8.15.0", "@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0", "@typescript-eslint/parser": "^8.15.0",
"@vitest/coverage-v8": "^3.0.0", "@vitest/coverage-v8": "^3.0.0",
@@ -52,14 +52,14 @@
}, },
"../open-api/typescript-sdk": { "../open-api/typescript-sdk": {
"name": "@immich/sdk", "name": "@immich/sdk",
"version": "1.126.1", "version": "1.125.7",
"dev": true, "dev": true,
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
"@oazapfts/runtime": "^1.0.2" "@oazapfts/runtime": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }
}, },
@@ -1482,9 +1482,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.13.1", "version": "22.10.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.9.tgz",
"integrity": "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==", "integrity": "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@immich/cli", "name": "@immich/cli",
"version": "2.2.50", "version": "2.2.48",
"description": "Command Line Interface (CLI) for Immich", "description": "Command Line Interface (CLI) for Immich",
"type": "module", "type": "module",
"exports": "./dist/index.js", "exports": "./dist/index.js",
@@ -20,7 +20,7 @@
"@types/cli-progress": "^3.11.0", "@types/cli-progress": "^3.11.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/mock-fs": "^4.13.1", "@types/mock-fs": "^4.13.1",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@typescript-eslint/eslint-plugin": "^8.15.0", "@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0", "@typescript-eslint/parser": "^8.15.0",
"@vitest/coverage-v8": "^3.0.0", "@vitest/coverage-v8": "^3.0.0",
+30 -30
View File
@@ -2,37 +2,37 @@
# Manual edits may be lost in future updates. # Manual edits may be lost in future updates.
provider "registry.opentofu.org/cloudflare/cloudflare" { provider "registry.opentofu.org/cloudflare/cloudflare" {
version = "4.52.0" version = "4.50.0"
constraints = "4.52.0" constraints = "4.50.0"
hashes = [ hashes = [
"h1:2BEJyXJtYC4B4nda/WCYUmuJYDaYk88F8t1pwPzr0iQ=", "h1:0qvD5ZKn2tMZ8cOjQrUSITIC9tKCZbrSaSswV9lOyiU=",
"h1:4IASk5SESeWKQ7JU0+M7KApuF5mZyklvwMXPBabim3c=", "h1:4N0gplrZ0zOsJv3Kx1VfIx2FwrZHbYU0Un2yfiLZIGQ=",
"h1:5ImZxxALSnWfH/4EXw/wFirSmk5Tr0ACmcysy51AafE=", "h1:81AMQq4kNKU/35U8ElQegUxG4E6xB0erIjG5xVmjIyo=",
"h1:6TJ3dxLSin4ZKBJLsZDn95H2ZYnGm8S7GGHvvXuuMQU=", "h1:EEQNADUmV3IL6x00yzy04i7OCSLeOMgM9XQkV3w71gA=",
"h1:IzTUjg9kQ4N3qizP9CjYLeHwjsuGgtxwXvfUQWyOLcA=", "h1:HD0KI7td6oiSSAnJNn8UPSGf+hKiTo4JVQYfAiU1SqM=",
"h1:NTaOQfYINA0YTG/V1/9+SYtgX1it63+cBugj4WK4FWc=", "h1:Hl+o5LtcvZg2f3l1hh9vaG/DFK6k+dTIZSeM0lXyfpo=",
"h1:PXH48LuJn329sCfMXprdMDk51EZaWFyajVvS03qhQLs=", "h1:ZUO2oIJ6jtZdvl816h0cEIiIeZ/fFCF64+abGEVxZZM=",
"h1:Pi5M+GeoMSN2eJ6QnIeXjBf19O+rby/74CfB2ocpv20=", "h1:Zio80fnEeUKdlSOhTVskMEFSLUQ6TMsMKnXc+Dy2P2A=",
"h1:ShXZ2ZjBvm3thfoPPzPT8+OhyismnydQVkUAfI8X12w=", "h1:aLLvg36evTyqjtXGV2MjAV8imktXFmry7p/xCu9GQC4=",
"h1:WQ9hu0Wge2msBbODfottCSKgu8oKUrw4Opz+fDPVVHk=", "h1:azL05eWyy2V8SWkbZZImPWvv8ynG4eqmrbZhjXBDFug=",
"h1:Z5yXML2DE0uH9UU+M0ut9JMQAORcwVZz1CxBHzeBmao=", "h1:ckMysHY4fJmr7o58XMi+DdgOTB/U/Mf1u1JA9ly3g/I=",
"h1:jqI2qKknpleS3JDSplyGYHMu0u9K/tor1ZOjFwDgEMk=", "h1:jxOwjDNjt5WCb4YjjiMsman91O8Y+MAPz6UwJ4a6F+0=",
"h1:kgfutDh14Q5nw4eg6qGFamFxIiY8Ae0FPKRBLDOzpcI=", "h1:u4OfnjSLa4Wk1IUFAzrvMnGgr8MvRHEWVDHEScPK2E8=",
"h1:zCAO7GZmfYhWb+i6TfqlqhMeDyPZWGio2IzEzAh3YTs=", "h1:wQkR1oeSkzlHn3rnVuLJRJLBHlg4EHt7Y64DeTjfkjQ=",
"zh:19be1a91c982b902c42aba47766860dfa5dc151eed1e95fd39ca642229381ef0", "zh:0ef99ed39472a94e6a0d6fa733cf0a46bce3bf66eba2873efae8846efdddc237",
"zh:1de451c4d1ecf7efbe67b6dace3426ba810711afdd644b0f1b870364c8ae91f8", "zh:2929cbbffcead171d45c88e4a7a59e9c013ea775dafa68b10da8db7cd04b6140",
"zh:352b4a2120173298622e669258744554339d959ac3a95607b117a48ee4a83238", "zh:462601c87118088e1a718842e367af7d8e7620598d426980a6d6b33de759865e",
"zh:3c6f1346d9154afbd2d558fabb4b0150fc8d559aa961254144fe1bc17fe6032f", "zh:56766eb62a74a9d88d9efb8486dd3a0c5c9db873d0a980ae9ef1e8af27d74231",
"zh:4c4c92d53fb535b1e0eff26f222bbd627b97d3b4c891ec9c321268676d06152f", "zh:6b4e8810d99498a5a20a5872982a0f1354e79cfc4a7dfe7cc656f1c7eaae47d8",
"zh:53276f68006c9ceb7cdb10a6ccf91a5c1eadd1407a28edb5741e84e88d7e29e8", "zh:6d65bdb4ec94b6eecc8abe26d94e2ca09262dc1e7a9934db829f418be0119920",
"zh:7925a97773948171a63d4f65bb81ee92fd6d07a447e36012977313293a5435c9", "zh:71adeaf31e41a358ec6095004062e43f56ee7d4b2504e5613ab351d511695641",
"zh:7dfb0a4496cfe032437386d0a2cd9229a1956e9c30bd920923c141b0f0440060",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:8d4aa79f0a414bb4163d771063c70cd991c8fac6c766e685bac2ee12903c5bd6", "zh:89761c15908ccc2cf9c50bb5cb3be45d3ad0c45fc7c608c6b95f48c0288b7160",
"zh:a67540c13565616a7e7e51ee9366e88b0dc60046e1d75c72680e150bd02725bb", "zh:8cc5d7c5939da89cfd01f3e51c84f3576564783acea9db86bd9e32049805ed96",
"zh:a936383a4767f5393f38f622e92bf2d0c03fe04b69c284951f27345766c7b31b", "zh:987cff8225b1dd436cdcb4fc6228689ae7e4281de6896412a2a9a3325c49f05e",
"zh:d4887d73c466ff036eecf50ad6404ba38fd82ea4855296b1846d244b0f13c380", "zh:991e83ebb89867d71e01a1c215ed159efb425683b0a44707be8579eb0a337f06",
"zh:e9093c8bd5b6cd99c81666e315197791781b8f93afa14fc2e0f732d1bb2a44b7", "zh:ab8177ae2d8f5cfa90043a6f867435012cae115f6061b832a7e2462e0ae87a67",
"zh:efd3b3f1ec59a37f635aa1d4efcf178734c2fcf8ddb0d56ea690bec342da8672", "zh:d1ca34df1398f201274a6a18102975148c10ca15aa43cfc56cc9897620929509",
"zh:d34946f70201baf6dda03e3b294c6bbe40d95d0278e97b9f636ded94822b24ac",
] ]
} }
@@ -5,7 +5,7 @@ terraform {
required_providers { required_providers {
cloudflare = { cloudflare = {
source = "cloudflare/cloudflare" source = "cloudflare/cloudflare"
version = "4.52.0" version = "4.50.0"
} }
} }
} }
+30 -30
View File
@@ -2,37 +2,37 @@
# Manual edits may be lost in future updates. # Manual edits may be lost in future updates.
provider "registry.opentofu.org/cloudflare/cloudflare" { provider "registry.opentofu.org/cloudflare/cloudflare" {
version = "4.52.0" version = "4.50.0"
constraints = "4.52.0" constraints = "4.50.0"
hashes = [ hashes = [
"h1:2BEJyXJtYC4B4nda/WCYUmuJYDaYk88F8t1pwPzr0iQ=", "h1:0qvD5ZKn2tMZ8cOjQrUSITIC9tKCZbrSaSswV9lOyiU=",
"h1:4IASk5SESeWKQ7JU0+M7KApuF5mZyklvwMXPBabim3c=", "h1:4N0gplrZ0zOsJv3Kx1VfIx2FwrZHbYU0Un2yfiLZIGQ=",
"h1:5ImZxxALSnWfH/4EXw/wFirSmk5Tr0ACmcysy51AafE=", "h1:81AMQq4kNKU/35U8ElQegUxG4E6xB0erIjG5xVmjIyo=",
"h1:6TJ3dxLSin4ZKBJLsZDn95H2ZYnGm8S7GGHvvXuuMQU=", "h1:EEQNADUmV3IL6x00yzy04i7OCSLeOMgM9XQkV3w71gA=",
"h1:IzTUjg9kQ4N3qizP9CjYLeHwjsuGgtxwXvfUQWyOLcA=", "h1:HD0KI7td6oiSSAnJNn8UPSGf+hKiTo4JVQYfAiU1SqM=",
"h1:NTaOQfYINA0YTG/V1/9+SYtgX1it63+cBugj4WK4FWc=", "h1:Hl+o5LtcvZg2f3l1hh9vaG/DFK6k+dTIZSeM0lXyfpo=",
"h1:PXH48LuJn329sCfMXprdMDk51EZaWFyajVvS03qhQLs=", "h1:ZUO2oIJ6jtZdvl816h0cEIiIeZ/fFCF64+abGEVxZZM=",
"h1:Pi5M+GeoMSN2eJ6QnIeXjBf19O+rby/74CfB2ocpv20=", "h1:Zio80fnEeUKdlSOhTVskMEFSLUQ6TMsMKnXc+Dy2P2A=",
"h1:ShXZ2ZjBvm3thfoPPzPT8+OhyismnydQVkUAfI8X12w=", "h1:aLLvg36evTyqjtXGV2MjAV8imktXFmry7p/xCu9GQC4=",
"h1:WQ9hu0Wge2msBbODfottCSKgu8oKUrw4Opz+fDPVVHk=", "h1:azL05eWyy2V8SWkbZZImPWvv8ynG4eqmrbZhjXBDFug=",
"h1:Z5yXML2DE0uH9UU+M0ut9JMQAORcwVZz1CxBHzeBmao=", "h1:ckMysHY4fJmr7o58XMi+DdgOTB/U/Mf1u1JA9ly3g/I=",
"h1:jqI2qKknpleS3JDSplyGYHMu0u9K/tor1ZOjFwDgEMk=", "h1:jxOwjDNjt5WCb4YjjiMsman91O8Y+MAPz6UwJ4a6F+0=",
"h1:kgfutDh14Q5nw4eg6qGFamFxIiY8Ae0FPKRBLDOzpcI=", "h1:u4OfnjSLa4Wk1IUFAzrvMnGgr8MvRHEWVDHEScPK2E8=",
"h1:zCAO7GZmfYhWb+i6TfqlqhMeDyPZWGio2IzEzAh3YTs=", "h1:wQkR1oeSkzlHn3rnVuLJRJLBHlg4EHt7Y64DeTjfkjQ=",
"zh:19be1a91c982b902c42aba47766860dfa5dc151eed1e95fd39ca642229381ef0", "zh:0ef99ed39472a94e6a0d6fa733cf0a46bce3bf66eba2873efae8846efdddc237",
"zh:1de451c4d1ecf7efbe67b6dace3426ba810711afdd644b0f1b870364c8ae91f8", "zh:2929cbbffcead171d45c88e4a7a59e9c013ea775dafa68b10da8db7cd04b6140",
"zh:352b4a2120173298622e669258744554339d959ac3a95607b117a48ee4a83238", "zh:462601c87118088e1a718842e367af7d8e7620598d426980a6d6b33de759865e",
"zh:3c6f1346d9154afbd2d558fabb4b0150fc8d559aa961254144fe1bc17fe6032f", "zh:56766eb62a74a9d88d9efb8486dd3a0c5c9db873d0a980ae9ef1e8af27d74231",
"zh:4c4c92d53fb535b1e0eff26f222bbd627b97d3b4c891ec9c321268676d06152f", "zh:6b4e8810d99498a5a20a5872982a0f1354e79cfc4a7dfe7cc656f1c7eaae47d8",
"zh:53276f68006c9ceb7cdb10a6ccf91a5c1eadd1407a28edb5741e84e88d7e29e8", "zh:6d65bdb4ec94b6eecc8abe26d94e2ca09262dc1e7a9934db829f418be0119920",
"zh:7925a97773948171a63d4f65bb81ee92fd6d07a447e36012977313293a5435c9", "zh:71adeaf31e41a358ec6095004062e43f56ee7d4b2504e5613ab351d511695641",
"zh:7dfb0a4496cfe032437386d0a2cd9229a1956e9c30bd920923c141b0f0440060",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:8d4aa79f0a414bb4163d771063c70cd991c8fac6c766e685bac2ee12903c5bd6", "zh:89761c15908ccc2cf9c50bb5cb3be45d3ad0c45fc7c608c6b95f48c0288b7160",
"zh:a67540c13565616a7e7e51ee9366e88b0dc60046e1d75c72680e150bd02725bb", "zh:8cc5d7c5939da89cfd01f3e51c84f3576564783acea9db86bd9e32049805ed96",
"zh:a936383a4767f5393f38f622e92bf2d0c03fe04b69c284951f27345766c7b31b", "zh:987cff8225b1dd436cdcb4fc6228689ae7e4281de6896412a2a9a3325c49f05e",
"zh:d4887d73c466ff036eecf50ad6404ba38fd82ea4855296b1846d244b0f13c380", "zh:991e83ebb89867d71e01a1c215ed159efb425683b0a44707be8579eb0a337f06",
"zh:e9093c8bd5b6cd99c81666e315197791781b8f93afa14fc2e0f732d1bb2a44b7", "zh:ab8177ae2d8f5cfa90043a6f867435012cae115f6061b832a7e2462e0ae87a67",
"zh:efd3b3f1ec59a37f635aa1d4efcf178734c2fcf8ddb0d56ea690bec342da8672", "zh:d1ca34df1398f201274a6a18102975148c10ca15aa43cfc56cc9897620929509",
"zh:d34946f70201baf6dda03e3b294c6bbe40d95d0278e97b9f636ded94822b24ac",
] ]
} }
+1 -1
View File
@@ -5,7 +5,7 @@ terraform {
required_providers { required_providers {
cloudflare = { cloudflare = {
source = "cloudflare/cloudflare" source = "cloudflare/cloudflare"
version = "4.52.0" version = "4.50.0"
} }
} }
} }
+1 -1
View File
@@ -103,7 +103,7 @@ services:
command: ['./run.sh', '-disable-reporting'] command: ['./run.sh', '-disable-reporting']
ports: ports:
- 3000:3000 - 3000:3000
image: grafana/grafana:11.5.1-ubuntu@sha256:9a4ab78cec1a2ec7d1ca5dfd5aacec6412706a1bc9e971fc7184e2f6696a63f5 image: grafana/grafana:11.4.0-ubuntu@sha256:afccec22ba0e4815cca1d2bf3836e414322390dc78d77f1851976ffa8d61051c
volumes: volumes:
- grafana-data:/var/lib/grafana - grafana-data:/var/lib/grafana
+1 -1
View File
@@ -76,7 +76,7 @@ To see local changes to `@immich/ui` in Immich, do the following:
### Mobile app ### Mobile app
The mobile app `(/mobile)` will required Flutter toolchain 3.13.x and FVM to be installed on your system. The mobile app `(/mobile)` will required Flutter toolchain 3.13.x to be installed on your system.
Please refer to the [Flutter's official documentation](https://flutter.dev/docs/get-started/install) for more information on setting up the toolchain on your machine. Please refer to the [Flutter's official documentation](https://flutter.dev/docs/get-started/install) for more information on setting up the toolchain on your machine.
@@ -11,7 +11,7 @@ You do not need to redo any machine learning jobs after enabling hardware accele
- ARM NN (Mali) - ARM NN (Mali)
- CUDA (NVIDIA GPUs with [compute capability](https://developer.nvidia.com/cuda-gpus) 5.2 or higher) - CUDA (NVIDIA GPUs with [compute capability](https://developer.nvidia.com/cuda-gpus) 5.2 or higher)
- OpenVINO (Intel GPUs such as Iris Xe and Arc) - OpenVINO (Intel discrete GPUs such as Iris Xe and Arc)
## Limitations ## Limitations
@@ -43,9 +43,8 @@ You do not need to redo any machine learning jobs after enabling hardware accele
#### OpenVINO #### OpenVINO
- Integrated GPUs are more likely to experience issues than discrete GPUs, especially for older processors or servers with low RAM. - The server must have a discrete GPU, i.e. Iris Xe or Arc. Expect issues when attempting to use integrated graphics.
- Ensure the server's kernel version is new enough to use the device for hardware accceleration. - Ensure the server's kernel version is new enough to use the device for hardware accceleration.
- Expect higher RAM usage when using OpenVINO compared to CPU processing.
## Setup ## Setup
+2 -2
View File
@@ -44,12 +44,12 @@ export default function VersionSwitcher(): JSX.Element {
return ( return (
versions.length > 0 && ( versions.length > 0 && (
<DropdownNavbarItem <DropdownNavbarItem
className="version-switcher-34ab39" className="navbar__item"
label={label} label={label}
mobile={windowSize === 'mobile'} mobile={windowSize === 'mobile'}
items={versions.map(({ label, url }) => ({ items={versions.map(({ label, url }) => ({
label, label,
to: url + location.pathname + location.hash, to: url + location.pathname,
target: '_self', target: '_self',
}))} }))}
/> />
-5
View File
@@ -75,11 +75,6 @@ div[class^='announcementBar_'] {
font-weight: 500; font-weight: 500;
} }
/* workaround for version switcher PR 15894 */
div[class*='navbar__items'] > li:has(a[class*='version-switcher-34ab39']) {
display: none;
}
code { code {
font-weight: 600; font-weight: 600;
} }
+1 -1
View File
@@ -53,7 +53,7 @@ function HomepageHeader() {
<Link <Link
className="flex place-items-center place-content-center py-3 px-8 border bg-immich-primary/10 dark:bg-gray-300 rounded-xl hover:no-underline text-immich-primary dark:text-immich-dark-bg font-bold uppercase" className="flex place-items-center place-content-center py-3 px-8 border bg-immich-primary/10 dark:bg-gray-300 rounded-xl hover:no-underline text-immich-primary dark:text-immich-dark-bg font-bold uppercase"
to="https://immich.store" to="https://demo.immich.app/"
> >
Buy Merch Buy Merch
</Link> </Link>
-8
View File
@@ -1,12 +1,4 @@
[ [
{
"label": "v1.126.1",
"url": "https://v1.126.1.archive.immich.app"
},
{
"label": "v1.126.0",
"url": "https://v1.126.0.archive.immich.app"
},
{ {
"label": "v1.125.7", "label": "v1.125.7",
"url": "https://v1.125.7.archive.immich.app" "url": "https://v1.125.7.archive.immich.app"
+3
View File
@@ -32,6 +32,9 @@ services:
- database - database
ports: ports:
- 2285:2285 - 2285:2285
cap_drop:
# We need this to perform testing on permission errors
- DAC_OVERRIDE
redis: redis:
image: redis:6.2-alpine@sha256:905c4ee67b8e0aa955331960d2aa745781e6bd89afc44a8584bfd13bc890f0ae image: redis:6.2-alpine@sha256:905c4ee67b8e0aa955331960d2aa745781e6bd89afc44a8584bfd13bc890f0ae
+10 -10
View File
@@ -1,12 +1,12 @@
{ {
"name": "immich-e2e", "name": "immich-e2e",
"version": "1.126.1", "version": "1.125.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "immich-e2e", "name": "immich-e2e",
"version": "1.126.1", "version": "1.125.7",
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.1.0", "@eslint/eslintrc": "^3.1.0",
@@ -15,7 +15,7 @@
"@immich/sdk": "file:../open-api/typescript-sdk", "@immich/sdk": "file:../open-api/typescript-sdk",
"@playwright/test": "^1.44.1", "@playwright/test": "^1.44.1",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@types/oidc-provider": "^8.5.1", "@types/oidc-provider": "^8.5.1",
"@types/pg": "^8.11.0", "@types/pg": "^8.11.0",
"@types/pngjs": "^6.0.4", "@types/pngjs": "^6.0.4",
@@ -45,7 +45,7 @@
}, },
"../cli": { "../cli": {
"name": "@immich/cli", "name": "@immich/cli",
"version": "2.2.50", "version": "2.2.48",
"dev": true, "dev": true,
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
@@ -64,7 +64,7 @@
"@types/cli-progress": "^3.11.0", "@types/cli-progress": "^3.11.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/mock-fs": "^4.13.1", "@types/mock-fs": "^4.13.1",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@typescript-eslint/eslint-plugin": "^8.15.0", "@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0", "@typescript-eslint/parser": "^8.15.0",
"@vitest/coverage-v8": "^3.0.0", "@vitest/coverage-v8": "^3.0.0",
@@ -92,14 +92,14 @@
}, },
"../open-api/typescript-sdk": { "../open-api/typescript-sdk": {
"name": "@immich/sdk", "name": "@immich/sdk",
"version": "1.126.1", "version": "1.125.7",
"dev": true, "dev": true,
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
"@oazapfts/runtime": "^1.0.2" "@oazapfts/runtime": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }
}, },
@@ -1666,9 +1666,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.13.1", "version": "22.10.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.9.tgz",
"integrity": "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==", "integrity": "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "immich-e2e", "name": "immich-e2e",
"version": "1.126.1", "version": "1.125.7",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
@@ -25,7 +25,7 @@
"@immich/sdk": "file:../open-api/typescript-sdk", "@immich/sdk": "file:../open-api/typescript-sdk",
"@playwright/test": "^1.44.1", "@playwright/test": "^1.44.1",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@types/oidc-provider": "^8.5.1", "@types/oidc-provider": "^8.5.1",
"@types/pg": "^8.11.0", "@types/pg": "^8.11.0",
"@types/pngjs": "^6.0.4", "@types/pngjs": "^6.0.4",
+29 -1
View File
@@ -1,5 +1,5 @@
import { LibraryResponseDto, LoginResponseDto, getAllLibraries, scanLibrary } from '@immich/sdk'; import { LibraryResponseDto, LoginResponseDto, getAllLibraries, scanLibrary } from '@immich/sdk';
import { cpSync, existsSync, rmSync, unlinkSync } from 'node:fs'; import { chmodSync, cpSync, existsSync, promises, rmSync, unlinkSync } from 'node:fs';
import { Socket } from 'socket.io-client'; import { Socket } from 'socket.io-client';
import { userDto, uuidDto } from 'src/fixtures'; import { userDto, uuidDto } from 'src/fixtures';
import { errorDto } from 'src/responses'; import { errorDto } from 'src/responses';
@@ -492,6 +492,34 @@ describe('/libraries', () => {
utils.removeImageFile(`${testAssetDir}/temp/folder${char}2/asset2.png`); utils.removeImageFile(`${testAssetDir}/temp/folder${char}2/asset2.png`);
}); });
it('should handle permission errors on import paths without error', async () => {
const library = await utils.createLibrary(admin.accessToken, {
ownerId: admin.userId,
importPaths: [`${testAssetDirInternal}/temp/`],
});
const stat = await promises.stat(`${testAssetDir}/temp/directoryA`);
const mode = stat.mode;
chmodSync(`${testAssetDir}/temp/directoryB`, 0o000);
const { status } = await request(app)
.post(`/libraries/${library.id}/scan`)
.set('Authorization', `Bearer ${admin.accessToken}`)
.send();
expect(status).toBe(204);
await utils.waitForQueueFinish(admin.accessToken, 'library');
chmodSync(`${testAssetDir}/temp/directoryB`, mode);
const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id });
expect(assets.count).toBe(1);
expect(assets.items.find((asset) => asset.originalPath.includes('directoryA'))).toBeDefined();
expect(assets.items.find((asset) => asset.originalPath.includes('directoryB'))).not.toBeDefined();
});
it('should reimport a modified file', async () => { it('should reimport a modified file', async () => {
const library = await utils.createLibrary(admin.accessToken, { const library = await utils.createLibrary(admin.accessToken, {
ownerId: admin.userId, ownerId: admin.userId,
-19
View File
@@ -195,7 +195,6 @@ describe('/people', () => {
.send({ .send({
name: 'New Person', name: 'New Person',
birthDate: '1990-01-01', birthDate: '1990-01-01',
color: '#333',
}); });
expect(status).toBe(201); expect(status).toBe(201);
expect(body).toMatchObject({ expect(body).toMatchObject({
@@ -274,24 +273,6 @@ describe('/people', () => {
expect(body).toMatchObject({ birthDate: null }); expect(body).toMatchObject({ birthDate: null });
}); });
it('should set a color', async () => {
const { status, body } = await request(app)
.put(`/people/${visiblePerson.id}`)
.set('Authorization', `Bearer ${admin.accessToken}`)
.send({ color: '#555' });
expect(status).toBe(200);
expect(body).toMatchObject({ color: '#555' });
});
it('should clear a color', async () => {
const { status, body } = await request(app)
.put(`/people/${visiblePerson.id}`)
.set('Authorization', `Bearer ${admin.accessToken}`)
.send({ color: null });
expect(status).toBe(200);
expect(body.color).toBeUndefined();
});
it('should mark a person as favorite', async () => { it('should mark a person as favorite', async () => {
const person = await utils.createPerson(admin.accessToken, { const person = await utils.createPerson(admin.accessToken, {
name: 'visible_person', name: 'visible_person',
-24
View File
@@ -150,30 +150,6 @@ describe('/shared-links', () => {
); );
}); });
it('should filter on albumId', async () => {
const { status, body } = await request(app)
.get(`/shared-links?albumId=${album.id}`)
.set('Authorization', `Bearer ${user1.accessToken}`);
expect(status).toBe(200);
expect(body).toHaveLength(2);
expect(body).toEqual(
expect.arrayContaining([
expect.objectContaining({ id: linkWithAlbum.id }),
expect.objectContaining({ id: linkWithPassword.id }),
]),
);
});
it('should find 0 albums', async () => {
const { status, body } = await request(app)
.get(`/shared-links?albumId=${uuidDto.notFound}`)
.set('Authorization', `Bearer ${user1.accessToken}`);
expect(status).toBe(200);
expect(body).toHaveLength(0);
});
it('should not get shared links created by other users', async () => { it('should not get shared links created by other users', async () => {
const { status, body } = await request(app) const { status, body } = await request(app)
.get('/shared-links') .get('/shared-links')
-7
View File
@@ -436,7 +436,6 @@
"back_close_deselect": "Back, close, or deselect", "back_close_deselect": "Back, close, or deselect",
"backward": "Backward", "backward": "Backward",
"birthdate_saved": "Date of birth saved successfully", "birthdate_saved": "Date of birth saved successfully",
"show_shared_links": "Show shared links",
"birthdate_set_description": "Date of birth is used to calculate the age of this person at the time of a photo.", "birthdate_set_description": "Date of birth is used to calculate the age of this person at the time of a photo.",
"blurred_background": "Blurred background", "blurred_background": "Blurred background",
"bugs_and_feature_requests": "Bugs & Feature Requests", "bugs_and_feature_requests": "Bugs & Feature Requests",
@@ -769,10 +768,8 @@
"go_to_search": "Go to search", "go_to_search": "Go to search",
"go_to_folder": "Go to folder", "go_to_folder": "Go to folder",
"group_albums_by": "Group albums by...", "group_albums_by": "Group albums by...",
"group_country": "Group by country",
"group_no": "No grouping", "group_no": "No grouping",
"group_owner": "Group by owner", "group_owner": "Group by owner",
"group_places_by": "Group places by...",
"group_year": "Group by year", "group_year": "Group by year",
"has_quota": "Has quota", "has_quota": "Has quota",
"hi_user": "Hi {name} ({email})", "hi_user": "Hi {name} ({email})",
@@ -805,7 +802,6 @@
"include_shared_albums": "Include shared albums", "include_shared_albums": "Include shared albums",
"include_shared_partner_assets": "Include shared partner assets", "include_shared_partner_assets": "Include shared partner assets",
"individual_share": "Individual share", "individual_share": "Individual share",
"individual_shares": "Individual shares",
"info": "Info", "info": "Info",
"interval": { "interval": {
"day_at_onepm": "Every day at 1pm", "day_at_onepm": "Every day at 1pm",
@@ -991,7 +987,6 @@
"pick_a_location": "Pick a location", "pick_a_location": "Pick a location",
"place": "Place", "place": "Place",
"places": "Places", "places": "Places",
"places_count": "{count, plural, one {{count, number} Place} other {{count, number} Places}}",
"play": "Play", "play": "Play",
"play_memories": "Play memories", "play_memories": "Play memories",
"play_motion_photo": "Play Motion Photo", "play_motion_photo": "Play Motion Photo",
@@ -1174,7 +1169,6 @@
"shared_from_partner": "Photos from {partner}", "shared_from_partner": "Photos from {partner}",
"shared_link_options": "Shared link options", "shared_link_options": "Shared link options",
"shared_links": "Shared links", "shared_links": "Shared links",
"shared_links_description": "Share photos and videos with a link",
"shared_photos_and_videos_count": "{assetCount, plural, other {# shared photos & videos.}}", "shared_photos_and_videos_count": "{assetCount, plural, other {# shared photos & videos.}}",
"shared_with_partner": "Shared with {partner}", "shared_with_partner": "Shared with {partner}",
"sharing": "Sharing", "sharing": "Sharing",
@@ -1284,7 +1278,6 @@
"unfavorite": "Unfavorite", "unfavorite": "Unfavorite",
"unhide_person": "Unhide person", "unhide_person": "Unhide person",
"unknown": "Unknown", "unknown": "Unknown",
"unknown_country": "Unknown Country",
"unknown_year": "Unknown Year", "unknown_year": "Unknown Year",
"unlimited": "Unlimited", "unlimited": "Unlimited",
"unlink_motion_video": "Unlink motion video", "unlink_motion_video": "Unlink motion video",
+437 -437
View File
@@ -312,157 +312,157 @@
"admin_password": "رمز عبور مدیر", "admin_password": "رمز عبور مدیر",
"administration": "مدیریت", "administration": "مدیریت",
"advanced": "پیشرفته", "advanced": "پیشرفته",
"album_added": "آلبوم اضافه شد", "album_added": "",
"album_added_notification_setting_description": "", "album_added_notification_setting_description": "",
"album_cover_updated": "جلد آلبوم به‌روزرسانی شد", "album_cover_updated": "",
"album_info_updated": "اطلاعات آلبوم به‌روزرسانی شد", "album_info_updated": "",
"album_name": "نام آلبوم", "album_name": "",
"album_options": "گزینه‌های آلبوم", "album_options": "",
"album_updated": "آلبوم به‌روزرسانی شد", "album_updated": "",
"album_updated_setting_description": "", "album_updated_setting_description": "",
"albums": "آلبوم‌ها", "albums": "",
"albums_count": "", "albums_count": "",
"all": "همه", "all": "",
"all_people": "همه افراد", "all_people": "",
"allow_dark_mode": "اجازه دادن به حالت تاریک", "allow_dark_mode": "",
"allow_edits": "اجازه ویرایش", "allow_edits": "",
"api_key": "کلید API", "api_key": "",
"api_keys": "کلیدهای API", "api_keys": "",
"app_settings": "تنظیمات برنامه", "app_settings": "",
"appears_in": "ظاهر می‌شود در", "appears_in": "",
"archive": "بایگانی", "archive": "",
"archive_or_unarchive_photo": "", "archive_or_unarchive_photo": "",
"archive_size": "اندازه بایگانی", "archive_size": "",
"archive_size_description": "", "archive_size_description": "",
"asset_offline": "محتوا آفلاین", "asset_offline": "",
"assets": "محتواها", "assets": "",
"authorized_devices": "دستگاه‌های مجاز", "authorized_devices": "",
"back": "بازگشت", "back": "",
"backward": "عقب", "backward": "",
"blurred_background": "پس‌زمینه محو", "blurred_background": "",
"bulk_delete_duplicates_confirmation": "", "bulk_delete_duplicates_confirmation": "",
"bulk_keep_duplicates_confirmation": "", "bulk_keep_duplicates_confirmation": "",
"bulk_trash_duplicates_confirmation": "", "bulk_trash_duplicates_confirmation": "",
"camera": "دوربین", "camera": "",
"camera_brand": "برند دوربین", "camera_brand": "",
"camera_model": "مدل دوربین", "camera_model": "",
"cancel": "لغو", "cancel": "",
"cancel_search": "لغو جستجو", "cancel_search": "",
"cannot_merge_people": "نمی‌توان افراد را ادغام کرد", "cannot_merge_people": "",
"cannot_update_the_description": "نمی‌توان توضیحات را به‌روزرسانی کرد", "cannot_update_the_description": "",
"change_date": "تغییر تاریخ", "change_date": "",
"change_expiration_time": "تغییر زمان انقضا", "change_expiration_time": "",
"change_location": "تغییر مکان", "change_location": "",
"change_name": "تغییر نام", "change_name": "",
"change_name_successfully": "نام با موفقیت تغییر یافت", "change_name_successfully": "",
"change_password": "تغییر رمز عبور", "change_password": "",
"change_your_password": "رمز عبور خود را تغییر دهید", "change_your_password": "",
"changed_visibility_successfully": "", "changed_visibility_successfully": "",
"check_all": "انتخاب همه", "check_all": "",
"check_logs": "بررسی لاگ‌ها", "check_logs": "",
"choose_matching_people_to_merge": "", "choose_matching_people_to_merge": "",
"city": "شهر", "city": "",
"clear": "پاک کردن", "clear": "",
"clear_all": "پاک کردن همه", "clear_all": "",
"clear_message": "پاک کردن پیام", "clear_message": "",
"clear_value": "پاک کردن مقدار", "clear_value": "",
"close": "بستن", "close": "",
"collapse_all": "جمع کردن همه", "collapse_all": "",
"color_theme": "تم رنگ", "color_theme": "",
"comment_options": "گزینه‌های نظر", "comment_options": "",
"comments_are_disabled": "نظرات غیرفعال هستند", "comments_are_disabled": "",
"confirm": "تأیید", "confirm": "",
"confirm_admin_password": "تأیید رمز عبور مدیر", "confirm_admin_password": "",
"confirm_delete_shared_link": "", "confirm_delete_shared_link": "",
"confirm_password": "تأیید رمز عبور", "confirm_password": "",
"contain": "شامل", "contain": "",
"context": "زمینه", "context": "",
"continue": "ادامه", "continue": "",
"copied_image_to_clipboard": "تصویر به کلیپ‌بورد کپی شد.", "copied_image_to_clipboard": "",
"copied_to_clipboard": "به کلیپ‌بورد کپی شد!", "copied_to_clipboard": "",
"copy_error": "خطا در کپی", "copy_error": "",
"copy_file_path": "کپی مسیر فایل", "copy_file_path": "",
"copy_image": "کپی تصویر", "copy_image": "",
"copy_link": "کپی لینک", "copy_link": "",
"copy_link_to_clipboard": "کپی لینک به کلیپ‌بورد", "copy_link_to_clipboard": "",
"copy_password": "کپی رمز عبور", "copy_password": "",
"copy_to_clipboard": "کپی به کلیپ‌بورد", "copy_to_clipboard": "",
"country": "کشور", "country": "",
"cover": "جلد", "cover": "",
"covers": "جلدها", "covers": "",
"create": "ایجاد", "create": "",
"create_album": "ایجاد آلبوم", "create_album": "",
"create_library": "ایجاد کتابخانه", "create_library": "",
"create_link": "ایجاد لینک", "create_link": "",
"create_link_to_share": "ایجاد لینک برای اشتراک‌گذاری", "create_link_to_share": "",
"create_new_person": "ایجاد فرد جدید", "create_new_person": "",
"create_new_user": "ایجاد کاربر جدید", "create_new_user": "",
"create_user": "ایجاد کاربر", "create_user": "",
"created": "ایجاد شد", "created": "",
"current_device": "دستگاه فعلی", "current_device": "",
"custom_locale": "", "custom_locale": "",
"custom_locale_description": "", "custom_locale_description": "",
"dark": "تاریک", "dark": "",
"date_after": "تاریخ پس از", "date_after": "",
"date_and_time": "تاریخ و زمان", "date_and_time": "",
"date_before": "تاریخ قبل از", "date_before": "",
"date_range": "بازه زمانی", "date_range": "",
"day": "روز", "day": "",
"deduplicate_all": "حذف تکراری‌ها به صورت کامل", "deduplicate_all": "",
"default_locale": "", "default_locale": "",
"default_locale_description": "", "default_locale_description": "",
"delete": "حذف", "delete": "",
"delete_album": "حذف آلبوم", "delete_album": "",
"delete_api_key_prompt": "", "delete_api_key_prompt": "",
"delete_duplicates_confirmation": "", "delete_duplicates_confirmation": "",
"delete_key": "حذف کلید", "delete_key": "",
"delete_library": "حذف کتابخانه", "delete_library": "",
"delete_link": "حذف لینک", "delete_link": "",
"delete_shared_link": "حذف لینک اشتراکی", "delete_shared_link": "",
"delete_user": "حذف کاربر", "delete_user": "",
"deleted_shared_link": "لینک اشتراکی حذف شد", "deleted_shared_link": "",
"description": "توضیحات", "description": "",
"details": "جزئیات", "details": "",
"direction": "جهت", "direction": "",
"disabled": "غیرفعال", "disabled": "",
"disallow_edits": "عدم اجازه ویرایش", "disallow_edits": "",
"discover": "کشف کردن", "discover": "",
"dismiss_all_errors": "رد تمام خطاها", "dismiss_all_errors": "",
"dismiss_error": "رد خطا", "dismiss_error": "",
"display_options": "گزینه‌های نمایش", "display_options": "",
"display_order": "ترتیب نمایش", "display_order": "",
"display_original_photos": "نمایش عکس‌های اصلی", "display_original_photos": "",
"display_original_photos_setting_description": "", "display_original_photos_setting_description": "",
"done": "انجام شد", "done": "",
"download": "دانلود", "download": "",
"download_settings": "تنظیمات دانلود", "download_settings": "",
"download_settings_description": "مدیریت تنظیمات مرتبط با دانلود محتوا", "download_settings_description": "",
"downloading": "در حال دانلود", "downloading": "",
"duplicates": "تکراری‌ها", "duplicates": "",
"duplicates_description": "", "duplicates_description": "",
"duration": "مدت زمان", "duration": "",
"edit_album": "ویرایش آلبوم", "edit_album": "",
"edit_avatar": "ویرایش آواتار", "edit_avatar": "",
"edit_date": "ویرایش تاریخ", "edit_date": "",
"edit_date_and_time": "ویرایش تاریخ و زمان", "edit_date_and_time": "",
"edit_exclusion_pattern": "ویرایش الگوی استثناء", "edit_exclusion_pattern": "",
"edit_faces": "ویرایش چهره‌ها", "edit_faces": "",
"edit_import_path": "", "edit_import_path": "",
"edit_import_paths": "", "edit_import_paths": "",
"edit_key": "ویرایش کلید", "edit_key": "",
"edit_link": "ویرایش لینک", "edit_link": "",
"edit_location": "ویرایش مکان", "edit_location": "",
"edit_name": "ویرایش نام", "edit_name": "",
"edit_people": "ویرایش افراد", "edit_people": "",
"edit_title": "ویرایش عنوان", "edit_title": "",
"edit_user": "ویرایش کاربر", "edit_user": "",
"edited": "ویرایش شد", "edited": "",
"editor": "ویرایشگر", "editor": "",
"email": "ایمیل", "email": "",
"empty_trash": "خالی کردن سطل زباله", "empty_trash": "",
"end_date": "تاریخ پایان", "end_date": "",
"error": "خطا", "error": "",
"error_loading_image": "خطا در بارگذاری تصویر", "error_loading_image": "",
"errors": { "errors": {
"exclusion_pattern_already_exists": "", "exclusion_pattern_already_exists": "",
"import_path_already_exists": "", "import_path_already_exists": "",
@@ -530,400 +530,400 @@
"unable_to_update_timeline_display_status": "", "unable_to_update_timeline_display_status": "",
"unable_to_update_user": "" "unable_to_update_user": ""
}, },
"exit_slideshow": "خروج از نمایش اسلاید", "exit_slideshow": "",
"expand_all": "باز کردن همه", "expand_all": "",
"expire_after": "منقضی شدن بعد از", "expire_after": "",
"expired": "منقضی شده", "expired": "",
"explore": "کاوش کردن", "explore": "",
"export": "صادر کردن", "export": "",
"export_as_json": "صادر کردن به‌صورت JSON", "export_as_json": "",
"extension": "پسوند", "extension": "",
"external": "خارجی", "external": "",
"external_libraries": "کتابخانه‌های خارجی", "external_libraries": "",
"favorite": "علاقه‌مندی", "favorite": "",
"favorite_or_unfavorite_photo": "", "favorite_or_unfavorite_photo": "",
"favorites": "علاقه‌مندی‌ها", "favorites": "",
"feature_photo_updated": "", "feature_photo_updated": "",
"file_name": "نام فایل", "file_name": "",
"file_name_or_extension": "نام فایل یا پسوند", "file_name_or_extension": "",
"filename": "نام فایل", "filename": "",
"filetype": "نوع فایل", "filetype": "",
"filter_people": "فیلتر افراد", "filter_people": "",
"find_them_fast": "", "find_them_fast": "",
"fix_incorrect_match": "رفع تطابق نادرست", "fix_incorrect_match": "",
"forward": "جلو", "forward": "",
"general": "عمومی", "general": "",
"get_help": "دریافت کمک", "get_help": "",
"getting_started": "شروع به کار", "getting_started": "",
"go_back": "بازگشت", "go_back": "",
"go_to_search": "رفتن به جستجو", "go_to_search": "",
"group_albums_by": "گروه‌بندی آلبوم‌ها براساس...", "group_albums_by": "",
"has_quota": "دارای سهمیه", "has_quota": "",
"hide_gallery": "پنهان کردن گالری", "hide_gallery": "",
"hide_password": "پنهان کردن رمز عبور", "hide_password": "",
"hide_person": "پنهان کردن فرد", "hide_person": "",
"host": "میزبان", "host": "",
"hour": "ساعت", "hour": "",
"image": "تصویر", "image": "",
"immich_logo": "لوگوی Immich", "immich_logo": "",
"immich_web_interface": "رابط وب Immich", "immich_web_interface": "",
"import_from_json": "وارد کردن از JSON", "import_from_json": "",
"import_path": "مسیر وارد کردن", "import_path": "",
"in_albums": "", "in_albums": "",
"in_archive": "در بایگانی", "in_archive": "",
"include_archived": "شامل بایگانی شده‌ها", "include_archived": "",
"include_shared_albums": "شامل آلبوم‌های اشتراکی", "include_shared_albums": "",
"include_shared_partner_assets": "", "include_shared_partner_assets": "",
"individual_share": "اشتراک فردی", "individual_share": "",
"info": "اطلاعات", "info": "",
"interval": { "interval": {
"day_at_onepm": "", "day_at_onepm": "",
"hours": "", "hours": "",
"night_at_midnight": "", "night_at_midnight": "",
"night_at_twoam": "" "night_at_twoam": ""
}, },
"invite_people": "دعوت افراد", "invite_people": "",
"invite_to_album": "دعوت به آلبوم", "invite_to_album": "",
"jobs": "وظایف", "jobs": "",
"keep": "نگه داشتن", "keep": "",
"keep_all": "نگه داشتن همه", "keep_all": "",
"keyboard_shortcuts": "میانبرهای صفحه‌کلید", "keyboard_shortcuts": "",
"language": "زبان", "language": "",
"language_setting_description": "انتخاب زبان دلخواه شما", "language_setting_description": "",
"last_seen": "آخرین مشاهده", "last_seen": "",
"leave": "ترک کردن", "leave": "",
"let_others_respond": "اجازه به دیگران برای پاسخ‌گویی", "let_others_respond": "",
"level": "سطح", "level": "",
"library": "کتابخانه", "library": "",
"library_options": "گزینه‌های کتابخانه", "library_options": "",
"light": "روشن", "light": "",
"link_options": "گزینه‌های لینک", "link_options": "",
"link_to_oauth": "اتصال به OAuth", "link_to_oauth": "",
"linked_oauth_account": "حساب OAuth متصل شده", "linked_oauth_account": "",
"list": "لیست", "list": "",
"loading": "در حال بارگذاری", "loading": "",
"loading_search_results_failed": "بارگذاری نتایج جستجو ناموفق بود", "loading_search_results_failed": "",
"log_out": "خروج از سیستم", "log_out": "",
"log_out_all_devices": "خروج از همه دستگاه‌ها", "log_out_all_devices": "",
"login_has_been_disabled": "ورود غیرفعال شده است.", "login_has_been_disabled": "",
"look": "نگاه کردن", "look": "",
"loop_videos": "پخش مداوم ویدئوها", "loop_videos": "",
"loop_videos_description": "", "loop_videos_description": "",
"make": "ساختن", "make": "",
"manage_shared_links": "مدیریت لینک‌های اشتراکی", "manage_shared_links": "",
"manage_sharing_with_partners": "", "manage_sharing_with_partners": "",
"manage_the_app_settings": "مدیریت تنظیمات برنامه", "manage_the_app_settings": "",
"manage_your_account": "مدیریت حساب کاربری شما", "manage_your_account": "",
"manage_your_api_keys": "مدیریت کلیدهای API شما", "manage_your_api_keys": "",
"manage_your_devices": "مدیریت دستگاه‌های متصل", "manage_your_devices": "",
"manage_your_oauth_connection": "مدیریت اتصال OAuth شما", "manage_your_oauth_connection": "",
"map": "نقشه", "map": "",
"map_marker_with_image": "", "map_marker_with_image": "",
"map_settings": "تنظیمات نقشه", "map_settings": "",
"matches": "تطابق‌ها", "matches": "",
"media_type": "نوع رسانه", "media_type": "",
"memories": "خاطرات", "memories": "",
"memories_setting_description": "", "memories_setting_description": "",
"memory": "خاطره", "memory": "",
"menu": "منو", "menu": "",
"merge": "ادغام", "merge": "",
"merge_people": "ادغام افراد", "merge_people": "",
"merge_people_limit": "", "merge_people_limit": "",
"merge_people_prompt": "", "merge_people_prompt": "",
"merge_people_successfully": "ادغام افراد با موفقیت انجام شد", "merge_people_successfully": "",
"minimize": "کوچک کردن", "minimize": "",
"minute": "دقیقه", "minute": "",
"missing": "گمشده", "missing": "",
"model": "مدل", "model": "",
"month": "ماه", "month": "",
"more": "بیشتر", "more": "",
"moved_to_trash": "به سطل زباله منتقل شد", "moved_to_trash": "",
"my_albums": "آلبوم‌های من", "my_albums": "",
"name": "نام", "name": "",
"name_or_nickname": "نام یا لقب", "name_or_nickname": "",
"never": "هرگز", "never": "",
"new_api_key": "کلید API جدید", "new_api_key": "",
"new_password": "رمز عبور جدید", "new_password": "",
"new_person": "فرد جدید", "new_person": "",
"new_user_created": "کاربر جدید ایجاد شد", "new_user_created": "",
"newest_first": "جدیدترین ابتدا", "newest_first": "",
"next": "بعدی", "next": "",
"next_memory": "خاطره بعدی", "next_memory": "",
"no": "خیر", "no": "",
"no_albums_message": "", "no_albums_message": "",
"no_archived_assets_message": "", "no_archived_assets_message": "",
"no_assets_message": "", "no_assets_message": "",
"no_duplicates_found": "هیچ تکراری یافت نشد.", "no_duplicates_found": "",
"no_exif_info_available": "اطلاعات EXIF موجود نیست", "no_exif_info_available": "",
"no_explore_results_message": "", "no_explore_results_message": "",
"no_favorites_message": "", "no_favorites_message": "",
"no_libraries_message": "", "no_libraries_message": "",
"no_name": "بدون نام", "no_name": "",
"no_places": "مکانی یافت نشد", "no_places": "",
"no_results": "نتیجه‌ای یافت نشد", "no_results": "",
"no_shared_albums_message": "", "no_shared_albums_message": "",
"not_in_any_album": "در هیچ آلبومی نیست", "not_in_any_album": "",
"note_apply_storage_label_to_previously_uploaded assets": "", "note_apply_storage_label_to_previously_uploaded assets": "",
"note_unlimited_quota": "", "note_unlimited_quota": "",
"notes": "یادداشت‌ها", "notes": "",
"notification_toggle_setting_description": "اعلان‌های ایمیلی را فعال کنید", "notification_toggle_setting_description": "",
"notifications": "اعلان‌ها", "notifications": "",
"notifications_setting_description": "مدیریت اعلان‌ها", "notifications_setting_description": "",
"oauth": "OAuth", "oauth": "",
"offline": "آفلاین", "offline": "",
"offline_paths": "مسیرهای آفلاین", "offline_paths": "",
"offline_paths_description": "", "offline_paths_description": "",
"ok": "تأیید", "ok": "",
"oldest_first": "قدیمی‌ترین ابتدا", "oldest_first": "",
"online": "آنلاین", "online": "",
"only_favorites": "فقط علاقه‌مندی‌ها", "only_favorites": "",
"open_the_search_filters": "باز کردن فیلترهای جستجو", "open_the_search_filters": "",
"options": "گزینه‌ها", "options": "",
"organize_your_library": "کتابخانه خود را سازماندهی کنید", "organize_your_library": "",
"other": "دیگر", "other": "",
"other_devices": "دستگاه‌های دیگر", "other_devices": "",
"other_variables": "متغیرهای دیگر", "other_variables": "",
"owned": "مالکیت", "owned": "",
"owner": "مالک", "owner": "",
"partner": "شریک", "partner": "",
"partner_can_access": "{partner} می‌تواند دسترسی داشته باشد", "partner_can_access": "",
"partner_can_access_assets": "", "partner_can_access_assets": "",
"partner_can_access_location": "مکان‌هایی که عکس‌های شما گرفته شده‌اند", "partner_can_access_location": "",
"partner_sharing": "اشتراک‌گذاری با شریک", "partner_sharing": "",
"partners": "شرکا", "partners": "",
"password": "رمز عبور", "password": "",
"password_does_not_match": "رمز عبور مطابقت ندارد", "password_does_not_match": "",
"password_required": "رمز عبور مورد نیاز است", "password_required": "",
"password_reset_success": "بازنشانی رمز عبور موفقیت‌آمیز بود", "password_reset_success": "",
"past_durations": { "past_durations": {
"days": "", "days": "",
"hours": "", "hours": "",
"years": "" "years": ""
}, },
"path": "مسیر", "path": "",
"pattern": "الگو", "pattern": "",
"pause": "توقف", "pause": "",
"pause_memories": "توقف خاطرات", "pause_memories": "",
"paused": "متوقف شده", "paused": "",
"pending": "در انتظار", "pending": "",
"people": "افراد", "people": "",
"people_sidebar_description": "", "people_sidebar_description": "",
"permanent_deletion_warning": "هشدار حذف دائمی", "permanent_deletion_warning": "",
"permanent_deletion_warning_setting_description": "نمایش هشدار هنگام حذف دائمی محتواها", "permanent_deletion_warning_setting_description": "",
"permanently_delete": "حذف دائمی", "permanently_delete": "",
"permanently_deleted_asset": "محتوای حذف شده دائمی", "permanently_deleted_asset": "",
"person": "فرد", "person": "",
"photos": "عکس‌ها", "photos": "",
"photos_count": "", "photos_count": "",
"photos_from_previous_years": "عکس‌های سال‌های گذشته", "photos_from_previous_years": "",
"pick_a_location": "یک مکان انتخاب کنید", "pick_a_location": "",
"place": "مکان", "place": "",
"places": "مکان‌ها", "places": "",
"play": "پخش", "play": "",
"play_memories": "پخش خاطرات", "play_memories": "",
"play_motion_photo": "پخش عکس متحرک", "play_motion_photo": "",
"play_or_pause_video": "پخش یا توقف ویدیو", "play_or_pause_video": "",
"port": "پورت", "port": "",
"preset": "پیش‌فرض", "preset": "",
"preview": "پیش‌نمایش", "preview": "",
"previous": "قبلی", "previous": "",
"previous_memory": "خاطره قبلی", "previous_memory": "",
"previous_or_next_photo": "عکس قبلی یا بعدی", "previous_or_next_photo": "",
"primary": "اصلی", "primary": "",
"profile_picture_set": "تصویر پروفایل تنظیم شد.", "profile_picture_set": "",
"public_share": "اشتراک عمومی", "public_share": "",
"reaction_options": "گزینه‌های واکنش", "reaction_options": "",
"read_changelog": "مطالعه تغییرات نسخه", "read_changelog": "",
"recent": "اخیر", "recent": "",
"recent_searches": "جستجوهای اخیر", "recent_searches": "",
"refresh": "تازه سازی", "refresh": "",
"refreshed": "تازه سازی شد", "refreshed": "",
"refreshes_every_file": "", "refreshes_every_file": "",
"remove": "حذف", "remove": "",
"remove_deleted_assets": "حذف محتواهای حذف‌شده", "remove_deleted_assets": "",
"remove_from_album": "حذف از آلبوم", "remove_from_album": "",
"remove_from_favorites": "حذف از علاقه‌مندی‌ها", "remove_from_favorites": "",
"remove_from_shared_link": "", "remove_from_shared_link": "",
"removed_api_key": "", "removed_api_key": "",
"rename": "تغییر نام", "rename": "",
"repair": "تعمیر", "repair": "",
"repair_no_results_message": "", "repair_no_results_message": "",
"replace_with_upload": "جایگزینی با آپلود", "replace_with_upload": "",
"require_password": "", "require_password": "",
"require_user_to_change_password_on_first_login": "", "require_user_to_change_password_on_first_login": "",
"reset": "بازنشانی", "reset": "",
"reset_password": "بازنشانی رمز عبور", "reset_password": "",
"reset_people_visibility": "", "reset_people_visibility": "",
"resolved_all_duplicates": "", "resolved_all_duplicates": "",
"restore": "بازیابی", "restore": "",
"restore_all": "بازیابی همه", "restore_all": "",
"restore_user": "بازیابی کاربر", "restore_user": "",
"resume": "ادامه", "resume": "",
"retry_upload": "", "retry_upload": "",
"review_duplicates": "بررسی تکراری‌ها", "review_duplicates": "",
"role": "نقش", "role": "",
"save": "ذخیره", "save": "",
"saved_api_key": "", "saved_api_key": "",
"saved_profile": "پروفایل ذخیره شد", "saved_profile": "",
"saved_settings": "تنظیمات ذخیره شد", "saved_settings": "",
"say_something": "چیزی بگویید", "say_something": "",
"scan_all_libraries": "اسکن همه کتابخانه‌ها", "scan_all_libraries": "",
"scan_settings": "تنظیمات اسکن", "scan_settings": "",
"scanning_for_album": "", "scanning_for_album": "",
"search": "جستجو", "search": "",
"search_albums": "جستجوی آلبوم‌ها", "search_albums": "",
"search_by_context": "جستجو براساس زمینه", "search_by_context": "",
"search_camera_make": "جستجوی برند دوربین...", "search_camera_make": "",
"search_camera_model": "جستجوی مدل دوربین...", "search_camera_model": "",
"search_city": "جستجوی شهر...", "search_city": "",
"search_country": "جستجوی کشور...", "search_country": "",
"search_for_existing_person": "جستجوی فرد موجود", "search_for_existing_person": "",
"search_people": "جستجوی افراد", "search_people": "",
"search_places": "جستجوی مکان‌ها", "search_places": "",
"search_state": "جستجوی ایالت...", "search_state": "",
"search_timezone": "جستجوی منطقه زمانی...", "search_timezone": "",
"search_type": "نوع جستجو", "search_type": "",
"search_your_photos": "", "search_your_photos": "",
"searching_locales": "", "searching_locales": "",
"second": "ثانیه", "second": "",
"select_album_cover": "انتخاب جلد آلبوم", "select_album_cover": "",
"select_all": "انتخاب همه", "select_all": "",
"select_avatar_color": "انتخاب رنگ آواتار", "select_avatar_color": "",
"select_face": "انتخاب چهره", "select_face": "",
"select_featured_photo": "انتخاب عکس ویژه", "select_featured_photo": "",
"select_keep_all": "انتخاب نگهداری همه", "select_keep_all": "",
"select_library_owner": "انتخاب مالک کتابخانه", "select_library_owner": "",
"select_new_face": "انتخاب چهره جدید", "select_new_face": "",
"select_photos": "انتخاب عکس‌ها", "select_photos": "",
"select_trash_all": "", "select_trash_all": "",
"selected": "انتخاب شده", "selected": "",
"send_message": "ارسال پیام", "send_message": "",
"send_welcome_email": "ارسال ایمیل خوش‌آمدگویی", "send_welcome_email": "",
"server_stats": "آمار سرور", "server_stats": "",
"set": "تنظیم", "set": "",
"set_as_album_cover": "", "set_as_album_cover": "",
"set_as_profile_picture": "", "set_as_profile_picture": "",
"set_date_of_birth": "تنظیم تاریخ تولد", "set_date_of_birth": "",
"set_profile_picture": "تنظیم تصویر پروفایل", "set_profile_picture": "",
"set_slideshow_to_fullscreen": "", "set_slideshow_to_fullscreen": "",
"settings": "تنظیمات", "settings": "",
"settings_saved": "تنظیمات ذخیره شد", "settings_saved": "",
"share": "اشتراک‌گذاری", "share": "",
"shared": "مشترک", "shared": "",
"shared_by": "مشترک توسط", "shared_by": "",
"shared_by_you": "", "shared_by_you": "",
"shared_from_partner": "عکس‌ها از {partner}", "shared_from_partner": "",
"shared_links": "لینک‌های اشتراکی", "shared_links": "",
"shared_photos_and_videos_count": "", "shared_photos_and_videos_count": "",
"shared_with_partner": "مشترک با {partner}", "shared_with_partner": "",
"sharing": "اشتراک‌گذاری", "sharing": "",
"sharing_sidebar_description": "", "sharing_sidebar_description": "",
"show_album_options": "نمایش گزینه‌های آلبوم", "show_album_options": "",
"show_and_hide_people": "", "show_and_hide_people": "",
"show_file_location": "نمایش مسیر فایل", "show_file_location": "",
"show_gallery": "نمایش گالری", "show_gallery": "",
"show_hidden_people": "نمایش افراد پنهان", "show_hidden_people": "",
"show_in_timeline": "", "show_in_timeline": "",
"show_in_timeline_setting_description": "", "show_in_timeline_setting_description": "",
"show_keyboard_shortcuts": "", "show_keyboard_shortcuts": "",
"show_metadata": "نمایش اطلاعات متا", "show_metadata": "",
"show_or_hide_info": "", "show_or_hide_info": "",
"show_password": "نمایش رمز عبور", "show_password": "",
"show_person_options": "", "show_person_options": "",
"show_progress_bar": "نمایش نوار پیشرفت", "show_progress_bar": "",
"show_search_options": "نمایش گزینه‌های جستجو", "show_search_options": "",
"shuffle": "تصادفی", "shuffle": "",
"sign_out": "خروج", "sign_out": "",
"sign_up": "ثبت‌نام", "sign_up": "",
"size": "اندازه", "size": "",
"skip_to_content": "رفتن به محتوا", "skip_to_content": "",
"slideshow": "نمایش اسلاید", "slideshow": "",
"slideshow_settings": "تنظیمات نمایش اسلاید", "slideshow_settings": "",
"sort_albums_by": "", "sort_albums_by": "",
"stack": "پشته", "stack": "",
"stack_selected_photos": "", "stack_selected_photos": "",
"stacktrace": "", "stacktrace": "",
"start": "شروع", "start": "",
"start_date": "تاریخ شروع", "start_date": "",
"state": "ایالت", "state": "",
"status": "وضعیت", "status": "",
"stop_motion_photo": "توقف عکس متحرک", "stop_motion_photo": "",
"stop_photo_sharing": "", "stop_photo_sharing": "",
"stop_photo_sharing_description": "", "stop_photo_sharing_description": "",
"stop_sharing_photos_with_user": "", "stop_sharing_photos_with_user": "",
"storage": "فضای ذخیره‌سازی", "storage": "",
"storage_label": "برچسب فضای ذخیره‌سازی", "storage_label": "",
"storage_usage": "", "storage_usage": "",
"submit": "ارسال", "submit": "",
"suggestions": "پیشنهادات", "suggestions": "",
"sunrise_on_the_beach": "", "sunrise_on_the_beach": "",
"swap_merge_direction": "تغییر جهت ادغام", "swap_merge_direction": "",
"sync": "همگام‌سازی", "sync": "",
"template": "الگو", "template": "",
"theme": "تم", "theme": "",
"theme_selection": "انتخاب تم", "theme_selection": "",
"theme_selection_description": "", "theme_selection_description": "",
"time_based_memories": "", "time_based_memories": "",
"timezone": "منطقه زمانی", "timezone": "",
"to_archive": "بایگانی", "to_archive": "",
"to_favorite": "به علاقه‌مندی‌ها", "to_favorite": "",
"to_trash": "", "to_trash": "",
"toggle_settings": "تغییر تنظیمات", "toggle_settings": "",
"toggle_theme": "تغییر تم تاریک", "toggle_theme": "",
"total_usage": "استفاده کلی", "total_usage": "",
"trash": "سطل زباله", "trash": "",
"trash_all": "", "trash_all": "",
"trash_count": "", "trash_count": "",
"trash_no_results_message": "", "trash_no_results_message": "",
"trashed_items_will_be_permanently_deleted_after": "", "trashed_items_will_be_permanently_deleted_after": "",
"type": "نوع", "type": "",
"unarchive": "", "unarchive": "",
"unfavorite": "حذف از علاقه‌مندی‌ها", "unfavorite": "",
"unhide_person": "آشکار کردن فرد", "unhide_person": "",
"unknown": "ناشناخته", "unknown": "",
"unknown_year": "سال نامشخص", "unknown_year": "",
"unlimited": "نامحدود", "unlimited": "",
"unlink_oauth": "لغو اتصال OAuth", "unlink_oauth": "",
"unlinked_oauth_account": "", "unlinked_oauth_account": "",
"unnamed_album": "آلبوم بدون نام", "unnamed_album": "",
"unnamed_share": "اشتراک بدون نام", "unnamed_share": "",
"unselect_all": "لغو انتخاب همه", "unselect_all": "",
"unstack": "", "unstack": "",
"untracked_files": "", "untracked_files": "",
"untracked_files_decription": "", "untracked_files_decription": "",
"up_next": "مورد بعدی", "up_next": "",
"updated_password": "", "updated_password": "",
"upload": "آپلود", "upload": "",
"upload_concurrency": "تعداد آپلود همزمان", "upload_concurrency": "",
"url": "آدرس", "url": "",
"usage": "استفاده", "usage": "",
"user": "کاربر", "user": "",
"user_id": "شناسه کاربر", "user_id": "",
"user_usage_detail": "جزئیات استفاده کاربر", "user_usage_detail": "",
"username": "نام کاربری", "username": "",
"users": "کاربران", "users": "",
"utilities": "ابزارها", "utilities": "",
"validate": "اعتبارسنجی", "validate": "",
"variables": "متغیرها", "variables": "",
"version": "نسخه", "version": "",
"version_announcement_message": "", "version_announcement_message": "",
"video": "ویدیو", "video": "",
"video_hover_setting": "", "video_hover_setting": "",
"video_hover_setting_description": "", "video_hover_setting_description": "",
"videos": "ویدیوها", "videos": "",
"videos_count": "", "videos_count": "",
"view": "مشاهده", "view": "",
"view_all": "مشاهده همه", "view_all": "",
"view_all_users": "مشاهده همه کاربران", "view_all_users": "",
"view_links": "مشاهده لینک‌ها", "view_links": "",
"view_next_asset": "مشاهده محتوای بعدی", "view_next_asset": "",
"view_previous_asset": "مشاهده محتوای قبلی", "view_previous_asset": "",
"waiting": "در انتظار", "waiting": "",
"week": "هفته", "week": "",
"welcome": "خوش آمدید", "welcome": "",
"welcome_to_immich": "", "welcome_to_immich": "",
"year": "سال", "year": "",
"yes": "بله", "yes": "",
"you_dont_have_any_shared_links": "", "you_dont_have_any_shared_links": "",
"zoom_image": "بزرگنمایی تصویر" "zoom_image": "بزرگنمایی تصویر"
} }
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "machine-learning" name = "machine-learning"
version = "1.126.1" version = "1.125.7"
description = "" description = ""
authors = ["Hau Tran <alex.tran1502@gmail.com>"] authors = ["Hau Tran <alex.tran1502@gmail.com>"]
readme = "README.md" readme = "README.md"
+2 -2
View File
@@ -35,8 +35,8 @@ platform :android do
task: 'bundle', task: 'bundle',
build_type: 'Release', build_type: 'Release',
properties: { properties: {
"android.injected.version.code" => 184, "android.injected.version.code" => 182,
"android.injected.version.name" => "1.126.1", "android.injected.version.name" => "1.125.7",
} }
) )
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab') upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')
+6 -6
View File
@@ -541,7 +541,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
@@ -685,7 +685,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
@@ -715,7 +715,7 @@
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
@@ -748,7 +748,7 @@
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements; CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -791,7 +791,7 @@
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements; CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -831,7 +831,7 @@
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements; CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 193; CURRENT_PROJECT_VERSION = 190;
CUSTOM_GROUP_ID = group.app.immich.share; CUSTOM_GROUP_ID = group.app.immich.share;
DEVELOPMENT_TEAM = 2F67MQ8R79; DEVELOPMENT_TEAM = 2F67MQ8R79;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES;
+2 -2
View File
@@ -78,7 +78,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.126.0</string> <string>1.125.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
@@ -93,7 +93,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>193</string> <string>190</string>
<key>FLTEnableImpeller</key> <key>FLTEnableImpeller</key>
<true/> <true/>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
+1 -1
View File
@@ -19,7 +19,7 @@ platform :ios do
desc "iOS Release" desc "iOS Release"
lane :release do lane :release do
increment_version_number( increment_version_number(
version_number: "1.126.1" version_number: "1.125.7"
) )
increment_build_number( increment_build_number(
build_number: latest_testflight_build_number + 1, build_number: latest_testflight_build_number + 1,
-1
View File
@@ -10,7 +10,6 @@ dynamic upgradeDto(dynamic value, String targetType) {
addDefault(value, 'ratings', RatingsResponse().toJson()); addDefault(value, 'ratings', RatingsResponse().toJson());
addDefault(value, 'people', PeopleResponse().toJson()); addDefault(value, 'people', PeopleResponse().toJson());
addDefault(value, 'tags', TagsResponse().toJson()); addDefault(value, 'tags', TagsResponse().toJson());
addDefault(value, 'sharedLinks', SharedLinksResponse().toJson());
} }
break; break;
case 'ServerConfigDto': case 'ServerConfigDto':
+1 -3
View File
@@ -3,7 +3,7 @@ Immich API
This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.126.1 - API version: 1.125.7
- Generator version: 7.8.0 - Generator version: 7.8.0
- Build package: org.openapitools.codegen.languages.DartClientCodegen - Build package: org.openapitools.codegen.languages.DartClientCodegen
@@ -408,8 +408,6 @@ Class | Method | HTTP request | Description
- [SharedLinkEditDto](doc//SharedLinkEditDto.md) - [SharedLinkEditDto](doc//SharedLinkEditDto.md)
- [SharedLinkResponseDto](doc//SharedLinkResponseDto.md) - [SharedLinkResponseDto](doc//SharedLinkResponseDto.md)
- [SharedLinkType](doc//SharedLinkType.md) - [SharedLinkType](doc//SharedLinkType.md)
- [SharedLinksResponse](doc//SharedLinksResponse.md)
- [SharedLinksUpdate](doc//SharedLinksUpdate.md)
- [SignUpDto](doc//SignUpDto.md) - [SignUpDto](doc//SignUpDto.md)
- [SmartSearchDto](doc//SmartSearchDto.md) - [SmartSearchDto](doc//SmartSearchDto.md)
- [SourceType](doc//SourceType.md) - [SourceType](doc//SourceType.md)
-2
View File
@@ -221,8 +221,6 @@ part 'model/shared_link_create_dto.dart';
part 'model/shared_link_edit_dto.dart'; part 'model/shared_link_edit_dto.dart';
part 'model/shared_link_response_dto.dart'; part 'model/shared_link_response_dto.dart';
part 'model/shared_link_type.dart'; part 'model/shared_link_type.dart';
part 'model/shared_links_response.dart';
part 'model/shared_links_update.dart';
part 'model/sign_up_dto.dart'; part 'model/sign_up_dto.dart';
part 'model/smart_search_dto.dart'; part 'model/smart_search_dto.dart';
part 'model/source_type.dart'; part 'model/source_type.dart';
+3 -13
View File
@@ -127,10 +127,7 @@ class SharedLinksApi {
} }
/// Performs an HTTP 'GET /shared-links' operation and returns the [Response]. /// Performs an HTTP 'GET /shared-links' operation and returns the [Response].
/// Parameters: Future<Response> getAllSharedLinksWithHttpInfo() async {
///
/// * [String] albumId:
Future<Response> getAllSharedLinksWithHttpInfo({ String? albumId, }) async {
// ignore: prefer_const_declarations // ignore: prefer_const_declarations
final path = r'/shared-links'; final path = r'/shared-links';
@@ -141,10 +138,6 @@ class SharedLinksApi {
final headerParams = <String, String>{}; final headerParams = <String, String>{};
final formParams = <String, String>{}; final formParams = <String, String>{};
if (albumId != null) {
queryParams.addAll(_queryParams('', 'albumId', albumId));
}
const contentTypes = <String>[]; const contentTypes = <String>[];
@@ -159,11 +152,8 @@ class SharedLinksApi {
); );
} }
/// Parameters: Future<List<SharedLinkResponseDto>?> getAllSharedLinks() async {
/// final response = await getAllSharedLinksWithHttpInfo();
/// * [String] albumId:
Future<List<SharedLinkResponseDto>?> getAllSharedLinks({ String? albumId, }) async {
final response = await getAllSharedLinksWithHttpInfo( albumId: albumId, );
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response)); throw ApiException(response.statusCode, await _decodeBodyBytes(response));
} }
-4
View File
@@ -496,10 +496,6 @@ class ApiClient {
return SharedLinkResponseDto.fromJson(value); return SharedLinkResponseDto.fromJson(value);
case 'SharedLinkType': case 'SharedLinkType':
return SharedLinkTypeTypeTransformer().decode(value); return SharedLinkTypeTypeTransformer().decode(value);
case 'SharedLinksResponse':
return SharedLinksResponse.fromJson(value);
case 'SharedLinksUpdate':
return SharedLinksUpdate.fromJson(value);
case 'SignUpDto': case 'SignUpDto':
return SignUpDto.fromJson(value); return SignUpDto.fromJson(value);
case 'SmartSearchDto': case 'SmartSearchDto':
+1 -12
View File
@@ -14,7 +14,6 @@ class PeopleUpdateItem {
/// Returns a new [PeopleUpdateItem] instance. /// Returns a new [PeopleUpdateItem] instance.
PeopleUpdateItem({ PeopleUpdateItem({
this.birthDate, this.birthDate,
this.color,
this.featureFaceAssetId, this.featureFaceAssetId,
required this.id, required this.id,
this.isFavorite, this.isFavorite,
@@ -25,8 +24,6 @@ class PeopleUpdateItem {
/// Person date of birth. Note: the mobile app cannot currently set the birth date to null. /// Person date of birth. Note: the mobile app cannot currently set the birth date to null.
DateTime? birthDate; DateTime? birthDate;
String? color;
/// Asset is used to get the feature face thumbnail. /// Asset is used to get the feature face thumbnail.
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
@@ -68,7 +65,6 @@ class PeopleUpdateItem {
@override @override
bool operator ==(Object other) => identical(this, other) || other is PeopleUpdateItem && bool operator ==(Object other) => identical(this, other) || other is PeopleUpdateItem &&
other.birthDate == birthDate && other.birthDate == birthDate &&
other.color == color &&
other.featureFaceAssetId == featureFaceAssetId && other.featureFaceAssetId == featureFaceAssetId &&
other.id == id && other.id == id &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
@@ -79,7 +75,6 @@ class PeopleUpdateItem {
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(birthDate == null ? 0 : birthDate!.hashCode) + (birthDate == null ? 0 : birthDate!.hashCode) +
(color == null ? 0 : color!.hashCode) +
(featureFaceAssetId == null ? 0 : featureFaceAssetId!.hashCode) + (featureFaceAssetId == null ? 0 : featureFaceAssetId!.hashCode) +
(id.hashCode) + (id.hashCode) +
(isFavorite == null ? 0 : isFavorite!.hashCode) + (isFavorite == null ? 0 : isFavorite!.hashCode) +
@@ -87,7 +82,7 @@ class PeopleUpdateItem {
(name == null ? 0 : name!.hashCode); (name == null ? 0 : name!.hashCode);
@override @override
String toString() => 'PeopleUpdateItem[birthDate=$birthDate, color=$color, featureFaceAssetId=$featureFaceAssetId, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]'; String toString() => 'PeopleUpdateItem[birthDate=$birthDate, featureFaceAssetId=$featureFaceAssetId, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -96,11 +91,6 @@ class PeopleUpdateItem {
} else { } else {
// json[r'birthDate'] = null; // json[r'birthDate'] = null;
} }
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
}
if (this.featureFaceAssetId != null) { if (this.featureFaceAssetId != null) {
json[r'featureFaceAssetId'] = this.featureFaceAssetId; json[r'featureFaceAssetId'] = this.featureFaceAssetId;
} else { } else {
@@ -135,7 +125,6 @@ class PeopleUpdateItem {
return PeopleUpdateItem( return PeopleUpdateItem(
birthDate: mapDateTime(json, r'birthDate', r''), birthDate: mapDateTime(json, r'birthDate', r''),
color: mapValueOfType<String>(json, r'color'),
featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'), featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'),
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite'), isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
+1 -12
View File
@@ -14,7 +14,6 @@ class PersonCreateDto {
/// Returns a new [PersonCreateDto] instance. /// Returns a new [PersonCreateDto] instance.
PersonCreateDto({ PersonCreateDto({
this.birthDate, this.birthDate,
this.color,
this.isFavorite, this.isFavorite,
this.isHidden, this.isHidden,
this.name, this.name,
@@ -23,8 +22,6 @@ class PersonCreateDto {
/// Person date of birth. Note: the mobile app cannot currently set the birth date to null. /// Person date of birth. Note: the mobile app cannot currently set the birth date to null.
DateTime? birthDate; DateTime? birthDate;
String? color;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated /// does not include a default value (using the "default:" property), however, the generated
@@ -54,7 +51,6 @@ class PersonCreateDto {
@override @override
bool operator ==(Object other) => identical(this, other) || other is PersonCreateDto && bool operator ==(Object other) => identical(this, other) || other is PersonCreateDto &&
other.birthDate == birthDate && other.birthDate == birthDate &&
other.color == color &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
other.isHidden == isHidden && other.isHidden == isHidden &&
other.name == name; other.name == name;
@@ -63,13 +59,12 @@ class PersonCreateDto {
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(birthDate == null ? 0 : birthDate!.hashCode) + (birthDate == null ? 0 : birthDate!.hashCode) +
(color == null ? 0 : color!.hashCode) +
(isFavorite == null ? 0 : isFavorite!.hashCode) + (isFavorite == null ? 0 : isFavorite!.hashCode) +
(isHidden == null ? 0 : isHidden!.hashCode) + (isHidden == null ? 0 : isHidden!.hashCode) +
(name == null ? 0 : name!.hashCode); (name == null ? 0 : name!.hashCode);
@override @override
String toString() => 'PersonCreateDto[birthDate=$birthDate, color=$color, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]'; String toString() => 'PersonCreateDto[birthDate=$birthDate, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -78,11 +73,6 @@ class PersonCreateDto {
} else { } else {
// json[r'birthDate'] = null; // json[r'birthDate'] = null;
} }
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
}
if (this.isFavorite != null) { if (this.isFavorite != null) {
json[r'isFavorite'] = this.isFavorite; json[r'isFavorite'] = this.isFavorite;
} else { } else {
@@ -111,7 +101,6 @@ class PersonCreateDto {
return PersonCreateDto( return PersonCreateDto(
birthDate: mapDateTime(json, r'birthDate', r''), birthDate: mapDateTime(json, r'birthDate', r''),
color: mapValueOfType<String>(json, r'color'),
isFavorite: mapValueOfType<bool>(json, r'isFavorite'), isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
isHidden: mapValueOfType<bool>(json, r'isHidden'), isHidden: mapValueOfType<bool>(json, r'isHidden'),
name: mapValueOfType<String>(json, r'name'), name: mapValueOfType<String>(json, r'name'),
+1 -19
View File
@@ -14,7 +14,6 @@ class PersonResponseDto {
/// Returns a new [PersonResponseDto] instance. /// Returns a new [PersonResponseDto] instance.
PersonResponseDto({ PersonResponseDto({
required this.birthDate, required this.birthDate,
this.color,
required this.id, required this.id,
this.isFavorite, this.isFavorite,
required this.isHidden, required this.isHidden,
@@ -25,15 +24,6 @@ class PersonResponseDto {
DateTime? birthDate; DateTime? birthDate;
/// This property was added in v1.126.0
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? color;
String id; String id;
/// This property was added in v1.126.0 /// This property was added in v1.126.0
@@ -63,7 +53,6 @@ class PersonResponseDto {
@override @override
bool operator ==(Object other) => identical(this, other) || other is PersonResponseDto && bool operator ==(Object other) => identical(this, other) || other is PersonResponseDto &&
other.birthDate == birthDate && other.birthDate == birthDate &&
other.color == color &&
other.id == id && other.id == id &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
other.isHidden == isHidden && other.isHidden == isHidden &&
@@ -75,7 +64,6 @@ class PersonResponseDto {
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(birthDate == null ? 0 : birthDate!.hashCode) + (birthDate == null ? 0 : birthDate!.hashCode) +
(color == null ? 0 : color!.hashCode) +
(id.hashCode) + (id.hashCode) +
(isFavorite == null ? 0 : isFavorite!.hashCode) + (isFavorite == null ? 0 : isFavorite!.hashCode) +
(isHidden.hashCode) + (isHidden.hashCode) +
@@ -84,7 +72,7 @@ class PersonResponseDto {
(updatedAt == null ? 0 : updatedAt!.hashCode); (updatedAt == null ? 0 : updatedAt!.hashCode);
@override @override
String toString() => 'PersonResponseDto[birthDate=$birthDate, color=$color, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name, thumbnailPath=$thumbnailPath, updatedAt=$updatedAt]'; String toString() => 'PersonResponseDto[birthDate=$birthDate, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name, thumbnailPath=$thumbnailPath, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -92,11 +80,6 @@ class PersonResponseDto {
json[r'birthDate'] = _dateFormatter.format(this.birthDate!.toUtc()); json[r'birthDate'] = _dateFormatter.format(this.birthDate!.toUtc());
} else { } else {
// json[r'birthDate'] = null; // json[r'birthDate'] = null;
}
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
} }
json[r'id'] = this.id; json[r'id'] = this.id;
if (this.isFavorite != null) { if (this.isFavorite != null) {
@@ -125,7 +108,6 @@ class PersonResponseDto {
return PersonResponseDto( return PersonResponseDto(
birthDate: mapDateTime(json, r'birthDate', r''), birthDate: mapDateTime(json, r'birthDate', r''),
color: mapValueOfType<String>(json, r'color'),
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite'), isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
isHidden: mapValueOfType<bool>(json, r'isHidden')!, isHidden: mapValueOfType<bool>(json, r'isHidden')!,
+1 -12
View File
@@ -14,7 +14,6 @@ class PersonUpdateDto {
/// Returns a new [PersonUpdateDto] instance. /// Returns a new [PersonUpdateDto] instance.
PersonUpdateDto({ PersonUpdateDto({
this.birthDate, this.birthDate,
this.color,
this.featureFaceAssetId, this.featureFaceAssetId,
this.isFavorite, this.isFavorite,
this.isHidden, this.isHidden,
@@ -24,8 +23,6 @@ class PersonUpdateDto {
/// Person date of birth. Note: the mobile app cannot currently set the birth date to null. /// Person date of birth. Note: the mobile app cannot currently set the birth date to null.
DateTime? birthDate; DateTime? birthDate;
String? color;
/// Asset is used to get the feature face thumbnail. /// Asset is used to get the feature face thumbnail.
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
@@ -64,7 +61,6 @@ class PersonUpdateDto {
@override @override
bool operator ==(Object other) => identical(this, other) || other is PersonUpdateDto && bool operator ==(Object other) => identical(this, other) || other is PersonUpdateDto &&
other.birthDate == birthDate && other.birthDate == birthDate &&
other.color == color &&
other.featureFaceAssetId == featureFaceAssetId && other.featureFaceAssetId == featureFaceAssetId &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
other.isHidden == isHidden && other.isHidden == isHidden &&
@@ -74,14 +70,13 @@ class PersonUpdateDto {
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(birthDate == null ? 0 : birthDate!.hashCode) + (birthDate == null ? 0 : birthDate!.hashCode) +
(color == null ? 0 : color!.hashCode) +
(featureFaceAssetId == null ? 0 : featureFaceAssetId!.hashCode) + (featureFaceAssetId == null ? 0 : featureFaceAssetId!.hashCode) +
(isFavorite == null ? 0 : isFavorite!.hashCode) + (isFavorite == null ? 0 : isFavorite!.hashCode) +
(isHidden == null ? 0 : isHidden!.hashCode) + (isHidden == null ? 0 : isHidden!.hashCode) +
(name == null ? 0 : name!.hashCode); (name == null ? 0 : name!.hashCode);
@override @override
String toString() => 'PersonUpdateDto[birthDate=$birthDate, color=$color, featureFaceAssetId=$featureFaceAssetId, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]'; String toString() => 'PersonUpdateDto[birthDate=$birthDate, featureFaceAssetId=$featureFaceAssetId, isFavorite=$isFavorite, isHidden=$isHidden, name=$name]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -90,11 +85,6 @@ class PersonUpdateDto {
} else { } else {
// json[r'birthDate'] = null; // json[r'birthDate'] = null;
} }
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
}
if (this.featureFaceAssetId != null) { if (this.featureFaceAssetId != null) {
json[r'featureFaceAssetId'] = this.featureFaceAssetId; json[r'featureFaceAssetId'] = this.featureFaceAssetId;
} else { } else {
@@ -128,7 +118,6 @@ class PersonUpdateDto {
return PersonUpdateDto( return PersonUpdateDto(
birthDate: mapDateTime(json, r'birthDate', r''), birthDate: mapDateTime(json, r'birthDate', r''),
color: mapValueOfType<String>(json, r'color'),
featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'), featureFaceAssetId: mapValueOfType<String>(json, r'featureFaceAssetId'),
isFavorite: mapValueOfType<bool>(json, r'isFavorite'), isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
isHidden: mapValueOfType<bool>(json, r'isHidden'), isHidden: mapValueOfType<bool>(json, r'isHidden'),
+1 -19
View File
@@ -14,7 +14,6 @@ class PersonWithFacesResponseDto {
/// Returns a new [PersonWithFacesResponseDto] instance. /// Returns a new [PersonWithFacesResponseDto] instance.
PersonWithFacesResponseDto({ PersonWithFacesResponseDto({
required this.birthDate, required this.birthDate,
this.color,
this.faces = const [], this.faces = const [],
required this.id, required this.id,
this.isFavorite, this.isFavorite,
@@ -26,15 +25,6 @@ class PersonWithFacesResponseDto {
DateTime? birthDate; DateTime? birthDate;
/// This property was added in v1.126.0
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? color;
List<AssetFaceWithoutPersonResponseDto> faces; List<AssetFaceWithoutPersonResponseDto> faces;
String id; String id;
@@ -66,7 +56,6 @@ class PersonWithFacesResponseDto {
@override @override
bool operator ==(Object other) => identical(this, other) || other is PersonWithFacesResponseDto && bool operator ==(Object other) => identical(this, other) || other is PersonWithFacesResponseDto &&
other.birthDate == birthDate && other.birthDate == birthDate &&
other.color == color &&
_deepEquality.equals(other.faces, faces) && _deepEquality.equals(other.faces, faces) &&
other.id == id && other.id == id &&
other.isFavorite == isFavorite && other.isFavorite == isFavorite &&
@@ -79,7 +68,6 @@ class PersonWithFacesResponseDto {
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(birthDate == null ? 0 : birthDate!.hashCode) + (birthDate == null ? 0 : birthDate!.hashCode) +
(color == null ? 0 : color!.hashCode) +
(faces.hashCode) + (faces.hashCode) +
(id.hashCode) + (id.hashCode) +
(isFavorite == null ? 0 : isFavorite!.hashCode) + (isFavorite == null ? 0 : isFavorite!.hashCode) +
@@ -89,7 +77,7 @@ class PersonWithFacesResponseDto {
(updatedAt == null ? 0 : updatedAt!.hashCode); (updatedAt == null ? 0 : updatedAt!.hashCode);
@override @override
String toString() => 'PersonWithFacesResponseDto[birthDate=$birthDate, color=$color, faces=$faces, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name, thumbnailPath=$thumbnailPath, updatedAt=$updatedAt]'; String toString() => 'PersonWithFacesResponseDto[birthDate=$birthDate, faces=$faces, id=$id, isFavorite=$isFavorite, isHidden=$isHidden, name=$name, thumbnailPath=$thumbnailPath, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -97,11 +85,6 @@ class PersonWithFacesResponseDto {
json[r'birthDate'] = _dateFormatter.format(this.birthDate!.toUtc()); json[r'birthDate'] = _dateFormatter.format(this.birthDate!.toUtc());
} else { } else {
// json[r'birthDate'] = null; // json[r'birthDate'] = null;
}
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
} }
json[r'faces'] = this.faces; json[r'faces'] = this.faces;
json[r'id'] = this.id; json[r'id'] = this.id;
@@ -131,7 +114,6 @@ class PersonWithFacesResponseDto {
return PersonWithFacesResponseDto( return PersonWithFacesResponseDto(
birthDate: mapDateTime(json, r'birthDate', r''), birthDate: mapDateTime(json, r'birthDate', r''),
color: mapValueOfType<String>(json, r'color'),
faces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'faces']), faces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'faces']),
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
isFavorite: mapValueOfType<bool>(json, r'isFavorite'), isFavorite: mapValueOfType<bool>(json, r'isFavorite'),
-107
View File
@@ -1,107 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SharedLinksResponse {
/// Returns a new [SharedLinksResponse] instance.
SharedLinksResponse({
this.enabled = true,
this.sidebarWeb = false,
});
bool enabled;
bool sidebarWeb;
@override
bool operator ==(Object other) => identical(this, other) || other is SharedLinksResponse &&
other.enabled == enabled &&
other.sidebarWeb == sidebarWeb;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(enabled.hashCode) +
(sidebarWeb.hashCode);
@override
String toString() => 'SharedLinksResponse[enabled=$enabled, sidebarWeb=$sidebarWeb]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'enabled'] = this.enabled;
json[r'sidebarWeb'] = this.sidebarWeb;
return json;
}
/// Returns a new [SharedLinksResponse] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SharedLinksResponse? fromJson(dynamic value) {
upgradeDto(value, "SharedLinksResponse");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SharedLinksResponse(
enabled: mapValueOfType<bool>(json, r'enabled')!,
sidebarWeb: mapValueOfType<bool>(json, r'sidebarWeb')!,
);
}
return null;
}
static List<SharedLinksResponse> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SharedLinksResponse>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SharedLinksResponse.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SharedLinksResponse> mapFromJson(dynamic json) {
final map = <String, SharedLinksResponse>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SharedLinksResponse.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SharedLinksResponse-objects as value to a dart map
static Map<String, List<SharedLinksResponse>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SharedLinksResponse>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SharedLinksResponse.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'enabled',
'sidebarWeb',
};
}
-125
View File
@@ -1,125 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SharedLinksUpdate {
/// Returns a new [SharedLinksUpdate] instance.
SharedLinksUpdate({
this.enabled,
this.sidebarWeb,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? enabled;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? sidebarWeb;
@override
bool operator ==(Object other) => identical(this, other) || other is SharedLinksUpdate &&
other.enabled == enabled &&
other.sidebarWeb == sidebarWeb;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(enabled == null ? 0 : enabled!.hashCode) +
(sidebarWeb == null ? 0 : sidebarWeb!.hashCode);
@override
String toString() => 'SharedLinksUpdate[enabled=$enabled, sidebarWeb=$sidebarWeb]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.enabled != null) {
json[r'enabled'] = this.enabled;
} else {
// json[r'enabled'] = null;
}
if (this.sidebarWeb != null) {
json[r'sidebarWeb'] = this.sidebarWeb;
} else {
// json[r'sidebarWeb'] = null;
}
return json;
}
/// Returns a new [SharedLinksUpdate] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SharedLinksUpdate? fromJson(dynamic value) {
upgradeDto(value, "SharedLinksUpdate");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SharedLinksUpdate(
enabled: mapValueOfType<bool>(json, r'enabled'),
sidebarWeb: mapValueOfType<bool>(json, r'sidebarWeb'),
);
}
return null;
}
static List<SharedLinksUpdate> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SharedLinksUpdate>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SharedLinksUpdate.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SharedLinksUpdate> mapFromJson(dynamic json) {
final map = <String, SharedLinksUpdate>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SharedLinksUpdate.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SharedLinksUpdate-objects as value to a dart map
static Map<String, List<SharedLinksUpdate>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SharedLinksUpdate>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SharedLinksUpdate.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}
+1 -9
View File
@@ -21,7 +21,6 @@ class UserPreferencesResponseDto {
required this.people, required this.people,
required this.purchase, required this.purchase,
required this.ratings, required this.ratings,
required this.sharedLinks,
required this.tags, required this.tags,
}); });
@@ -41,8 +40,6 @@ class UserPreferencesResponseDto {
RatingsResponse ratings; RatingsResponse ratings;
SharedLinksResponse sharedLinks;
TagsResponse tags; TagsResponse tags;
@override @override
@@ -55,7 +52,6 @@ class UserPreferencesResponseDto {
other.people == people && other.people == people &&
other.purchase == purchase && other.purchase == purchase &&
other.ratings == ratings && other.ratings == ratings &&
other.sharedLinks == sharedLinks &&
other.tags == tags; other.tags == tags;
@override @override
@@ -69,11 +65,10 @@ class UserPreferencesResponseDto {
(people.hashCode) + (people.hashCode) +
(purchase.hashCode) + (purchase.hashCode) +
(ratings.hashCode) + (ratings.hashCode) +
(sharedLinks.hashCode) +
(tags.hashCode); (tags.hashCode);
@override @override
String toString() => 'UserPreferencesResponseDto[avatar=$avatar, download=$download, emailNotifications=$emailNotifications, folders=$folders, memories=$memories, people=$people, purchase=$purchase, ratings=$ratings, sharedLinks=$sharedLinks, tags=$tags]'; String toString() => 'UserPreferencesResponseDto[avatar=$avatar, download=$download, emailNotifications=$emailNotifications, folders=$folders, memories=$memories, people=$people, purchase=$purchase, ratings=$ratings, tags=$tags]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -85,7 +80,6 @@ class UserPreferencesResponseDto {
json[r'people'] = this.people; json[r'people'] = this.people;
json[r'purchase'] = this.purchase; json[r'purchase'] = this.purchase;
json[r'ratings'] = this.ratings; json[r'ratings'] = this.ratings;
json[r'sharedLinks'] = this.sharedLinks;
json[r'tags'] = this.tags; json[r'tags'] = this.tags;
return json; return json;
} }
@@ -107,7 +101,6 @@ class UserPreferencesResponseDto {
people: PeopleResponse.fromJson(json[r'people'])!, people: PeopleResponse.fromJson(json[r'people'])!,
purchase: PurchaseResponse.fromJson(json[r'purchase'])!, purchase: PurchaseResponse.fromJson(json[r'purchase'])!,
ratings: RatingsResponse.fromJson(json[r'ratings'])!, ratings: RatingsResponse.fromJson(json[r'ratings'])!,
sharedLinks: SharedLinksResponse.fromJson(json[r'sharedLinks'])!,
tags: TagsResponse.fromJson(json[r'tags'])!, tags: TagsResponse.fromJson(json[r'tags'])!,
); );
} }
@@ -164,7 +157,6 @@ class UserPreferencesResponseDto {
'people', 'people',
'purchase', 'purchase',
'ratings', 'ratings',
'sharedLinks',
'tags', 'tags',
}; };
} }
+1 -18
View File
@@ -21,7 +21,6 @@ class UserPreferencesUpdateDto {
this.people, this.people,
this.purchase, this.purchase,
this.ratings, this.ratings,
this.sharedLinks,
this.tags, this.tags,
}); });
@@ -89,14 +88,6 @@ class UserPreferencesUpdateDto {
/// ///
RatingsUpdate? ratings; RatingsUpdate? ratings;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
SharedLinksUpdate? sharedLinks;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated /// does not include a default value (using the "default:" property), however, the generated
@@ -115,7 +106,6 @@ class UserPreferencesUpdateDto {
other.people == people && other.people == people &&
other.purchase == purchase && other.purchase == purchase &&
other.ratings == ratings && other.ratings == ratings &&
other.sharedLinks == sharedLinks &&
other.tags == tags; other.tags == tags;
@override @override
@@ -129,11 +119,10 @@ class UserPreferencesUpdateDto {
(people == null ? 0 : people!.hashCode) + (people == null ? 0 : people!.hashCode) +
(purchase == null ? 0 : purchase!.hashCode) + (purchase == null ? 0 : purchase!.hashCode) +
(ratings == null ? 0 : ratings!.hashCode) + (ratings == null ? 0 : ratings!.hashCode) +
(sharedLinks == null ? 0 : sharedLinks!.hashCode) +
(tags == null ? 0 : tags!.hashCode); (tags == null ? 0 : tags!.hashCode);
@override @override
String toString() => 'UserPreferencesUpdateDto[avatar=$avatar, download=$download, emailNotifications=$emailNotifications, folders=$folders, memories=$memories, people=$people, purchase=$purchase, ratings=$ratings, sharedLinks=$sharedLinks, tags=$tags]'; String toString() => 'UserPreferencesUpdateDto[avatar=$avatar, download=$download, emailNotifications=$emailNotifications, folders=$folders, memories=$memories, people=$people, purchase=$purchase, ratings=$ratings, tags=$tags]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@@ -177,11 +166,6 @@ class UserPreferencesUpdateDto {
} else { } else {
// json[r'ratings'] = null; // json[r'ratings'] = null;
} }
if (this.sharedLinks != null) {
json[r'sharedLinks'] = this.sharedLinks;
} else {
// json[r'sharedLinks'] = null;
}
if (this.tags != null) { if (this.tags != null) {
json[r'tags'] = this.tags; json[r'tags'] = this.tags;
} else { } else {
@@ -207,7 +191,6 @@ class UserPreferencesUpdateDto {
people: PeopleUpdate.fromJson(json[r'people']), people: PeopleUpdate.fromJson(json[r'people']),
purchase: PurchaseUpdate.fromJson(json[r'purchase']), purchase: PurchaseUpdate.fromJson(json[r'purchase']),
ratings: RatingsUpdate.fromJson(json[r'ratings']), ratings: RatingsUpdate.fromJson(json[r'ratings']),
sharedLinks: SharedLinksUpdate.fromJson(json[r'sharedLinks']),
tags: TagsUpdate.fromJson(json[r'tags']), tags: TagsUpdate.fromJson(json[r'tags']),
); );
} }
+1 -1
View File
@@ -2,7 +2,7 @@ name: immich_mobile
description: Immich - selfhosted backup media file on mobile phone description: Immich - selfhosted backup media file on mobile phone
publish_to: 'none' publish_to: 'none'
version: 1.126.1+184 version: 1.125.7+182
environment: environment:
sdk: '>=3.3.0 <4.0.0' sdk: '>=3.3.0 <4.0.0'
+3 -67
View File
@@ -5230,17 +5230,7 @@
"/shared-links": { "/shared-links": {
"get": { "get": {
"operationId": "getAllSharedLinks", "operationId": "getAllSharedLinks",
"parameters": [ "parameters": [],
{
"name": "albumId",
"required": false,
"in": "query",
"schema": {
"format": "uuid",
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"content": { "content": {
@@ -7468,7 +7458,7 @@
"info": { "info": {
"title": "Immich", "title": "Immich",
"description": "Immich API", "description": "Immich API",
"version": "1.126.1", "version": "1.125.7",
"contact": {} "contact": {}
}, },
"tags": [], "tags": [],
@@ -10296,10 +10286,6 @@
"nullable": true, "nullable": true,
"type": "string" "type": "string"
}, },
"color": {
"nullable": true,
"type": "string"
},
"featureFaceAssetId": { "featureFaceAssetId": {
"description": "Asset is used to get the feature face thumbnail.", "description": "Asset is used to get the feature face thumbnail.",
"type": "string" "type": "string"
@@ -10416,10 +10402,6 @@
"nullable": true, "nullable": true,
"type": "string" "type": "string"
}, },
"color": {
"nullable": true,
"type": "string"
},
"isFavorite": { "isFavorite": {
"type": "boolean" "type": "boolean"
}, },
@@ -10441,10 +10423,6 @@
"nullable": true, "nullable": true,
"type": "string" "type": "string"
}, },
"color": {
"description": "This property was added in v1.126.0",
"type": "string"
},
"id": { "id": {
"type": "string" "type": "string"
}, },
@@ -10495,10 +10473,6 @@
"nullable": true, "nullable": true,
"type": "string" "type": "string"
}, },
"color": {
"nullable": true,
"type": "string"
},
"featureFaceAssetId": { "featureFaceAssetId": {
"description": "Asset is used to get the feature face thumbnail.", "description": "Asset is used to get the feature face thumbnail.",
"type": "string" "type": "string"
@@ -10524,10 +10498,6 @@
"nullable": true, "nullable": true,
"type": "string" "type": "string"
}, },
"color": {
"description": "This property was added in v1.126.0",
"type": "string"
},
"faces": { "faces": {
"items": { "items": {
"$ref": "#/components/schemas/AssetFaceWithoutPersonResponseDto" "$ref": "#/components/schemas/AssetFaceWithoutPersonResponseDto"
@@ -11524,34 +11494,6 @@
], ],
"type": "string" "type": "string"
}, },
"SharedLinksResponse": {
"properties": {
"enabled": {
"default": true,
"type": "boolean"
},
"sidebarWeb": {
"default": false,
"type": "boolean"
}
},
"required": [
"enabled",
"sidebarWeb"
],
"type": "object"
},
"SharedLinksUpdate": {
"properties": {
"enabled": {
"type": "boolean"
},
"sidebarWeb": {
"type": "boolean"
}
},
"type": "object"
},
"SignUpDto": { "SignUpDto": {
"properties": { "properties": {
"email": { "email": {
@@ -12669,6 +12611,7 @@
"properties": { "properties": {
"color": { "color": {
"nullable": true, "nullable": true,
"pattern": "^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$",
"type": "string" "type": "string"
} }
}, },
@@ -13198,9 +13141,6 @@
"ratings": { "ratings": {
"$ref": "#/components/schemas/RatingsResponse" "$ref": "#/components/schemas/RatingsResponse"
}, },
"sharedLinks": {
"$ref": "#/components/schemas/SharedLinksResponse"
},
"tags": { "tags": {
"$ref": "#/components/schemas/TagsResponse" "$ref": "#/components/schemas/TagsResponse"
} }
@@ -13214,7 +13154,6 @@
"people", "people",
"purchase", "purchase",
"ratings", "ratings",
"sharedLinks",
"tags" "tags"
], ],
"type": "object" "type": "object"
@@ -13245,9 +13184,6 @@
"ratings": { "ratings": {
"$ref": "#/components/schemas/RatingsUpdate" "$ref": "#/components/schemas/RatingsUpdate"
}, },
"sharedLinks": {
"$ref": "#/components/schemas/SharedLinksUpdate"
},
"tags": { "tags": {
"$ref": "#/components/schemas/TagsUpdate" "$ref": "#/components/schemas/TagsUpdate"
} }
+6 -6
View File
@@ -1,18 +1,18 @@
{ {
"name": "@immich/sdk", "name": "@immich/sdk",
"version": "1.126.1", "version": "1.125.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@immich/sdk", "name": "@immich/sdk",
"version": "1.126.1", "version": "1.125.7",
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
"@oazapfts/runtime": "^1.0.2" "@oazapfts/runtime": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }
}, },
@@ -22,9 +22,9 @@
"integrity": "sha512-8tKiYffhwTGHSHYGnZ3oneLGCjX0po/XAXQ5Ng9fqKkvIdl/xz8+Vh8i+6xjzZqvZ2pLVpUcuSfnvNI/x67L0g==" "integrity": "sha512-8tKiYffhwTGHSHYGnZ3oneLGCjX0po/XAXQ5Ng9fqKkvIdl/xz8+Vh8i+6xjzZqvZ2pLVpUcuSfnvNI/x67L0g=="
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.13.1", "version": "22.10.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.9.tgz",
"integrity": "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==", "integrity": "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@immich/sdk", "name": "@immich/sdk",
"version": "1.126.1", "version": "1.125.7",
"description": "Auto-generated TypeScript SDK for the Immich API", "description": "Auto-generated TypeScript SDK for the Immich API",
"type": "module", "type": "module",
"main": "./build/index.js", "main": "./build/index.js",
@@ -19,7 +19,7 @@
"@oazapfts/runtime": "^1.0.2" "@oazapfts/runtime": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"typescript": "^5.3.3" "typescript": "^5.3.3"
}, },
"repository": { "repository": {
+3 -24
View File
@@ -1,6 +1,6 @@
/** /**
* Immich * Immich
* 1.126.1 * 1.125.7
* DO NOT MODIFY - This file has been generated using oazapfts. * DO NOT MODIFY - This file has been generated using oazapfts.
* See https://www.npmjs.com/package/oazapfts * See https://www.npmjs.com/package/oazapfts
*/ */
@@ -113,10 +113,6 @@ export type PurchaseResponse = {
export type RatingsResponse = { export type RatingsResponse = {
enabled: boolean; enabled: boolean;
}; };
export type SharedLinksResponse = {
enabled: boolean;
sidebarWeb: boolean;
};
export type TagsResponse = { export type TagsResponse = {
enabled: boolean; enabled: boolean;
sidebarWeb: boolean; sidebarWeb: boolean;
@@ -130,7 +126,6 @@ export type UserPreferencesResponseDto = {
people: PeopleResponse; people: PeopleResponse;
purchase: PurchaseResponse; purchase: PurchaseResponse;
ratings: RatingsResponse; ratings: RatingsResponse;
sharedLinks: SharedLinksResponse;
tags: TagsResponse; tags: TagsResponse;
}; };
export type AvatarUpdate = { export type AvatarUpdate = {
@@ -163,10 +158,6 @@ export type PurchaseUpdate = {
export type RatingsUpdate = { export type RatingsUpdate = {
enabled?: boolean; enabled?: boolean;
}; };
export type SharedLinksUpdate = {
enabled?: boolean;
sidebarWeb?: boolean;
};
export type TagsUpdate = { export type TagsUpdate = {
enabled?: boolean; enabled?: boolean;
sidebarWeb?: boolean; sidebarWeb?: boolean;
@@ -180,7 +171,6 @@ export type UserPreferencesUpdateDto = {
people?: PeopleUpdate; people?: PeopleUpdate;
purchase?: PurchaseUpdate; purchase?: PurchaseUpdate;
ratings?: RatingsUpdate; ratings?: RatingsUpdate;
sharedLinks?: SharedLinksUpdate;
tags?: TagsUpdate; tags?: TagsUpdate;
}; };
export type AlbumUserResponseDto = { export type AlbumUserResponseDto = {
@@ -223,8 +213,6 @@ export type AssetFaceWithoutPersonResponseDto = {
}; };
export type PersonWithFacesResponseDto = { export type PersonWithFacesResponseDto = {
birthDate: string | null; birthDate: string | null;
/** This property was added in v1.126.0 */
color?: string;
faces: AssetFaceWithoutPersonResponseDto[]; faces: AssetFaceWithoutPersonResponseDto[];
id: string; id: string;
/** This property was added in v1.126.0 */ /** This property was added in v1.126.0 */
@@ -505,8 +493,6 @@ export type DuplicateResponseDto = {
}; };
export type PersonResponseDto = { export type PersonResponseDto = {
birthDate: string | null; birthDate: string | null;
/** This property was added in v1.126.0 */
color?: string;
id: string; id: string;
/** This property was added in v1.126.0 */ /** This property was added in v1.126.0 */
isFavorite?: boolean; isFavorite?: boolean;
@@ -707,7 +693,6 @@ export type PersonCreateDto = {
/** Person date of birth. /** Person date of birth.
Note: the mobile app cannot currently set the birth date to null. */ Note: the mobile app cannot currently set the birth date to null. */
birthDate?: string | null; birthDate?: string | null;
color?: string | null;
isFavorite?: boolean; isFavorite?: boolean;
/** Person visibility */ /** Person visibility */
isHidden?: boolean; isHidden?: boolean;
@@ -718,7 +703,6 @@ export type PeopleUpdateItem = {
/** Person date of birth. /** Person date of birth.
Note: the mobile app cannot currently set the birth date to null. */ Note: the mobile app cannot currently set the birth date to null. */
birthDate?: string | null; birthDate?: string | null;
color?: string | null;
/** Asset is used to get the feature face thumbnail. */ /** Asset is used to get the feature face thumbnail. */
featureFaceAssetId?: string; featureFaceAssetId?: string;
/** Person id. */ /** Person id. */
@@ -736,7 +720,6 @@ export type PersonUpdateDto = {
/** Person date of birth. /** Person date of birth.
Note: the mobile app cannot currently set the birth date to null. */ Note: the mobile app cannot currently set the birth date to null. */
birthDate?: string | null; birthDate?: string | null;
color?: string | null;
/** Asset is used to get the feature face thumbnail. */ /** Asset is used to get the feature face thumbnail. */
featureFaceAssetId?: string; featureFaceAssetId?: string;
isFavorite?: boolean; isFavorite?: boolean;
@@ -2762,15 +2745,11 @@ export function deleteSession({ id }: {
method: "DELETE" method: "DELETE"
})); }));
} }
export function getAllSharedLinks({ albumId }: { export function getAllSharedLinks(opts?: Oazapfts.RequestOpts) {
albumId?: string;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{ return oazapfts.ok(oazapfts.fetchJson<{
status: 200; status: 200;
data: SharedLinkResponseDto[]; data: SharedLinkResponseDto[];
}>(`/shared-links${QS.query(QS.explode({ }>("/shared-links", {
albumId
}))}`, {
...opts ...opts
})); }));
} }
+2 -2
View File
@@ -1,5 +1,5 @@
# dev build # dev build
FROM ghcr.io/immich-app/base-server-dev:20250204@sha256:8b203f19f4d5cf4619b60ee5f50d6d4b5ea3745747f5e5170d1b7404ebeb0792 AS dev FROM ghcr.io/immich-app/base-server-dev:20250123@sha256:04eba5cd87d61bc3d20a3915b2302f04d08fbc329c55ee0cde103c502f59f412 AS dev
RUN apt-get install --no-install-recommends -yqq tini RUN apt-get install --no-install-recommends -yqq tini
WORKDIR /usr/src/app WORKDIR /usr/src/app
@@ -42,7 +42,7 @@ RUN npm run build
# prod build # prod build
FROM ghcr.io/immich-app/base-server-prod:20250204@sha256:2af3da713d5ab3ccca23b216b747557ea6016117e72deac101e35069ccaf9b5e FROM ghcr.io/immich-app/base-server-prod:20250123@sha256:591739983913f82672d8191258f3a1a24c123db0d619ff91fca8fef431ee1338
WORKDIR /usr/src/app WORKDIR /usr/src/app
ENV NODE_ENV=production \ ENV NODE_ENV=production \
+771 -2324
View File
File diff suppressed because it is too large Load Diff
+17 -21
View File
@@ -1,6 +1,6 @@
{ {
"name": "immich", "name": "immich",
"version": "1.126.1", "version": "1.125.7",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,
@@ -35,19 +35,16 @@
"email:dev": "email dev -p 3050 --dir src/emails" "email:dev": "email dev -p 3050 --dir src/emails"
}, },
"dependencies": { "dependencies": {
"@apollo/server": "^4.11.3", "@nestjs/bullmq": "^11.0.0",
"@nestjs/apollo": "^13.0.2", "@nestjs/common": "^10.2.2",
"@nestjs/bullmq": "^11.0.1", "@nestjs/core": "^10.2.2",
"@nestjs/common": "^11.0.4",
"@nestjs/core": "^11.0.4",
"@nestjs/event-emitter": "^3.0.0", "@nestjs/event-emitter": "^3.0.0",
"@nestjs/graphql": "^13.0.2", "@nestjs/platform-express": "^10.2.2",
"@nestjs/platform-express": "^11.0.4", "@nestjs/platform-socket.io": "^10.2.2",
"@nestjs/platform-socket.io": "^11.0.4",
"@nestjs/schedule": "^5.0.0", "@nestjs/schedule": "^5.0.0",
"@nestjs/swagger": "^11.0.2", "@nestjs/swagger": "^8.0.0",
"@nestjs/typeorm": "^11.0.0", "@nestjs/typeorm": "^10.0.0",
"@nestjs/websockets": "^11.0.4", "@nestjs/websockets": "^10.2.2",
"@opentelemetry/auto-instrumentations-node": "^0.55.0", "@opentelemetry/auto-instrumentations-node": "^0.55.0",
"@opentelemetry/context-async-hooks": "^1.24.0", "@opentelemetry/context-async-hooks": "^1.24.0",
"@opentelemetry/exporter-prometheus": "^0.57.0", "@opentelemetry/exporter-prometheus": "^0.57.0",
@@ -63,10 +60,9 @@
"class-validator": "^0.14.0", "class-validator": "^0.14.0",
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"exiftool-vendored": "^28.3.1", "exiftool-vendored": "^28.3.1",
"fast-glob": "^3.3.2", "fast-glob": "github:etnoy/fast-glob#built",
"fluent-ffmpeg": "^2.1.2", "fluent-ffmpeg": "^2.1.2",
"geo-tz": "^8.0.0", "geo-tz": "^8.0.0",
"graphql": "^16.10.0",
"handlebars": "^4.7.8", "handlebars": "^4.7.8",
"i18n-iso-countries": "^7.6.0", "i18n-iso-countries": "^7.6.0",
"ioredis": "^5.3.2", "ioredis": "^5.3.2",
@@ -76,9 +72,9 @@
"kysely-postgres-js": "^2.0.0", "kysely-postgres-js": "^2.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"luxon": "^3.4.2", "luxon": "^3.4.2",
"nest-commander": "^3.16.0", "nest-commander": "^3.11.1",
"nestjs-cls": "^5.0.0", "nestjs-cls": "^4.3.0",
"nestjs-kysely": "^1.1.0", "nestjs-kysely": "^1.0.0",
"nestjs-otel": "^6.0.0", "nestjs-otel": "^6.0.0",
"nodemailer": "^6.9.13", "nodemailer": "^6.9.13",
"openid-client": "^5.4.3", "openid-client": "^5.4.3",
@@ -101,9 +97,9 @@
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.1.0", "@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.8.0", "@eslint/js": "^9.8.0",
"@nestjs/cli": "^11.0.2", "@nestjs/cli": "^10.1.16",
"@nestjs/schematics": "^11.0.0", "@nestjs/schematics": "^10.0.2",
"@nestjs/testing": "^11.0.4", "@nestjs/testing": "^10.2.2",
"@swc/core": "^1.4.14", "@swc/core": "^1.4.14",
"@testcontainers/postgresql": "^10.2.1", "@testcontainers/postgresql": "^10.2.1",
"@types/archiver": "^6.0.0", "@types/archiver": "^6.0.0",
@@ -116,7 +112,7 @@
"@types/lodash": "^4.14.197", "@types/lodash": "^4.14.197",
"@types/mock-fs": "^4.13.1", "@types/mock-fs": "^4.13.1",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^22.13.1", "@types/node": "^22.10.9",
"@types/nodemailer": "^6.4.14", "@types/nodemailer": "^6.4.14",
"@types/picomatch": "^3.0.0", "@types/picomatch": "^3.0.0",
"@types/pngjs": "^6.0.5", "@types/pngjs": "^6.0.5",
+2 -25
View File
@@ -1,15 +1,12 @@
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { BullModule } from '@nestjs/bullmq'; import { BullModule } from '@nestjs/bullmq';
import { Inject, Module, OnModuleDestroy, OnModuleInit, ValidationPipe } from '@nestjs/common'; import { Inject, Module, OnModuleDestroy, OnModuleInit, ValidationPipe } from '@nestjs/common';
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE, ModuleRef } from '@nestjs/core'; import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE, ModuleRef } from '@nestjs/core';
import { GraphQLModule } from '@nestjs/graphql';
import { ScheduleModule, SchedulerRegistry } from '@nestjs/schedule'; import { ScheduleModule, SchedulerRegistry } from '@nestjs/schedule';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { PostgresJSDialect } from 'kysely-postgres-js'; import { PostgresJSDialect } from 'kysely-postgres-js';
import { ClsModule } from 'nestjs-cls'; import { ClsModule } from 'nestjs-cls';
import { KyselyModule } from 'nestjs-kysely'; import { KyselyModule } from 'nestjs-kysely';
import { OpenTelemetryModule } from 'nestjs-otel'; import { OpenTelemetryModule } from 'nestjs-otel';
import { join } from 'node:path';
import postgres from 'postgres'; import postgres from 'postgres';
import { commands } from 'src/commands'; import { commands } from 'src/commands';
import { IWorker } from 'src/constants'; import { IWorker } from 'src/constants';
@@ -27,7 +24,6 @@ import { providers, repositories } from 'src/repositories';
import { ConfigRepository } from 'src/repositories/config.repository'; import { ConfigRepository } from 'src/repositories/config.repository';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { teardownTelemetry, TelemetryRepository } from 'src/repositories/telemetry.repository'; import { teardownTelemetry, TelemetryRepository } from 'src/repositories/telemetry.repository';
import { resolvers } from 'src/resolvers';
import { services } from 'src/services'; import { services } from 'src/services';
import { CliService } from 'src/services/cli.service'; import { CliService } from 'src/services/cli.service';
import { DatabaseService } from 'src/services/database.service'; import { DatabaseService } from 'src/services/database.service';
@@ -108,28 +104,9 @@ class BaseModule implements OnModuleInit, OnModuleDestroy {
} }
@Module({ @Module({
imports: [ imports: [...imports, ScheduleModule.forRoot()],
...imports,
ScheduleModule.forRoot(),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
playground: true,
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
sortSchema: true,
debug: true,
buildSchemaOptions: {
numberScalarMode: 'integer',
},
}),
],
controllers: [...controllers], controllers: [...controllers],
providers: [ providers: [...common, ...middleware, { provide: IWorker, useValue: ImmichWorker.API }],
//
...common,
...middleware,
...resolvers,
{ provide: IWorker, useValue: ImmichWorker.API },
],
}) })
export class ApiModule extends BaseModule {} export class ApiModule extends BaseModule {}
+1 -1
View File
@@ -33,7 +33,7 @@ export const citiesFile = 'cities500.txt';
export const MOBILE_REDIRECT = 'app.immich:///oauth-callback'; export const MOBILE_REDIRECT = 'app.immich:///oauth-callback';
export const LOGIN_URL = '/auth/login?autoLaunch=0'; export const LOGIN_URL = '/auth/login?autoLaunch=0';
export const excludePaths = ['/.well-known/immich', '/custom.css', '/favicon.ico', '/graphql']; export const excludePaths = ['/.well-known/immich', '/custom.css', '/favicon.ico'];
export const FACE_THUMBNAIL_SIZE = 250; export const FACE_THUMBNAIL_SIZE = 250;
@@ -9,7 +9,6 @@ import {
SharedLinkEditDto, SharedLinkEditDto,
SharedLinkPasswordDto, SharedLinkPasswordDto,
SharedLinkResponseDto, SharedLinkResponseDto,
SharedLinkSearchDto,
} from 'src/dtos/shared-link.dto'; } from 'src/dtos/shared-link.dto';
import { ImmichCookie, Permission } from 'src/enum'; import { ImmichCookie, Permission } from 'src/enum';
import { Auth, Authenticated, GetLoginDetails } from 'src/middleware/auth.guard'; import { Auth, Authenticated, GetLoginDetails } from 'src/middleware/auth.guard';
@@ -25,8 +24,8 @@ export class SharedLinkController {
@Get() @Get()
@Authenticated({ permission: Permission.SHARED_LINK_READ }) @Authenticated({ permission: Permission.SHARED_LINK_READ })
getAllSharedLinks(@Auth() auth: AuthDto, @Query() dto: SharedLinkSearchDto): Promise<SharedLinkResponseDto[]> { getAllSharedLinks(@Auth() auth: AuthDto): Promise<SharedLinkResponseDto[]> {
return this.service.getAll(auth, dto); return this.service.getAll(auth);
} }
@Get('me') @Get('me')
+2 -16
View File
@@ -9,7 +9,6 @@ import {
Param, Param,
Post, Post,
Put, Put,
Req,
Res, Res,
UploadedFile, UploadedFile,
UseInterceptors, UseInterceptors,
@@ -39,21 +38,8 @@ export class UserController {
@Get() @Get()
@Authenticated() @Authenticated()
async searchUsers(@Req() req: Request): Promise<UserResponseDto[]> { searchUsers(@Auth() auth: AuthDto): Promise<UserResponseDto[]> {
const response = await fetch(`http://localhost:2283/graphql`, { return this.service.search(auth);
method: 'POST',
body: JSON.stringify({
operationName: null,
query: '{ users { id name email } }',
}),
headers: {
...req.headers,
'Content-Type': 'application/json',
},
});
const { data } = await response.json();
return data.users;
} }
@Get('me') @Get('me')
+11 -12
View File
@@ -5,13 +5,12 @@ import { AssetEntity } from 'src/entities/asset.entity';
import { PersonEntity } from 'src/entities/person.entity'; import { PersonEntity } from 'src/entities/person.entity';
import { AssetFileType, AssetPathType, ImageFormat, PathType, PersonPathType, StorageFolder } from 'src/enum'; import { AssetFileType, AssetPathType, ImageFormat, PathType, PersonPathType, StorageFolder } from 'src/enum';
import { IAssetRepository } from 'src/interfaces/asset.interface'; import { IAssetRepository } from 'src/interfaces/asset.interface';
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
import { IMoveRepository } from 'src/interfaces/move.interface'; import { IMoveRepository } from 'src/interfaces/move.interface';
import { IPersonRepository } from 'src/interfaces/person.interface'; import { IPersonRepository } from 'src/interfaces/person.interface';
import { IStorageRepository } from 'src/interfaces/storage.interface'; import { IStorageRepository } from 'src/interfaces/storage.interface';
import { ConfigRepository } from 'src/repositories/config.repository'; import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { CryptoRepository } from 'src/repositories/crypto.repository'; import { IConfigRepository, ILoggingRepository } from 'src/types';
import { LoggingRepository } from 'src/repositories/logging.repository';
import { SystemMetadataRepository } from 'src/repositories/system-metadata.repository';
import { getAssetFiles } from 'src/utils/asset.util'; import { getAssetFiles } from 'src/utils/asset.util';
import { getConfig } from 'src/utils/config'; import { getConfig } from 'src/utils/config';
@@ -34,24 +33,24 @@ let instance: StorageCore | null;
export class StorageCore { export class StorageCore {
private constructor( private constructor(
private assetRepository: IAssetRepository, private assetRepository: IAssetRepository,
private configRepository: ConfigRepository, private configRepository: IConfigRepository,
private cryptoRepository: CryptoRepository, private cryptoRepository: ICryptoRepository,
private moveRepository: IMoveRepository, private moveRepository: IMoveRepository,
private personRepository: IPersonRepository, private personRepository: IPersonRepository,
private storageRepository: IStorageRepository, private storageRepository: IStorageRepository,
private systemMetadataRepository: SystemMetadataRepository, private systemMetadataRepository: ISystemMetadataRepository,
private logger: LoggingRepository, private logger: ILoggingRepository,
) {} ) {}
static create( static create(
assetRepository: IAssetRepository, assetRepository: IAssetRepository,
configRepository: ConfigRepository, configRepository: IConfigRepository,
cryptoRepository: CryptoRepository, cryptoRepository: ICryptoRepository,
moveRepository: IMoveRepository, moveRepository: IMoveRepository,
personRepository: IPersonRepository, personRepository: IPersonRepository,
storageRepository: IStorageRepository, storageRepository: IStorageRepository,
systemMetadataRepository: SystemMetadataRepository, systemMetadataRepository: ISystemMetadataRepository,
logger: LoggingRepository, logger: ILoggingRepository,
) { ) {
if (!instance) { if (!instance) {
instance = new StorageCore( instance = new StorageCore(
-1
View File
@@ -276,7 +276,6 @@ export interface Partners {
export interface Person { export interface Person {
birthDate: Timestamp | null; birthDate: Timestamp | null;
color: string | null;
createdAt: Generated<Timestamp>; createdAt: Generated<Timestamp>;
faceAssetId: string | null; faceAssetId: string | null;
id: Generated<string>; id: Generated<string>;
+1 -15
View File
@@ -7,14 +7,7 @@ import { AuthDto } from 'src/dtos/auth.dto';
import { AssetFaceEntity } from 'src/entities/asset-face.entity'; import { AssetFaceEntity } from 'src/entities/asset-face.entity';
import { PersonEntity } from 'src/entities/person.entity'; import { PersonEntity } from 'src/entities/person.entity';
import { SourceType } from 'src/enum'; import { SourceType } from 'src/enum';
import { import { IsDateStringFormat, MaxDateString, Optional, ValidateBoolean, ValidateUUID } from 'src/validation';
IsDateStringFormat,
MaxDateString,
Optional,
ValidateBoolean,
ValidateHexColor,
ValidateUUID,
} from 'src/validation';
export class PersonCreateDto { export class PersonCreateDto {
/** /**
@@ -42,10 +35,6 @@ export class PersonCreateDto {
@ValidateBoolean({ optional: true }) @ValidateBoolean({ optional: true })
isFavorite?: boolean; isFavorite?: boolean;
@Optional({ emptyToNull: true, nullable: true })
@ValidateHexColor()
color?: string | null;
} }
export class PersonUpdateDto extends PersonCreateDto { export class PersonUpdateDto extends PersonCreateDto {
@@ -113,8 +102,6 @@ export class PersonResponseDto {
updatedAt?: Date; updatedAt?: Date;
@PropertyLifecycle({ addedAt: 'v1.126.0' }) @PropertyLifecycle({ addedAt: 'v1.126.0' })
isFavorite?: boolean; isFavorite?: boolean;
@PropertyLifecycle({ addedAt: 'v1.126.0' })
color?: string;
} }
export class PersonWithFacesResponseDto extends PersonResponseDto { export class PersonWithFacesResponseDto extends PersonResponseDto {
@@ -189,7 +176,6 @@ export function mapPerson(person: PersonEntity): PersonResponseDto {
thumbnailPath: person.thumbnailPath, thumbnailPath: person.thumbnailPath,
isHidden: person.isHidden, isHidden: person.isHidden,
isFavorite: person.isFavorite, isFavorite: person.isFavorite,
color: person.color ?? undefined,
updatedAt: person.updatedAt, updatedAt: person.updatedAt,
}; };
} }
+2 -2
View File
@@ -1,4 +1,4 @@
import { SessionItem } from 'src/types'; import { SessionEntity } from 'src/entities/session.entity';
export class SessionResponseDto { export class SessionResponseDto {
id!: string; id!: string;
@@ -9,7 +9,7 @@ export class SessionResponseDto {
deviceOS!: string; deviceOS!: string;
} }
export const mapSession = (entity: SessionItem, currentId?: string): SessionResponseDto => ({ export const mapSession = (entity: SessionEntity, currentId?: string): SessionResponseDto => ({
id: entity.id, id: entity.id,
createdAt: entity.createdAt.toISOString(), createdAt: entity.createdAt.toISOString(),
updatedAt: entity.updatedAt.toISOString(), updatedAt: entity.updatedAt.toISOString(),
-5
View File
@@ -7,11 +7,6 @@ import { SharedLinkEntity } from 'src/entities/shared-link.entity';
import { SharedLinkType } from 'src/enum'; import { SharedLinkType } from 'src/enum';
import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation'; import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation';
export class SharedLinkSearchDto {
@ValidateUUID({ optional: true })
albumId?: string;
}
export class SharedLinkCreateDto { export class SharedLinkCreateDto {
@IsEnum(SharedLinkType) @IsEnum(SharedLinkType)
@ApiProperty({ enum: SharedLinkType, enumName: 'SharedLinkType' }) @ApiProperty({ enum: SharedLinkType, enumName: 'SharedLinkType' })
+5 -3
View File
@@ -1,7 +1,8 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsHexColor, IsNotEmpty, IsString } from 'class-validator'; import { IsHexColor, IsNotEmpty, IsString } from 'class-validator';
import { TagEntity } from 'src/entities/tag.entity'; import { TagEntity } from 'src/entities/tag.entity';
import { Optional, ValidateHexColor, ValidateUUID } from 'src/validation'; import { Optional, ValidateUUID } from 'src/validation';
export class TagCreateDto { export class TagCreateDto {
@IsString() @IsString()
@@ -17,8 +18,9 @@ export class TagCreateDto {
} }
export class TagUpdateDto { export class TagUpdateDto {
@Optional({ emptyToNull: true, nullable: true }) @Optional({ nullable: true, emptyToNull: true })
@ValidateHexColor() @IsHexColor()
@Transform(({ value }) => (typeof value === 'string' && value[0] !== '#' ? `#${value}` : value))
color?: string | null; color?: string | null;
} }
-19
View File
@@ -38,14 +38,6 @@ class PeopleUpdate {
sidebarWeb?: boolean; sidebarWeb?: boolean;
} }
class SharedLinksUpdate {
@ValidateBoolean({ optional: true })
enabled?: boolean;
@ValidateBoolean({ optional: true })
sidebarWeb?: boolean;
}
class TagsUpdate { class TagsUpdate {
@ValidateBoolean({ optional: true }) @ValidateBoolean({ optional: true })
enabled?: boolean; enabled?: boolean;
@@ -106,11 +98,6 @@ export class UserPreferencesUpdateDto {
@Type(() => RatingsUpdate) @Type(() => RatingsUpdate)
ratings?: RatingsUpdate; ratings?: RatingsUpdate;
@Optional()
@ValidateNested()
@Type(() => SharedLinksUpdate)
sharedLinks?: SharedLinksUpdate;
@Optional() @Optional()
@ValidateNested() @ValidateNested()
@Type(() => TagsUpdate) @Type(() => TagsUpdate)
@@ -165,11 +152,6 @@ class TagsResponse {
sidebarWeb: boolean = true; sidebarWeb: boolean = true;
} }
class SharedLinksResponse {
enabled: boolean = true;
sidebarWeb: boolean = false;
}
class EmailNotificationsResponse { class EmailNotificationsResponse {
enabled!: boolean; enabled!: boolean;
albumInvite!: boolean; albumInvite!: boolean;
@@ -193,7 +175,6 @@ export class UserPreferencesResponseDto implements UserPreferences {
memories!: MemoriesResponse; memories!: MemoriesResponse;
people!: PeopleResponse; people!: PeopleResponse;
ratings!: RatingsResponse; ratings!: RatingsResponse;
sharedLinks!: SharedLinksResponse;
tags!: TagsResponse; tags!: TagsResponse;
avatar!: AvatarResponse; avatar!: AvatarResponse;
emailNotifications!: EmailNotificationsResponse; emailNotifications!: EmailNotificationsResponse;
-3
View File
@@ -52,7 +52,4 @@ export class PersonEntity {
@Column({ default: false }) @Column({ default: false })
isFavorite!: boolean; isFavorite!: boolean;
@Column({ type: 'varchar', nullable: true, default: null })
color?: string | null;
} }
@@ -34,10 +34,6 @@ export interface UserPreferences {
ratings: { ratings: {
enabled: boolean; enabled: boolean;
}; };
sharedLinks: {
enabled: boolean;
sidebarWeb: boolean;
};
tags: { tags: {
enabled: boolean; enabled: boolean;
sidebarWeb: boolean; sidebarWeb: boolean;
@@ -78,10 +74,6 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
enabled: true, enabled: true,
sidebarWeb: false, sidebarWeb: false,
}, },
sharedLinks: {
enabled: true,
sidebarWeb: false,
},
ratings: { ratings: {
enabled: false, enabled: false,
}, },
@@ -0,0 +1,25 @@
import { ChildProcessWithoutNullStreams, SpawnOptionsWithoutStdio } from 'node:child_process';
import { Readable } from 'node:stream';
export interface ImmichReadStream {
stream: Readable;
type?: string;
length?: number;
}
export interface ImmichZipStream extends ImmichReadStream {
addFile: (inputPath: string, filename: string) => void;
finalize: () => Promise<void>;
}
export interface DiskUsage {
available: number;
free: number;
total: number;
}
export const IProcessRepository = 'IProcessRepository';
export interface IProcessRepository {
spawn(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
}
@@ -0,0 +1,17 @@
import { Insertable, Updateable } from 'kysely';
import { Sessions } from 'src/db';
import { SessionEntity } from 'src/entities/session.entity';
export const ISessionRepository = 'ISessionRepository';
type E = SessionEntity;
export type SessionSearchOptions = { updatedBefore: Date };
export interface ISessionRepository {
search(options: SessionSearchOptions): Promise<SessionEntity[]>;
create(dto: Insertable<Sessions>): Promise<SessionEntity>;
update(id: string, dto: Updateable<Sessions>): Promise<SessionEntity>;
delete(id: string): Promise<void>;
getByToken(token: string): Promise<E | undefined>;
getByUserId(userId: string): Promise<E[]>;
}
@@ -4,13 +4,8 @@ import { SharedLinkEntity } from 'src/entities/shared-link.entity';
export const ISharedLinkRepository = 'ISharedLinkRepository'; export const ISharedLinkRepository = 'ISharedLinkRepository';
export type SharedLinkSearchOptions = {
userId: string;
albumId?: string;
};
export interface ISharedLinkRepository { export interface ISharedLinkRepository {
getAll(options: SharedLinkSearchOptions): Promise<SharedLinkEntity[]>; getAll(userId: string): Promise<SharedLinkEntity[]>;
get(userId: string, id: string): Promise<SharedLinkEntity | undefined>; get(userId: string, id: string): Promise<SharedLinkEntity | undefined>;
getByKey(key: Buffer): Promise<SharedLinkEntity | undefined>; getByKey(key: Buffer): Promise<SharedLinkEntity | undefined>;
create(entity: Insertable<SharedLinks> & { assetIds?: string[] }): Promise<SharedLinkEntity>; create(entity: Insertable<SharedLinks> & { assetIds?: string[] }): Promise<SharedLinkEntity>;
@@ -0,0 +1,10 @@
import { SystemMetadata } from 'src/entities/system-metadata.entity';
export const ISystemMetadataRepository = 'ISystemMetadataRepository';
export interface ISystemMetadataRepository {
get<T extends keyof SystemMetadata>(key: T): Promise<SystemMetadata[T] | null>;
set<T extends keyof SystemMetadata>(key: T, value: SystemMetadata[T]): Promise<void>;
delete<T extends keyof SystemMetadata>(key: T): Promise<void>;
readFile(filename: string): Promise<string>;
}
@@ -5,18 +5,19 @@ import { AssetMediaResponseDto, AssetMediaStatus } from 'src/dtos/asset-media-re
import { ImmichHeader } from 'src/enum'; import { ImmichHeader } from 'src/enum';
import { AuthenticatedRequest } from 'src/middleware/auth.guard'; import { AuthenticatedRequest } from 'src/middleware/auth.guard';
import { AssetMediaService } from 'src/services/asset-media.service'; import { AssetMediaService } from 'src/services/asset-media.service';
import { fromMaybeArray, getReqRes } from 'src/utils/request'; import { fromMaybeArray } from 'src/utils/request';
@Injectable() @Injectable()
export class AssetUploadInterceptor implements NestInterceptor { export class AssetUploadInterceptor implements NestInterceptor {
constructor(private service: AssetMediaService) {} constructor(private service: AssetMediaService) {}
async intercept(context: ExecutionContext, next: CallHandler<any>) { async intercept(context: ExecutionContext, next: CallHandler<any>) {
const { type, req, res } = getReqRes<AuthenticatedRequest, Response<AssetMediaResponseDto>>(context); const req = context.switchToHttp().getRequest<AuthenticatedRequest>();
const res = context.switchToHttp().getResponse<Response<AssetMediaResponseDto>>();
const checksum = fromMaybeArray(req.headers[ImmichHeader.CHECKSUM]); const checksum = fromMaybeArray(req.headers[ImmichHeader.CHECKSUM]);
const response = await this.service.getUploadAssetIdByChecksum(req.user, checksum); const response = await this.service.getUploadAssetIdByChecksum(req.user, checksum);
if (response && type === 'http') { if (response) {
res.status(200); res.status(200);
return of({ status: AssetMediaStatus.DUPLICATE, id: response.id }); return of({ status: AssetMediaStatus.DUPLICATE, id: response.id });
} }
+6 -8
View File
@@ -13,7 +13,6 @@ import { AuthDto } from 'src/dtos/auth.dto';
import { ImmichQuery, MetadataKey, Permission } from 'src/enum'; import { ImmichQuery, MetadataKey, Permission } from 'src/enum';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { AuthService, LoginDetails } from 'src/services/auth.service'; import { AuthService, LoginDetails } from 'src/services/auth.service';
import { getReqRes } from 'src/utils/request';
import { UAParser } from 'ua-parser-js'; import { UAParser } from 'ua-parser-js';
type AdminRoute = { admin?: true }; type AdminRoute = { admin?: true };
@@ -36,8 +35,7 @@ export const Authenticated = (options?: AuthenticatedOptions): MethodDecorator =
}; };
export const Auth = createParamDecorator((data, context: ExecutionContext): AuthDto => { export const Auth = createParamDecorator((data, context: ExecutionContext): AuthDto => {
const { req } = getReqRes<AuthenticatedRequest>(context); return context.switchToHttp().getRequest<AuthenticatedRequest>().user;
return req.user;
}); });
export const FileResponse = () => export const FileResponse = () =>
@@ -88,12 +86,12 @@ export class AuthGuard implements CanActivate {
sharedLink: sharedLinkRoute, sharedLink: sharedLinkRoute,
permission, permission,
} = { sharedLink: false, admin: false, ...options }; } = { sharedLink: false, admin: false, ...options };
const { req } = getReqRes<AuthenticatedRequest>(context); const request = context.switchToHttp().getRequest<AuthRequest>();
req.user = await this.authService.authenticate({ request.user = await this.authService.authenticate({
headers: req.headers, headers: request.headers,
queryParams: req.query as Record<string, string>, queryParams: request.query as Record<string, string>,
metadata: { adminRoute, sharedLinkRoute, permission, uri: req.path }, metadata: { adminRoute, sharedLinkRoute, permission, uri: request.path },
}); });
return true; return true;
@@ -1,18 +1,8 @@
import { ArgumentsHost, Catch, ExceptionFilter, HttpException } from '@nestjs/common'; import { ArgumentsHost, Catch, ExceptionFilter, HttpException } from '@nestjs/common';
import { GqlContextType } from '@nestjs/graphql'; import { Response } from 'express';
import { GraphQLError } from 'graphql';
import { ClsService } from 'nestjs-cls'; import { ClsService } from 'nestjs-cls';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { logGlobalError } from 'src/utils/logger'; import { logGlobalError } from 'src/utils/logger';
import { getReqRes } from 'src/utils/request';
type StructuredError = {
status: number;
body: {
[key: string]: unknown;
message?: string;
};
};
@Catch() @Catch()
export class GlobalExceptionFilter implements ExceptionFilter<Error> { export class GlobalExceptionFilter implements ExceptionFilter<Error> {
@@ -24,20 +14,15 @@ export class GlobalExceptionFilter implements ExceptionFilter<Error> {
} }
catch(error: Error, host: ArgumentsHost) { catch(error: Error, host: ArgumentsHost) {
const { res } = getReqRes(host); const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const { status, body } = this.fromError(error); const { status, body } = this.fromError(error);
const message = { ...body, statusCode: status, correlationId: this.cls.getId() }; if (!response.headersSent) {
response.status(status).json({ ...body, statusCode: status, correlationId: this.cls.getId() });
if (host.getType<GqlContextType>() === 'graphql') {
throw new GraphQLError(body?.message || 'Error', { extensions: message });
}
if (!res.headersSent) {
res.status(status).json(message);
} }
} }
private fromError(error: Error): StructuredError { private fromError(error: Error) {
logGlobalError(this.logger, error); logGlobalError(this.logger, error);
if (error instanceof HttpException) { if (error instanceof HttpException) {
@@ -49,7 +34,7 @@ export class GlobalExceptionFilter implements ExceptionFilter<Error> {
body = { message: body }; body = { message: body };
} }
return { status, body } as StructuredError; return { status, body };
} }
return { return {
+8 -3
View File
@@ -1,7 +1,7 @@
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { Request, Response } from 'express';
import { Observable, finalize } from 'rxjs'; import { Observable, finalize } from 'rxjs';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { getReqRes } from 'src/utils/request';
const maxArrayLength = 100; const maxArrayLength = 100;
const replacer = (key: string, value: unknown) => { const replacer = (key: string, value: unknown) => {
@@ -23,7 +23,10 @@ export class LoggingInterceptor implements NestInterceptor {
} }
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> { intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> {
const { req, res } = getReqRes(context); const handler = context.switchToHttp();
const req = handler.getRequest<Request>();
const res = handler.getResponse<Response>();
const { method, ip, url } = req; const { method, ip, url } = req;
const start = performance.now(); const start = performance.now();
@@ -32,7 +35,9 @@ export class LoggingInterceptor implements NestInterceptor {
finalize(() => { finalize(() => {
const finish = performance.now(); const finish = performance.now();
const duration = (finish - start).toFixed(2); const duration = (finish - start).toFixed(2);
this.logger.debug(`${method} ${url} ${res?.statusCode || ''} ${duration}ms ${ip}`); const { statusCode } = res;
this.logger.debug(`${method} ${url} ${statusCode} ${duration}ms ${ip}`);
if (req.body && Object.keys(req.body).length > 0) { if (req.body && Object.keys(req.body).length > 0) {
this.logger.verbose(JSON.stringify(req.body, replacer)); this.logger.verbose(JSON.stringify(req.body, replacer));
} }
@@ -1,14 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddPersonColor1738889177573 implements MigrationInterface {
name = 'AddPersonColor1738889177573'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "person" ADD "color" character varying`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "person" DROP COLUMN "color"`);
}
}
-27
View File
@@ -1,27 +0,0 @@
import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';
import { UserAvatarColor } from 'src/enum';
registerEnumType(UserAvatarColor, {
name: 'UserAvatarColor',
});
@ObjectType()
export class User {
@Field()
id!: string;
@Field()
name!: string;
@Field()
email!: string;
@Field(() => UserAvatarColor)
avatarColor!: UserAvatarColor;
@Field()
profileImagePath!: string;
@Field({ nullable: true })
profileChangedAt!: Date;
}
+1 -1
View File
@@ -524,7 +524,7 @@ export class AssetRepository implements IAssetRepository {
.executeTakeFirst() as Promise<AssetEntity | undefined>; .executeTakeFirst() as Promise<AssetEntity | undefined>;
} }
private getMapMarkers(ownerIds: string[], options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> { getMapMarkers(ownerIds: string[], options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> {
const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options; const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options;
return this.db return this.db
+6 -3
View File
@@ -9,10 +9,13 @@ import { IMachineLearningRepository } from 'src/interfaces/machine-learning.inte
import { IMoveRepository } from 'src/interfaces/move.interface'; import { IMoveRepository } from 'src/interfaces/move.interface';
import { IPartnerRepository } from 'src/interfaces/partner.interface'; import { IPartnerRepository } from 'src/interfaces/partner.interface';
import { IPersonRepository } from 'src/interfaces/person.interface'; import { IPersonRepository } from 'src/interfaces/person.interface';
import { IProcessRepository } from 'src/interfaces/process.interface';
import { ISearchRepository } from 'src/interfaces/search.interface'; import { ISearchRepository } from 'src/interfaces/search.interface';
import { ISessionRepository } from 'src/interfaces/session.interface';
import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface'; import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface';
import { IStackRepository } from 'src/interfaces/stack.interface'; import { IStackRepository } from 'src/interfaces/stack.interface';
import { IStorageRepository } from 'src/interfaces/storage.interface'; import { IStorageRepository } from 'src/interfaces/storage.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { ITagRepository } from 'src/interfaces/tag.interface'; import { ITagRepository } from 'src/interfaces/tag.interface';
import { IUserRepository } from 'src/interfaces/user.interface'; import { IUserRepository } from 'src/interfaces/user.interface';
import { AccessRepository } from 'src/repositories/access.repository'; import { AccessRepository } from 'src/repositories/access.repository';
@@ -70,10 +73,7 @@ export const repositories = [
MetadataRepository, MetadataRepository,
NotificationRepository, NotificationRepository,
OAuthRepository, OAuthRepository,
ProcessRepository,
SessionRepository,
ServerInfoRepository, ServerInfoRepository,
SystemMetadataRepository,
TelemetryRepository, TelemetryRepository,
TrashRepository, TrashRepository,
ViewRepository, ViewRepository,
@@ -92,10 +92,13 @@ export const providers = [
{ provide: IMoveRepository, useClass: MoveRepository }, { provide: IMoveRepository, useClass: MoveRepository },
{ provide: IPartnerRepository, useClass: PartnerRepository }, { provide: IPartnerRepository, useClass: PartnerRepository },
{ provide: IPersonRepository, useClass: PersonRepository }, { provide: IPersonRepository, useClass: PersonRepository },
{ provide: IProcessRepository, useClass: ProcessRepository },
{ provide: ISearchRepository, useClass: SearchRepository }, { provide: ISearchRepository, useClass: SearchRepository },
{ provide: ISessionRepository, useClass: SessionRepository },
{ provide: ISharedLinkRepository, useClass: SharedLinkRepository }, { provide: ISharedLinkRepository, useClass: SharedLinkRepository },
{ provide: IStackRepository, useClass: StackRepository }, { provide: IStackRepository, useClass: StackRepository },
{ provide: IStorageRepository, useClass: StorageRepository }, { provide: IStorageRepository, useClass: StorageRepository },
{ provide: ISystemMetadataRepository, useClass: SystemMetadataRepository },
{ provide: ITagRepository, useClass: TagRepository }, { provide: ITagRepository, useClass: TagRepository },
{ provide: IUserRepository, useClass: UserRepository }, { provide: IUserRepository, useClass: UserRepository },
]; ];
@@ -1,14 +1,14 @@
import { ClsService } from 'nestjs-cls'; import { ClsService } from 'nestjs-cls';
import { ImmichWorker } from 'src/enum'; import { ImmichWorker } from 'src/enum';
import { ConfigRepository } from 'src/repositories/config.repository';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { IConfigRepository } from 'src/types';
import { mockEnvData, newConfigRepositoryMock } from 'test/repositories/config.repository.mock'; import { mockEnvData, newConfigRepositoryMock } from 'test/repositories/config.repository.mock';
import { Mocked } from 'vitest'; import { Mocked } from 'vitest';
describe(LoggingRepository.name, () => { describe(LoggingRepository.name, () => {
let sut: LoggingRepository; let sut: LoggingRepository;
let configMock: Mocked<ConfigRepository>; let configMock: Mocked<IConfigRepository>;
let clsMock: Mocked<ClsService>; let clsMock: Mocked<ClsService>;
beforeEach(() => { beforeEach(() => {
+3 -3
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { getName } from 'i18n-iso-countries'; import { getName } from 'i18n-iso-countries';
import { Expression, Kysely, sql, SqlBool } from 'kysely'; import { Expression, Kysely, sql, SqlBool } from 'kysely';
import { InjectKysely } from 'nestjs-kysely'; import { InjectKysely } from 'nestjs-kysely';
@@ -11,9 +11,9 @@ import { DB, GeodataPlaces, NaturalearthCountries } from 'src/db';
import { DummyValue, GenerateSql } from 'src/decorators'; import { DummyValue, GenerateSql } from 'src/decorators';
import { NaturalEarthCountriesTempEntity } from 'src/entities/natural-earth-countries.entity'; import { NaturalEarthCountriesTempEntity } from 'src/entities/natural-earth-countries.entity';
import { LogLevel, SystemMetadataKey } from 'src/enum'; import { LogLevel, SystemMetadataKey } from 'src/enum';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { ConfigRepository } from 'src/repositories/config.repository'; import { ConfigRepository } from 'src/repositories/config.repository';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { SystemMetadataRepository } from 'src/repositories/system-metadata.repository';
export interface MapMarkerSearchOptions { export interface MapMarkerSearchOptions {
isArchived?: boolean; isArchived?: boolean;
@@ -48,7 +48,7 @@ interface MapDB extends DB {
export class MapRepository { export class MapRepository {
constructor( constructor(
private configRepository: ConfigRepository, private configRepository: ConfigRepository,
private metadataRepository: SystemMetadataRepository, @Inject(ISystemMetadataRepository) private metadataRepository: ISystemMetadataRepository,
private logger: LoggingRepository, private logger: LoggingRepository,
@InjectKysely() private db: Kysely<MapDB>, @InjectKysely() private db: Kysely<MapDB>,
) { ) {
@@ -1,16 +1,17 @@
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { EmailRenderRequest, EmailTemplate, NotificationRepository } from 'src/repositories/notification.repository'; import { EmailRenderRequest, EmailTemplate, NotificationRepository } from 'src/repositories/notification.repository';
import { ILoggingRepository, newLoggingRepositoryMock } from 'test/repositories/logger.repository.mock'; import { ILoggingRepository } from 'src/types';
import { newLoggingRepositoryMock } from 'test/repositories/logger.repository.mock';
import { Mocked } from 'vitest'; import { Mocked } from 'vitest';
describe(NotificationRepository.name, () => { describe(NotificationRepository.name, () => {
let sut: NotificationRepository; let sut: NotificationRepository;
let loggerMock: Mocked<LoggingRepository>; let loggerMock: Mocked<ILoggingRepository>;
beforeEach(() => { beforeEach(() => {
loggerMock = newLoggingRepositoryMock() as ILoggingRepository as Mocked<LoggingRepository>; loggerMock = newLoggingRepositoryMock();
sut = new NotificationRepository(loggerMock as LoggingRepository); sut = new NotificationRepository(loggerMock as ILoggingRepository as LoggingRepository);
}); });
describe('renderEmail', () => { describe('renderEmail', () => {
+1 -6
View File
@@ -43,12 +43,7 @@ export class OAuthRepository {
const params = client.callbackParams(url); const params = client.callbackParams(url);
try { try {
const tokens = await client.callback(redirectUrl, params, { state: params.state }); const tokens = await client.callback(redirectUrl, params, { state: params.state });
const profile = await client.userinfo<OAuthProfile>(tokens.access_token || ''); return await client.userinfo<OAuthProfile>(tokens.access_token || '');
if (!profile.sub) {
throw new Error('Unexpected profile response, no `sub`');
}
return profile;
} catch (error: Error | any) { } catch (error: Error | any) {
if (error.message.includes('unexpected JWT alg received')) { if (error.message.includes('unexpected JWT alg received')) {
this.logger.warn( this.logger.warn(
@@ -1,11 +1,13 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { ChildProcessWithoutNullStreams, spawn, SpawnOptionsWithoutStdio } from 'node:child_process'; import { ChildProcessWithoutNullStreams, spawn, SpawnOptionsWithoutStdio } from 'node:child_process';
import { IProcessRepository } from 'src/interfaces/process.interface';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { StorageRepository } from 'src/repositories/storage.repository';
@Injectable() @Injectable()
export class ProcessRepository { export class ProcessRepository implements IProcessRepository {
constructor(private logger: LoggingRepository) { constructor(private logger: LoggingRepository) {
this.logger.setContext(ProcessRepository.name); this.logger.setContext(StorageRepository.name);
} }
spawn(command: string, args: readonly string[], options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams { spawn(command: string, args: readonly string[], options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams {
+20 -15
View File
@@ -3,37 +3,36 @@ import { Insertable, Kysely, Updateable } from 'kysely';
import { InjectKysely } from 'nestjs-kysely'; import { InjectKysely } from 'nestjs-kysely';
import { DB, Sessions } from 'src/db'; import { DB, Sessions } from 'src/db';
import { DummyValue, GenerateSql } from 'src/decorators'; import { DummyValue, GenerateSql } from 'src/decorators';
import { withUser } from 'src/entities/session.entity'; import { SessionEntity, withUser } from 'src/entities/session.entity';
import { ISessionRepository, SessionSearchOptions } from 'src/interfaces/session.interface';
import { asUuid } from 'src/utils/database'; import { asUuid } from 'src/utils/database';
export type SessionSearchOptions = { updatedBefore: Date };
@Injectable() @Injectable()
export class SessionRepository { export class SessionRepository implements ISessionRepository {
constructor(@InjectKysely() private db: Kysely<DB>) {} constructor(@InjectKysely() private db: Kysely<DB>) {}
@GenerateSql({ params: [{ updatedBefore: DummyValue.DATE }] }) @GenerateSql({ params: [{ updatedBefore: DummyValue.DATE }] })
search(options: SessionSearchOptions) { search(options: SessionSearchOptions): Promise<SessionEntity[]> {
return this.db return this.db
.selectFrom('sessions') .selectFrom('sessions')
.selectAll() .selectAll()
.where('sessions.updatedAt', '<=', options.updatedBefore) .where('sessions.updatedAt', '<=', options.updatedBefore)
.execute(); .execute() as Promise<SessionEntity[]>;
} }
@GenerateSql({ params: [DummyValue.STRING] }) @GenerateSql({ params: [DummyValue.STRING] })
getByToken(token: string) { getByToken(token: string): Promise<SessionEntity | undefined> {
return this.db return this.db
.selectFrom('sessions') .selectFrom('sessions')
.innerJoinLateral(withUser, (join) => join.onTrue()) .innerJoinLateral(withUser, (join) => join.onTrue())
.selectAll('sessions') .selectAll('sessions')
.select((eb) => eb.fn.toJson('user').as('user')) .select((eb) => eb.fn.toJson('user').as('user'))
.where('sessions.token', '=', token) .where('sessions.token', '=', token)
.executeTakeFirst(); .executeTakeFirst() as Promise<SessionEntity | undefined>;
} }
@GenerateSql({ params: [DummyValue.UUID] }) @GenerateSql({ params: [DummyValue.UUID] })
getByUserId(userId: string) { getByUserId(userId: string): Promise<SessionEntity[]> {
return this.db return this.db
.selectFrom('sessions') .selectFrom('sessions')
.innerJoinLateral(withUser, (join) => join.onTrue()) .innerJoinLateral(withUser, (join) => join.onTrue())
@@ -42,24 +41,30 @@ export class SessionRepository {
.where('sessions.userId', '=', userId) .where('sessions.userId', '=', userId)
.orderBy('sessions.updatedAt', 'desc') .orderBy('sessions.updatedAt', 'desc')
.orderBy('sessions.createdAt', 'desc') .orderBy('sessions.createdAt', 'desc')
.execute(); .execute() as unknown as Promise<SessionEntity[]>;
} }
create(dto: Insertable<Sessions>) { async create(dto: Insertable<Sessions>): Promise<SessionEntity> {
return this.db.insertInto('sessions').values(dto).returningAll().executeTakeFirstOrThrow(); const { id, token, userId, createdAt, updatedAt, deviceType, deviceOS } = await this.db
.insertInto('sessions')
.values(dto)
.returningAll()
.executeTakeFirstOrThrow();
return { id, token, userId, createdAt, updatedAt, deviceType, deviceOS } as SessionEntity;
} }
update(id: string, dto: Updateable<Sessions>) { update(id: string, dto: Updateable<Sessions>): Promise<SessionEntity> {
return this.db return this.db
.updateTable('sessions') .updateTable('sessions')
.set(dto) .set(dto)
.where('sessions.id', '=', asUuid(id)) .where('sessions.id', '=', asUuid(id))
.returningAll() .returningAll()
.executeTakeFirstOrThrow(); .executeTakeFirstOrThrow() as Promise<SessionEntity>;
} }
@GenerateSql({ params: [DummyValue.UUID] }) @GenerateSql({ params: [DummyValue.UUID] })
async delete(id: string) { async delete(id: string): Promise<void> {
await this.db.deleteFrom('sessions').where('id', '=', asUuid(id)).execute(); await this.db.deleteFrom('sessions').where('id', '=', asUuid(id)).execute();
} }
} }
@@ -7,7 +7,7 @@ import { DB, SharedLinks } from 'src/db';
import { DummyValue, GenerateSql } from 'src/decorators'; import { DummyValue, GenerateSql } from 'src/decorators';
import { SharedLinkEntity } from 'src/entities/shared-link.entity'; import { SharedLinkEntity } from 'src/entities/shared-link.entity';
import { SharedLinkType } from 'src/enum'; import { SharedLinkType } from 'src/enum';
import { ISharedLinkRepository, SharedLinkSearchOptions } from 'src/interfaces/shared-link.interface'; import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface';
@Injectable() @Injectable()
export class SharedLinkRepository implements ISharedLinkRepository { export class SharedLinkRepository implements ISharedLinkRepository {
@@ -93,7 +93,7 @@ export class SharedLinkRepository implements ISharedLinkRepository {
} }
@GenerateSql({ params: [DummyValue.UUID] }) @GenerateSql({ params: [DummyValue.UUID] })
getAll({ userId, albumId }: SharedLinkSearchOptions): Promise<SharedLinkEntity[]> { getAll(userId: string): Promise<SharedLinkEntity[]> {
return this.db return this.db
.selectFrom('shared_links') .selectFrom('shared_links')
.selectAll('shared_links') .selectAll('shared_links')
@@ -149,7 +149,6 @@ export class SharedLinkRepository implements ISharedLinkRepository {
) )
.select((eb) => eb.fn.toJson('album').as('album')) .select((eb) => eb.fn.toJson('album').as('album'))
.where((eb) => eb.or([eb('shared_links.type', '=', SharedLinkType.INDIVIDUAL), eb('album.id', 'is not', null)])) .where((eb) => eb.or([eb('shared_links.type', '=', SharedLinkType.INDIVIDUAL), eb('album.id', 'is not', null)]))
.$if(!!albumId, (eb) => eb.where('shared_links.albumId', '=', albumId!))
.orderBy('shared_links.createdAt', 'desc') .orderBy('shared_links.createdAt', 'desc')
.distinctOn(['shared_links.createdAt']) .distinctOn(['shared_links.createdAt'])
.execute() as unknown as Promise<SharedLinkEntity[]>; .execute() as unknown as Promise<SharedLinkEntity[]>;
@@ -2,8 +2,8 @@ import mockfs from 'mock-fs';
import { CrawlOptionsDto } from 'src/dtos/library.dto'; import { CrawlOptionsDto } from 'src/dtos/library.dto';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { StorageRepository } from 'src/repositories/storage.repository'; import { StorageRepository } from 'src/repositories/storage.repository';
import { ILoggingRepository, newLoggingRepositoryMock } from 'test/repositories/logger.repository.mock'; import { ILoggingRepository } from 'src/types';
import { Mocked } from 'vitest'; import { newLoggingRepositoryMock } from 'test/repositories/logger.repository.mock';
interface Test { interface Test {
test: string; test: string;
@@ -182,11 +182,11 @@ const tests: Test[] = [
describe(StorageRepository.name, () => { describe(StorageRepository.name, () => {
let sut: StorageRepository; let sut: StorageRepository;
let logger: Mocked<ILoggingRepository>; let logger: ILoggingRepository;
beforeEach(() => { beforeEach(() => {
logger = newLoggingRepositoryMock(); logger = newLoggingRepositoryMock();
sut = new StorageRepository(logger as ILoggingRepository as LoggingRepository); sut = new StorageRepository(logger as LoggingRepository);
}); });
afterEach(() => { afterEach(() => {
@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import archiver from 'archiver'; import archiver from 'archiver';
import chokidar, { WatchOptions } from 'chokidar'; import chokidar, { WatchOptions } from 'chokidar';
import { escapePath, glob, globStream } from 'fast-glob'; import { escapePath, glob, globStream } from 'fast-glob';
import { ErrnoException } from 'fast-glob/out/types';
import { constants, createReadStream, createWriteStream, existsSync, mkdirSync } from 'node:fs'; import { constants, createReadStream, createWriteStream, existsSync, mkdirSync } from 'node:fs';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
@@ -170,6 +171,19 @@ export class StorageRepository implements IStorageRepository {
}); });
} }
private errorHandler = (error: ErrnoException) => {
if (error.code === 'ENOENT') {
this.logger.warn(`Path ${error.path} does not exist, ignoring.`);
return true;
} else if (error.code === 'EACCES') {
this.logger.warn(`Permission denied for path ${error.path}, ignoring.`);
return true;
}
this.logger.error(`Error while walking path ${error.path}: ${error.message}`);
return false;
};
async *walk(walkOptions: WalkOptionsDto): AsyncGenerator<string[]> { async *walk(walkOptions: WalkOptionsDto): AsyncGenerator<string[]> {
const { pathsToCrawl, exclusionPatterns, includeHidden } = walkOptions; const { pathsToCrawl, exclusionPatterns, includeHidden } = walkOptions;
if (pathsToCrawl.length === 0) { if (pathsToCrawl.length === 0) {
@@ -185,6 +199,7 @@ export class StorageRepository implements IStorageRepository {
onlyFiles: true, onlyFiles: true,
dot: includeHidden, dot: includeHidden,
ignore: exclusionPatterns, ignore: exclusionPatterns,
errorHandler: this.errorHandler,
}); });
let batch: string[] = []; let batch: string[] = [];
@@ -5,11 +5,12 @@ import { readFile } from 'node:fs/promises';
import { DB, SystemMetadata as DbSystemMetadata } from 'src/db'; import { DB, SystemMetadata as DbSystemMetadata } from 'src/db';
import { GenerateSql } from 'src/decorators'; import { GenerateSql } from 'src/decorators';
import { SystemMetadata } from 'src/entities/system-metadata.entity'; import { SystemMetadata } from 'src/entities/system-metadata.entity';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
type Upsert = Insertable<DbSystemMetadata>; type Upsert = Insertable<DbSystemMetadata>;
@Injectable() @Injectable()
export class SystemMetadataRepository { export class SystemMetadataRepository implements ISystemMetadataRepository {
constructor(@InjectKysely() private db: Kysely<DB>) {} constructor(@InjectKysely() private db: Kysely<DB>) {}
@GenerateSql({ params: ['metadata_key'] }) @GenerateSql({ params: ['metadata_key'] })
-3
View File
@@ -1,3 +0,0 @@
import { UsersResolver } from 'src/resolvers/user.resolver';
export const resolvers = [UsersResolver];
-22
View File
@@ -1,22 +0,0 @@
import { Args, Int, Query, Resolver } from '@nestjs/graphql';
import { AuthDto } from 'src/dtos/auth.dto';
import { Auth, Authenticated } from 'src/middleware/auth.guard';
import { User } from 'src/models/user.model';
import { UserService } from 'src/services/user.service';
@Resolver(() => User)
export class UsersResolver {
constructor(private service: UserService) {}
@Authenticated()
@Query(() => User)
async user(@Args('id', { type: () => Int }) id: string) {
return this.service.get(id);
}
@Authenticated()
@Query(() => [User])
async users(@Auth() auth: AuthDto) {
return this.service.search(auth);
}
}
-35
View File
@@ -1,35 +0,0 @@
# ------------------------------------------------------
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
# ------------------------------------------------------
"""
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.
"""
scalar DateTime
type Query {
user(id: Int!): User!
users: [User!]!
}
type User {
avatarColor: UserAvatarColor!
email: String!
id: String!
name: String!
profileChangedAt: DateTime
profileImagePath: String!
}
enum UserAvatarColor {
AMBER
BLUE
GRAY
GREEN
ORANGE
PINK
PRIMARY
PURPLE
RED
YELLOW
}
+37 -32
View File
@@ -1,16 +1,21 @@
import { BadRequestException } from '@nestjs/common'; import { BadRequestException } from '@nestjs/common';
import { ReactionType } from 'src/dtos/activity.dto'; import { ReactionType } from 'src/dtos/activity.dto';
import { ActivityService } from 'src/services/activity.service'; import { ActivityService } from 'src/services/activity.service';
import { IActivityRepository } from 'src/types';
import { activityStub } from 'test/fixtures/activity.stub'; import { activityStub } from 'test/fixtures/activity.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { IAccessRepositoryMock } from 'test/repositories/access.repository.mock';
import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
describe(ActivityService.name, () => { describe(ActivityService.name, () => {
let sut: ActivityService; let sut: ActivityService;
let mocks: ServiceMocks;
let accessMock: IAccessRepositoryMock;
let activityMock: Mocked<IActivityRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(ActivityService)); ({ sut, accessMock, activityMock } = newTestService(ActivityService));
}); });
it('should work', () => { it('should work', () => {
@@ -19,12 +24,12 @@ describe(ActivityService.name, () => {
describe('getAll', () => { describe('getAll', () => {
it('should get all', async () => { it('should get all', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.search.mockResolvedValue([]); activityMock.search.mockResolvedValue([]);
await expect(sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id' })).resolves.toEqual([]); await expect(sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id' })).resolves.toEqual([]);
expect(mocks.activity.search).toHaveBeenCalledWith({ expect(activityMock.search).toHaveBeenCalledWith({
assetId: 'asset-id', assetId: 'asset-id',
albumId: 'album-id', albumId: 'album-id',
isLiked: undefined, isLiked: undefined,
@@ -32,14 +37,14 @@ describe(ActivityService.name, () => {
}); });
it('should filter by type=like', async () => { it('should filter by type=like', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.search.mockResolvedValue([]); activityMock.search.mockResolvedValue([]);
await expect( await expect(
sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id', type: ReactionType.LIKE }), sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id', type: ReactionType.LIKE }),
).resolves.toEqual([]); ).resolves.toEqual([]);
expect(mocks.activity.search).toHaveBeenCalledWith({ expect(activityMock.search).toHaveBeenCalledWith({
assetId: 'asset-id', assetId: 'asset-id',
albumId: 'album-id', albumId: 'album-id',
isLiked: true, isLiked: true,
@@ -47,14 +52,14 @@ describe(ActivityService.name, () => {
}); });
it('should filter by type=comment', async () => { it('should filter by type=comment', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.search.mockResolvedValue([]); activityMock.search.mockResolvedValue([]);
await expect( await expect(
sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id', type: ReactionType.COMMENT }), sut.getAll(authStub.admin, { assetId: 'asset-id', albumId: 'album-id', type: ReactionType.COMMENT }),
).resolves.toEqual([]); ).resolves.toEqual([]);
expect(mocks.activity.search).toHaveBeenCalledWith({ expect(activityMock.search).toHaveBeenCalledWith({
assetId: 'asset-id', assetId: 'asset-id',
albumId: 'album-id', albumId: 'album-id',
isLiked: false, isLiked: false,
@@ -64,8 +69,8 @@ describe(ActivityService.name, () => {
describe('getStatistics', () => { describe('getStatistics', () => {
it('should get the comment count', async () => { it('should get the comment count', async () => {
mocks.activity.getStatistics.mockResolvedValue(1); activityMock.getStatistics.mockResolvedValue(1);
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([activityStub.oneComment.albumId])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([activityStub.oneComment.albumId]));
await expect( await expect(
sut.getStatistics(authStub.admin, { sut.getStatistics(authStub.admin, {
assetId: 'asset-id', assetId: 'asset-id',
@@ -88,8 +93,8 @@ describe(ActivityService.name, () => {
}); });
it('should create a comment', async () => { it('should create a comment', async () => {
mocks.access.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id'])); accessMock.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.create.mockResolvedValue(activityStub.oneComment); activityMock.create.mockResolvedValue(activityStub.oneComment);
await sut.create(authStub.admin, { await sut.create(authStub.admin, {
albumId: 'album-id', albumId: 'album-id',
@@ -98,7 +103,7 @@ describe(ActivityService.name, () => {
comment: 'comment', comment: 'comment',
}); });
expect(mocks.activity.create).toHaveBeenCalledWith({ expect(activityMock.create).toHaveBeenCalledWith({
userId: 'admin_id', userId: 'admin_id',
albumId: 'album-id', albumId: 'album-id',
assetId: 'asset-id', assetId: 'asset-id',
@@ -108,8 +113,8 @@ describe(ActivityService.name, () => {
}); });
it('should fail because activity is disabled for the album', async () => { it('should fail because activity is disabled for the album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.create.mockResolvedValue(activityStub.oneComment); activityMock.create.mockResolvedValue(activityStub.oneComment);
await expect( await expect(
sut.create(authStub.admin, { sut.create(authStub.admin, {
@@ -122,9 +127,9 @@ describe(ActivityService.name, () => {
}); });
it('should create a like', async () => { it('should create a like', async () => {
mocks.access.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id'])); accessMock.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.create.mockResolvedValue(activityStub.liked); activityMock.create.mockResolvedValue(activityStub.liked);
mocks.activity.search.mockResolvedValue([]); activityMock.search.mockResolvedValue([]);
await sut.create(authStub.admin, { await sut.create(authStub.admin, {
albumId: 'album-id', albumId: 'album-id',
@@ -132,7 +137,7 @@ describe(ActivityService.name, () => {
type: ReactionType.LIKE, type: ReactionType.LIKE,
}); });
expect(mocks.activity.create).toHaveBeenCalledWith({ expect(activityMock.create).toHaveBeenCalledWith({
userId: 'admin_id', userId: 'admin_id',
albumId: 'album-id', albumId: 'album-id',
assetId: 'asset-id', assetId: 'asset-id',
@@ -141,9 +146,9 @@ describe(ActivityService.name, () => {
}); });
it('should skip if like exists', async () => { it('should skip if like exists', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
mocks.access.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id'])); accessMock.activity.checkCreateAccess.mockResolvedValue(new Set(['album-id']));
mocks.activity.search.mockResolvedValue([activityStub.liked]); activityMock.search.mockResolvedValue([activityStub.liked]);
await sut.create(authStub.admin, { await sut.create(authStub.admin, {
albumId: 'album-id', albumId: 'album-id',
@@ -151,26 +156,26 @@ describe(ActivityService.name, () => {
type: ReactionType.LIKE, type: ReactionType.LIKE,
}); });
expect(mocks.activity.create).not.toHaveBeenCalled(); expect(activityMock.create).not.toHaveBeenCalled();
}); });
}); });
describe('delete', () => { describe('delete', () => {
it('should require access', async () => { it('should require access', async () => {
await expect(sut.delete(authStub.admin, activityStub.oneComment.id)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.delete(authStub.admin, activityStub.oneComment.id)).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.activity.delete).not.toHaveBeenCalled(); expect(activityMock.delete).not.toHaveBeenCalled();
}); });
it('should let the activity owner delete a comment', async () => { it('should let the activity owner delete a comment', async () => {
mocks.access.activity.checkOwnerAccess.mockResolvedValue(new Set(['activity-id'])); accessMock.activity.checkOwnerAccess.mockResolvedValue(new Set(['activity-id']));
await sut.delete(authStub.admin, 'activity-id'); await sut.delete(authStub.admin, 'activity-id');
expect(mocks.activity.delete).toHaveBeenCalledWith('activity-id'); expect(activityMock.delete).toHaveBeenCalledWith('activity-id');
}); });
it('should let the album owner delete a comment', async () => { it('should let the album owner delete a comment', async () => {
mocks.access.activity.checkAlbumOwnerAccess.mockResolvedValue(new Set(['activity-id'])); accessMock.activity.checkAlbumOwnerAccess.mockResolvedValue(new Set(['activity-id']));
await sut.delete(authStub.admin, 'activity-id'); await sut.delete(authStub.admin, 'activity-id');
expect(mocks.activity.delete).toHaveBeenCalledWith('activity-id'); expect(activityMock.delete).toHaveBeenCalledWith('activity-id');
}); });
}); });
}); });
+195 -184
View File
@@ -2,18 +2,29 @@ import { BadRequestException } from '@nestjs/common';
import _ from 'lodash'; import _ from 'lodash';
import { BulkIdErrorReason } from 'src/dtos/asset-ids.response.dto'; import { BulkIdErrorReason } from 'src/dtos/asset-ids.response.dto';
import { AlbumUserRole } from 'src/enum'; import { AlbumUserRole } from 'src/enum';
import { IAlbumRepository } from 'src/interfaces/album.interface';
import { IEventRepository } from 'src/interfaces/event.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { AlbumService } from 'src/services/album.service'; import { AlbumService } from 'src/services/album.service';
import { IAlbumUserRepository } from 'src/types';
import { albumStub } from 'test/fixtures/album.stub'; import { albumStub } from 'test/fixtures/album.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { userStub } from 'test/fixtures/user.stub'; import { userStub } from 'test/fixtures/user.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { IAccessRepositoryMock } from 'test/repositories/access.repository.mock';
import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
describe(AlbumService.name, () => { describe(AlbumService.name, () => {
let sut: AlbumService; let sut: AlbumService;
let mocks: ServiceMocks;
let accessMock: IAccessRepositoryMock;
let albumMock: Mocked<IAlbumRepository>;
let albumUserMock: Mocked<IAlbumUserRepository>;
let eventMock: Mocked<IEventRepository>;
let userMock: Mocked<IUserRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(AlbumService)); ({ sut, accessMock, albumMock, albumUserMock, eventMock, userMock } = newTestService(AlbumService));
}); });
it('should work', () => { it('should work', () => {
@@ -22,25 +33,25 @@ describe(AlbumService.name, () => {
describe('getStatistics', () => { describe('getStatistics', () => {
it('should get the album count', async () => { it('should get the album count', async () => {
mocks.album.getOwned.mockResolvedValue([]); albumMock.getOwned.mockResolvedValue([]);
mocks.album.getShared.mockResolvedValue([]); albumMock.getShared.mockResolvedValue([]);
mocks.album.getNotShared.mockResolvedValue([]); albumMock.getNotShared.mockResolvedValue([]);
await expect(sut.getStatistics(authStub.admin)).resolves.toEqual({ await expect(sut.getStatistics(authStub.admin)).resolves.toEqual({
owned: 0, owned: 0,
shared: 0, shared: 0,
notShared: 0, notShared: 0,
}); });
expect(mocks.album.getOwned).toHaveBeenCalledWith(authStub.admin.user.id); expect(albumMock.getOwned).toHaveBeenCalledWith(authStub.admin.user.id);
expect(mocks.album.getShared).toHaveBeenCalledWith(authStub.admin.user.id); expect(albumMock.getShared).toHaveBeenCalledWith(authStub.admin.user.id);
expect(mocks.album.getNotShared).toHaveBeenCalledWith(authStub.admin.user.id); expect(albumMock.getNotShared).toHaveBeenCalledWith(authStub.admin.user.id);
}); });
}); });
describe('getAll', () => { describe('getAll', () => {
it('gets list of albums for auth user', async () => { it('gets list of albums for auth user', async () => {
mocks.album.getOwned.mockResolvedValue([albumStub.empty, albumStub.sharedWithUser]); albumMock.getOwned.mockResolvedValue([albumStub.empty, albumStub.sharedWithUser]);
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ albumId: albumStub.empty.id, assetCount: 0, startDate: null, endDate: null }, { albumId: albumStub.empty.id, assetCount: 0, startDate: null, endDate: null },
{ albumId: albumStub.sharedWithUser.id, assetCount: 0, startDate: null, endDate: null }, { albumId: albumStub.sharedWithUser.id, assetCount: 0, startDate: null, endDate: null },
]); ]);
@@ -52,8 +63,8 @@ describe(AlbumService.name, () => {
}); });
it('gets list of albums that have a specific asset', async () => { it('gets list of albums that have a specific asset', async () => {
mocks.album.getByAssetId.mockResolvedValue([albumStub.oneAsset]); albumMock.getByAssetId.mockResolvedValue([albumStub.oneAsset]);
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ {
albumId: albumStub.oneAsset.id, albumId: albumStub.oneAsset.id,
assetCount: 1, assetCount: 1,
@@ -65,37 +76,37 @@ describe(AlbumService.name, () => {
const result = await sut.getAll(authStub.admin, { assetId: albumStub.oneAsset.id }); const result = await sut.getAll(authStub.admin, { assetId: albumStub.oneAsset.id });
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
expect(result[0].id).toEqual(albumStub.oneAsset.id); expect(result[0].id).toEqual(albumStub.oneAsset.id);
expect(mocks.album.getByAssetId).toHaveBeenCalledTimes(1); expect(albumMock.getByAssetId).toHaveBeenCalledTimes(1);
}); });
it('gets list of albums that are shared', async () => { it('gets list of albums that are shared', async () => {
mocks.album.getShared.mockResolvedValue([albumStub.sharedWithUser]); albumMock.getShared.mockResolvedValue([albumStub.sharedWithUser]);
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ albumId: albumStub.sharedWithUser.id, assetCount: 0, startDate: null, endDate: null }, { albumId: albumStub.sharedWithUser.id, assetCount: 0, startDate: null, endDate: null },
]); ]);
const result = await sut.getAll(authStub.admin, { shared: true }); const result = await sut.getAll(authStub.admin, { shared: true });
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
expect(result[0].id).toEqual(albumStub.sharedWithUser.id); expect(result[0].id).toEqual(albumStub.sharedWithUser.id);
expect(mocks.album.getShared).toHaveBeenCalledTimes(1); expect(albumMock.getShared).toHaveBeenCalledTimes(1);
}); });
it('gets list of albums that are NOT shared', async () => { it('gets list of albums that are NOT shared', async () => {
mocks.album.getNotShared.mockResolvedValue([albumStub.empty]); albumMock.getNotShared.mockResolvedValue([albumStub.empty]);
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ albumId: albumStub.empty.id, assetCount: 0, startDate: null, endDate: null }, { albumId: albumStub.empty.id, assetCount: 0, startDate: null, endDate: null },
]); ]);
const result = await sut.getAll(authStub.admin, { shared: false }); const result = await sut.getAll(authStub.admin, { shared: false });
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
expect(result[0].id).toEqual(albumStub.empty.id); expect(result[0].id).toEqual(albumStub.empty.id);
expect(mocks.album.getNotShared).toHaveBeenCalledTimes(1); expect(albumMock.getNotShared).toHaveBeenCalledTimes(1);
}); });
}); });
it('counts assets correctly', async () => { it('counts assets correctly', async () => {
mocks.album.getOwned.mockResolvedValue([albumStub.oneAsset]); albumMock.getOwned.mockResolvedValue([albumStub.oneAsset]);
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ {
albumId: albumStub.oneAsset.id, albumId: albumStub.oneAsset.id,
assetCount: 1, assetCount: 1,
@@ -108,14 +119,14 @@ describe(AlbumService.name, () => {
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
expect(result[0].assetCount).toEqual(1); expect(result[0].assetCount).toEqual(1);
expect(mocks.album.getOwned).toHaveBeenCalledTimes(1); expect(albumMock.getOwned).toHaveBeenCalledTimes(1);
}); });
describe('create', () => { describe('create', () => {
it('creates album', async () => { it('creates album', async () => {
mocks.album.create.mockResolvedValue(albumStub.empty); albumMock.create.mockResolvedValue(albumStub.empty);
mocks.user.get.mockResolvedValue(userStub.user1); userMock.get.mockResolvedValue(userStub.user1);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['123'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['123']));
await sut.create(authStub.admin, { await sut.create(authStub.admin, {
albumName: 'Empty album', albumName: 'Empty album',
@@ -124,7 +135,7 @@ describe(AlbumService.name, () => {
assetIds: ['123'], assetIds: ['123'],
}); });
expect(mocks.album.create).toHaveBeenCalledWith( expect(albumMock.create).toHaveBeenCalledWith(
{ {
ownerId: authStub.admin.user.id, ownerId: authStub.admin.user.id,
albumName: albumStub.empty.albumName, albumName: albumStub.empty.albumName,
@@ -136,30 +147,30 @@ describe(AlbumService.name, () => {
[{ userId: 'user-id', role: AlbumUserRole.EDITOR }], [{ userId: 'user-id', role: AlbumUserRole.EDITOR }],
); );
expect(mocks.user.get).toHaveBeenCalledWith('user-id', {}); expect(userMock.get).toHaveBeenCalledWith('user-id', {});
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['123'])); expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['123']));
expect(mocks.event.emit).toHaveBeenCalledWith('album.invite', { expect(eventMock.emit).toHaveBeenCalledWith('album.invite', {
id: albumStub.empty.id, id: albumStub.empty.id,
userId: 'user-id', userId: 'user-id',
}); });
}); });
it('should require valid userIds', async () => { it('should require valid userIds', async () => {
mocks.user.get.mockResolvedValue(void 0); userMock.get.mockResolvedValue(void 0);
await expect( await expect(
sut.create(authStub.admin, { sut.create(authStub.admin, {
albumName: 'Empty album', albumName: 'Empty album',
albumUsers: [{ userId: 'user-3', role: AlbumUserRole.EDITOR }], albumUsers: [{ userId: 'user-3', role: AlbumUserRole.EDITOR }],
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.user.get).toHaveBeenCalledWith('user-3', {}); expect(userMock.get).toHaveBeenCalledWith('user-3', {});
expect(mocks.album.create).not.toHaveBeenCalled(); expect(albumMock.create).not.toHaveBeenCalled();
}); });
it('should only add assets the user is allowed to access', async () => { it('should only add assets the user is allowed to access', async () => {
mocks.user.get.mockResolvedValue(userStub.user1); userMock.get.mockResolvedValue(userStub.user1);
mocks.album.create.mockResolvedValue(albumStub.oneAsset); albumMock.create.mockResolvedValue(albumStub.oneAsset);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.create(authStub.admin, { await sut.create(authStub.admin, {
albumName: 'Test album', albumName: 'Test album',
@@ -167,7 +178,7 @@ describe(AlbumService.name, () => {
assetIds: ['asset-1', 'asset-2'], assetIds: ['asset-1', 'asset-2'],
}); });
expect(mocks.album.create).toHaveBeenCalledWith( expect(albumMock.create).toHaveBeenCalledWith(
{ {
ownerId: authStub.admin.user.id, ownerId: authStub.admin.user.id,
albumName: 'Test album', albumName: 'Test album',
@@ -178,7 +189,7 @@ describe(AlbumService.name, () => {
['asset-1'], ['asset-1'],
[], [],
); );
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set(['asset-1', 'asset-2']), new Set(['asset-1', 'asset-2']),
); );
@@ -187,7 +198,7 @@ describe(AlbumService.name, () => {
describe('update', () => { describe('update', () => {
it('should prevent updating an album that does not exist', async () => { it('should prevent updating an album that does not exist', async () => {
mocks.album.getById.mockResolvedValue(void 0); albumMock.getById.mockResolvedValue(void 0);
await expect( await expect(
sut.update(authStub.user1, 'invalid-id', { sut.update(authStub.user1, 'invalid-id', {
@@ -195,7 +206,7 @@ describe(AlbumService.name, () => {
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should prevent updating a not owned album (shared with auth user)', async () => { it('should prevent updating a not owned album (shared with auth user)', async () => {
@@ -207,10 +218,10 @@ describe(AlbumService.name, () => {
}); });
it('should require a valid thumbnail asset id', async () => { it('should require a valid thumbnail asset id', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-4'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-4']));
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.album.update.mockResolvedValue(albumStub.oneAsset); albumMock.update.mockResolvedValue(albumStub.oneAsset);
mocks.album.getAssetIds.mockResolvedValue(new Set()); albumMock.getAssetIds.mockResolvedValue(new Set());
await expect( await expect(
sut.update(authStub.admin, albumStub.oneAsset.id, { sut.update(authStub.admin, albumStub.oneAsset.id, {
@@ -218,22 +229,22 @@ describe(AlbumService.name, () => {
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.getAssetIds).toHaveBeenCalledWith('album-4', ['not-in-album']); expect(albumMock.getAssetIds).toHaveBeenCalledWith('album-4', ['not-in-album']);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should allow the owner to update the album', async () => { it('should allow the owner to update the album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-4'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-4']));
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.album.update.mockResolvedValue(albumStub.oneAsset); albumMock.update.mockResolvedValue(albumStub.oneAsset);
await sut.update(authStub.admin, albumStub.oneAsset.id, { await sut.update(authStub.admin, albumStub.oneAsset.id, {
albumName: 'new album name', albumName: 'new album name',
}); });
expect(mocks.album.update).toHaveBeenCalledTimes(1); expect(albumMock.update).toHaveBeenCalledTimes(1);
expect(mocks.album.update).toHaveBeenCalledWith('album-4', { expect(albumMock.update).toHaveBeenCalledWith('album-4', {
id: 'album-4', id: 'album-4',
albumName: 'new album name', albumName: 'new album name',
}); });
@@ -242,33 +253,33 @@ describe(AlbumService.name, () => {
describe('delete', () => { describe('delete', () => {
it('should throw an error for an album not found', async () => { it('should throw an error for an album not found', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set()); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set());
await expect(sut.delete(authStub.admin, albumStub.sharedWithAdmin.id)).rejects.toBeInstanceOf( await expect(sut.delete(authStub.admin, albumStub.sharedWithAdmin.id)).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.album.delete).not.toHaveBeenCalled(); expect(albumMock.delete).not.toHaveBeenCalled();
}); });
it('should not let a shared user delete the album', async () => { it('should not let a shared user delete the album', async () => {
mocks.album.getById.mockResolvedValue(albumStub.sharedWithAdmin); albumMock.getById.mockResolvedValue(albumStub.sharedWithAdmin);
await expect(sut.delete(authStub.admin, albumStub.sharedWithAdmin.id)).rejects.toBeInstanceOf( await expect(sut.delete(authStub.admin, albumStub.sharedWithAdmin.id)).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.album.delete).not.toHaveBeenCalled(); expect(albumMock.delete).not.toHaveBeenCalled();
}); });
it('should let the owner delete an album', async () => { it('should let the owner delete an album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.empty.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.empty.id]));
mocks.album.getById.mockResolvedValue(albumStub.empty); albumMock.getById.mockResolvedValue(albumStub.empty);
await sut.delete(authStub.admin, albumStub.empty.id); await sut.delete(authStub.admin, albumStub.empty.id);
expect(mocks.album.delete).toHaveBeenCalledTimes(1); expect(albumMock.delete).toHaveBeenCalledTimes(1);
expect(mocks.album.delete).toHaveBeenCalledWith(albumStub.empty.id); expect(albumMock.delete).toHaveBeenCalledWith(albumStub.empty.id);
}); });
}); });
@@ -277,47 +288,47 @@ describe(AlbumService.name, () => {
await expect( await expect(
sut.addUsers(authStub.admin, albumStub.sharedWithAdmin.id, { albumUsers: [{ userId: 'user-1' }] }), sut.addUsers(authStub.admin, albumStub.sharedWithAdmin.id, { albumUsers: [{ userId: 'user-1' }] }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should throw an error if the userId is already added', async () => { it('should throw an error if the userId is already added', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id]));
mocks.album.getById.mockResolvedValue(albumStub.sharedWithAdmin); albumMock.getById.mockResolvedValue(albumStub.sharedWithAdmin);
await expect( await expect(
sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, {
albumUsers: [{ userId: authStub.admin.user.id }], albumUsers: [{ userId: authStub.admin.user.id }],
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should throw an error if the userId does not exist', async () => { it('should throw an error if the userId does not exist', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id]));
mocks.album.getById.mockResolvedValue(albumStub.sharedWithAdmin); albumMock.getById.mockResolvedValue(albumStub.sharedWithAdmin);
mocks.user.get.mockResolvedValue(void 0); userMock.get.mockResolvedValue(void 0);
await expect( await expect(
sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { albumUsers: [{ userId: 'user-3' }] }), sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { albumUsers: [{ userId: 'user-3' }] }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should throw an error if the userId is the ownerId', async () => { it('should throw an error if the userId is the ownerId', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id]));
mocks.album.getById.mockResolvedValue(albumStub.sharedWithAdmin); albumMock.getById.mockResolvedValue(albumStub.sharedWithAdmin);
await expect( await expect(
sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, {
albumUsers: [{ userId: userStub.user1.id }], albumUsers: [{ userId: userStub.user1.id }],
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should add valid shared users', async () => { it('should add valid shared users', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id]));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithAdmin)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithAdmin));
mocks.album.update.mockResolvedValue(albumStub.sharedWithAdmin); albumMock.update.mockResolvedValue(albumStub.sharedWithAdmin);
mocks.user.get.mockResolvedValue(userStub.user2); userMock.get.mockResolvedValue(userStub.user2);
mocks.albumUser.create.mockResolvedValue({ albumUserMock.create.mockResolvedValue({
usersId: userStub.user2.id, usersId: userStub.user2.id,
albumsId: albumStub.sharedWithAdmin.id, albumsId: albumStub.sharedWithAdmin.id,
role: AlbumUserRole.EDITOR, role: AlbumUserRole.EDITOR,
@@ -325,11 +336,11 @@ describe(AlbumService.name, () => {
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, {
albumUsers: [{ userId: authStub.user2.user.id }], albumUsers: [{ userId: authStub.user2.user.id }],
}); });
expect(mocks.albumUser.create).toHaveBeenCalledWith({ expect(albumUserMock.create).toHaveBeenCalledWith({
usersId: authStub.user2.user.id, usersId: authStub.user2.user.id,
albumsId: albumStub.sharedWithAdmin.id, albumsId: albumStub.sharedWithAdmin.id,
}); });
expect(mocks.event.emit).toHaveBeenCalledWith('album.invite', { expect(eventMock.emit).toHaveBeenCalledWith('album.invite', {
id: albumStub.sharedWithAdmin.id, id: albumStub.sharedWithAdmin.id,
userId: userStub.user2.id, userId: userStub.user2.id,
}); });
@@ -338,94 +349,94 @@ describe(AlbumService.name, () => {
describe('removeUser', () => { describe('removeUser', () => {
it('should require a valid album id', async () => { it('should require a valid album id', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-1'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-1']));
mocks.album.getById.mockResolvedValue(void 0); albumMock.getById.mockResolvedValue(void 0);
await expect(sut.removeUser(authStub.admin, 'album-1', 'user-1')).rejects.toBeInstanceOf(BadRequestException); await expect(sut.removeUser(authStub.admin, 'album-1', 'user-1')).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should remove a shared user from an owned album', async () => { it('should remove a shared user from an owned album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithUser.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithUser.id]));
mocks.album.getById.mockResolvedValue(albumStub.sharedWithUser); albumMock.getById.mockResolvedValue(albumStub.sharedWithUser);
await expect( await expect(
sut.removeUser(authStub.admin, albumStub.sharedWithUser.id, userStub.user1.id), sut.removeUser(authStub.admin, albumStub.sharedWithUser.id, userStub.user1.id),
).resolves.toBeUndefined(); ).resolves.toBeUndefined();
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1); expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(mocks.albumUser.delete).toHaveBeenCalledWith({ expect(albumUserMock.delete).toHaveBeenCalledWith({
albumsId: albumStub.sharedWithUser.id, albumsId: albumStub.sharedWithUser.id,
usersId: userStub.user1.id, usersId: userStub.user1.id,
}); });
expect(mocks.album.getById).toHaveBeenCalledWith(albumStub.sharedWithUser.id, { withAssets: false }); expect(albumMock.getById).toHaveBeenCalledWith(albumStub.sharedWithUser.id, { withAssets: false });
}); });
it('should prevent removing a shared user from a not-owned album (shared with auth user)', async () => { it('should prevent removing a shared user from a not-owned album (shared with auth user)', async () => {
mocks.album.getById.mockResolvedValue(albumStub.sharedWithMultiple); albumMock.getById.mockResolvedValue(albumStub.sharedWithMultiple);
await expect( await expect(
sut.removeUser(authStub.user1, albumStub.sharedWithMultiple.id, authStub.user2.user.id), sut.removeUser(authStub.user1, albumStub.sharedWithMultiple.id, authStub.user2.user.id),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.albumUser.delete).not.toHaveBeenCalled(); expect(albumUserMock.delete).not.toHaveBeenCalled();
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalledWith( expect(accessMock.album.checkOwnerAccess).toHaveBeenCalledWith(
authStub.user1.user.id, authStub.user1.user.id,
new Set([albumStub.sharedWithMultiple.id]), new Set([albumStub.sharedWithMultiple.id]),
); );
}); });
it('should allow a shared user to remove themselves', async () => { it('should allow a shared user to remove themselves', async () => {
mocks.album.getById.mockResolvedValue(albumStub.sharedWithUser); albumMock.getById.mockResolvedValue(albumStub.sharedWithUser);
await sut.removeUser(authStub.user1, albumStub.sharedWithUser.id, authStub.user1.user.id); await sut.removeUser(authStub.user1, albumStub.sharedWithUser.id, authStub.user1.user.id);
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1); expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(mocks.albumUser.delete).toHaveBeenCalledWith({ expect(albumUserMock.delete).toHaveBeenCalledWith({
albumsId: albumStub.sharedWithUser.id, albumsId: albumStub.sharedWithUser.id,
usersId: authStub.user1.user.id, usersId: authStub.user1.user.id,
}); });
}); });
it('should allow a shared user to remove themselves using "me"', async () => { it('should allow a shared user to remove themselves using "me"', async () => {
mocks.album.getById.mockResolvedValue(albumStub.sharedWithUser); albumMock.getById.mockResolvedValue(albumStub.sharedWithUser);
await sut.removeUser(authStub.user1, albumStub.sharedWithUser.id, 'me'); await sut.removeUser(authStub.user1, albumStub.sharedWithUser.id, 'me');
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1); expect(albumUserMock.delete).toHaveBeenCalledTimes(1);
expect(mocks.albumUser.delete).toHaveBeenCalledWith({ expect(albumUserMock.delete).toHaveBeenCalledWith({
albumsId: albumStub.sharedWithUser.id, albumsId: albumStub.sharedWithUser.id,
usersId: authStub.user1.user.id, usersId: authStub.user1.user.id,
}); });
}); });
it('should not allow the owner to be removed', async () => { it('should not allow the owner to be removed', async () => {
mocks.album.getById.mockResolvedValue(albumStub.empty); albumMock.getById.mockResolvedValue(albumStub.empty);
await expect(sut.removeUser(authStub.admin, albumStub.empty.id, authStub.admin.user.id)).rejects.toBeInstanceOf( await expect(sut.removeUser(authStub.admin, albumStub.empty.id, authStub.admin.user.id)).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should throw an error for a user not in the album', async () => { it('should throw an error for a user not in the album', async () => {
mocks.album.getById.mockResolvedValue(albumStub.empty); albumMock.getById.mockResolvedValue(albumStub.empty);
await expect(sut.removeUser(authStub.admin, albumStub.empty.id, 'user-3')).rejects.toBeInstanceOf( await expect(sut.removeUser(authStub.admin, albumStub.empty.id, 'user-3')).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
}); });
describe('updateUser', () => { describe('updateUser', () => {
it('should update user role', async () => { it('should update user role', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.sharedWithAdmin.id]));
await sut.updateUser(authStub.user1, albumStub.sharedWithAdmin.id, userStub.admin.id, { await sut.updateUser(authStub.user1, albumStub.sharedWithAdmin.id, userStub.admin.id, {
role: AlbumUserRole.EDITOR, role: AlbumUserRole.EDITOR,
}); });
expect(mocks.albumUser.update).toHaveBeenCalledWith( expect(albumUserMock.update).toHaveBeenCalledWith(
{ albumsId: albumStub.sharedWithAdmin.id, usersId: userStub.admin.id }, { albumsId: albumStub.sharedWithAdmin.id, usersId: userStub.admin.id },
{ role: AlbumUserRole.EDITOR }, { role: AlbumUserRole.EDITOR },
); );
@@ -434,9 +445,9 @@ describe(AlbumService.name, () => {
describe('getAlbumInfo', () => { describe('getAlbumInfo', () => {
it('should get a shared album', async () => { it('should get a shared album', async () => {
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.oneAsset.id])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set([albumStub.oneAsset.id]));
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ {
albumId: albumStub.oneAsset.id, albumId: albumStub.oneAsset.id,
assetCount: 1, assetCount: 1,
@@ -447,17 +458,17 @@ describe(AlbumService.name, () => {
await sut.get(authStub.admin, albumStub.oneAsset.id, {}); await sut.get(authStub.admin, albumStub.oneAsset.id, {});
expect(mocks.album.getById).toHaveBeenCalledWith(albumStub.oneAsset.id, { withAssets: true }); expect(albumMock.getById).toHaveBeenCalledWith(albumStub.oneAsset.id, { withAssets: true });
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalledWith( expect(accessMock.album.checkOwnerAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set([albumStub.oneAsset.id]), new Set([albumStub.oneAsset.id]),
); );
}); });
it('should get a shared album via a shared link', async () => { it('should get a shared album via a shared link', async () => {
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.access.album.checkSharedLinkAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkSharedLinkAccess.mockResolvedValue(new Set(['album-123']));
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ {
albumId: albumStub.oneAsset.id, albumId: albumStub.oneAsset.id,
assetCount: 1, assetCount: 1,
@@ -468,17 +479,17 @@ describe(AlbumService.name, () => {
await sut.get(authStub.adminSharedLink, 'album-123', {}); await sut.get(authStub.adminSharedLink, 'album-123', {});
expect(mocks.album.getById).toHaveBeenCalledWith('album-123', { withAssets: true }); expect(albumMock.getById).toHaveBeenCalledWith('album-123', { withAssets: true });
expect(mocks.access.album.checkSharedLinkAccess).toHaveBeenCalledWith( expect(accessMock.album.checkSharedLinkAccess).toHaveBeenCalledWith(
authStub.adminSharedLink.sharedLink?.id, authStub.adminSharedLink.sharedLink?.id,
new Set(['album-123']), new Set(['album-123']),
); );
}); });
it('should get a shared album via shared with user', async () => { it('should get a shared album via shared with user', async () => {
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.access.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123']));
mocks.album.getMetadataForIds.mockResolvedValue([ albumMock.getMetadataForIds.mockResolvedValue([
{ {
albumId: albumStub.oneAsset.id, albumId: albumStub.oneAsset.id,
assetCount: 1, assetCount: 1,
@@ -489,8 +500,8 @@ describe(AlbumService.name, () => {
await sut.get(authStub.user1, 'album-123', {}); await sut.get(authStub.user1, 'album-123', {});
expect(mocks.album.getById).toHaveBeenCalledWith('album-123', { withAssets: true }); expect(albumMock.getById).toHaveBeenCalledWith('album-123', { withAssets: true });
expect(mocks.access.album.checkSharedAlbumAccess).toHaveBeenCalledWith( expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
authStub.user1.user.id, authStub.user1.user.id,
new Set(['album-123']), new Set(['album-123']),
AlbumUserRole.VIEWER, AlbumUserRole.VIEWER,
@@ -500,8 +511,8 @@ describe(AlbumService.name, () => {
it('should throw an error for no access', async () => { it('should throw an error for no access', async () => {
await expect(sut.get(authStub.admin, 'album-123', {})).rejects.toBeInstanceOf(BadRequestException); await expect(sut.get(authStub.admin, 'album-123', {})).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-123'])); expect(accessMock.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-123']));
expect(mocks.access.album.checkSharedAlbumAccess).toHaveBeenCalledWith( expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set(['album-123']), new Set(['album-123']),
AlbumUserRole.VIEWER, AlbumUserRole.VIEWER,
@@ -511,10 +522,10 @@ describe(AlbumService.name, () => {
describe('addAssets', () => { describe('addAssets', () => {
it('should allow the owner to add assets', async () => { it('should allow the owner to add assets', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect( await expect(
sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
@@ -524,37 +535,37 @@ describe(AlbumService.name, () => {
{ success: true, id: 'asset-3' }, { success: true, id: 'asset-3' },
]); ]);
expect(mocks.album.update).toHaveBeenCalledWith('album-123', { expect(albumMock.update).toHaveBeenCalledWith('album-123', {
id: 'album-123', id: 'album-123',
updatedAt: expect.any(Date), updatedAt: expect.any(Date),
albumThumbnailAssetId: 'asset-1', albumThumbnailAssetId: 'asset-1',
}); });
expect(mocks.album.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']); expect(albumMock.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']);
}); });
it('should not set the thumbnail if the album has one already', async () => { it('should not set the thumbnail if the album has one already', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.album.getById.mockResolvedValue(_.cloneDeep({ ...albumStub.empty, albumThumbnailAssetId: 'asset-id' })); albumMock.getById.mockResolvedValue(_.cloneDeep({ ...albumStub.empty, albumThumbnailAssetId: 'asset-id' }));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([ await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([
{ success: true, id: 'asset-1' }, { success: true, id: 'asset-1' },
]); ]);
expect(mocks.album.update).toHaveBeenCalledWith('album-123', { expect(albumMock.update).toHaveBeenCalledWith('album-123', {
id: 'album-123', id: 'album-123',
updatedAt: expect.any(Date), updatedAt: expect.any(Date),
albumThumbnailAssetId: 'asset-id', albumThumbnailAssetId: 'asset-id',
}); });
expect(mocks.album.addAssetIds).toHaveBeenCalled(); expect(albumMock.addAssetIds).toHaveBeenCalled();
}); });
it('should allow a shared user to add assets', async () => { it('should allow a shared user to add assets', async () => {
mocks.access.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkSharedAlbumAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithUser)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithUser));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect( await expect(
sut.addAssets(authStub.user1, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.user1, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
@@ -564,34 +575,34 @@ describe(AlbumService.name, () => {
{ success: true, id: 'asset-3' }, { success: true, id: 'asset-3' },
]); ]);
expect(mocks.album.update).toHaveBeenCalledWith('album-123', { expect(albumMock.update).toHaveBeenCalledWith('album-123', {
id: 'album-123', id: 'album-123',
updatedAt: expect.any(Date), updatedAt: expect.any(Date),
albumThumbnailAssetId: 'asset-1', albumThumbnailAssetId: 'asset-1',
}); });
expect(mocks.album.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']); expect(albumMock.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']);
expect(mocks.event.emit).toHaveBeenCalledWith('album.update', { expect(eventMock.emit).toHaveBeenCalledWith('album.update', {
id: 'album-123', id: 'album-123',
recipientIds: ['admin_id'], recipientIds: ['admin_id'],
}); });
}); });
it('should not allow a shared user with viewer access to add assets', async () => { it('should not allow a shared user with viewer access to add assets', async () => {
mocks.access.album.checkSharedAlbumAccess.mockResolvedValue(new Set([])); accessMock.album.checkSharedAlbumAccess.mockResolvedValue(new Set([]));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithUser)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.sharedWithUser));
await expect( await expect(
sut.addAssets(authStub.user2, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.user2, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should allow a shared link user to add assets', async () => { it('should allow a shared link user to add assets', async () => {
mocks.access.album.checkSharedLinkAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkSharedLinkAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect( await expect(
sut.addAssets(authStub.adminSharedLink, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.adminSharedLink, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
@@ -601,115 +612,115 @@ describe(AlbumService.name, () => {
{ success: true, id: 'asset-3' }, { success: true, id: 'asset-3' },
]); ]);
expect(mocks.album.update).toHaveBeenCalledWith('album-123', { expect(albumMock.update).toHaveBeenCalledWith('album-123', {
id: 'album-123', id: 'album-123',
updatedAt: expect.any(Date), updatedAt: expect.any(Date),
albumThumbnailAssetId: 'asset-1', albumThumbnailAssetId: 'asset-1',
}); });
expect(mocks.album.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']); expect(albumMock.addAssetIds).toHaveBeenCalledWith('album-123', ['asset-1', 'asset-2', 'asset-3']);
expect(mocks.access.album.checkSharedLinkAccess).toHaveBeenCalledWith( expect(accessMock.album.checkSharedLinkAccess).toHaveBeenCalledWith(
authStub.adminSharedLink.sharedLink?.id, authStub.adminSharedLink.sharedLink?.id,
new Set(['album-123']), new Set(['album-123']),
); );
}); });
it('should allow adding assets shared via partner sharing', async () => { it('should allow adding assets shared via partner sharing', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkPartnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkPartnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([ await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([
{ success: true, id: 'asset-1' }, { success: true, id: 'asset-1' },
]); ]);
expect(mocks.album.update).toHaveBeenCalledWith('album-123', { expect(albumMock.update).toHaveBeenCalledWith('album-123', {
id: 'album-123', id: 'album-123',
updatedAt: expect.any(Date), updatedAt: expect.any(Date),
albumThumbnailAssetId: 'asset-1', albumThumbnailAssetId: 'asset-1',
}); });
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
}); });
it('should skip duplicate assets', async () => { it('should skip duplicate assets', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValueOnce(new Set(['asset-id'])); albumMock.getAssetIds.mockResolvedValueOnce(new Set(['asset-id']));
await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([ await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([
{ success: false, id: 'asset-id', error: BulkIdErrorReason.DUPLICATE }, { success: false, id: 'asset-id', error: BulkIdErrorReason.DUPLICATE },
]); ]);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should skip assets not shared with user', async () => { it('should skip assets not shared with user', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
mocks.album.getAssetIds.mockResolvedValueOnce(new Set()); albumMock.getAssetIds.mockResolvedValueOnce(new Set());
await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([ await expect(sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1'] })).resolves.toEqual([
{ success: false, id: 'asset-1', error: BulkIdErrorReason.NO_PERMISSION }, { success: false, id: 'asset-1', error: BulkIdErrorReason.NO_PERMISSION },
]); ]);
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
}); });
it('should not allow unauthorized access to the album', async () => { it('should not allow unauthorized access to the album', async () => {
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
await expect( await expect(
sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.admin, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalled(); expect(accessMock.album.checkOwnerAccess).toHaveBeenCalled();
expect(mocks.access.album.checkSharedAlbumAccess).toHaveBeenCalled(); expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalled();
}); });
it('should not allow unauthorized shared link access to the album', async () => { it('should not allow unauthorized shared link access to the album', async () => {
mocks.album.getById.mockResolvedValue(albumStub.oneAsset); albumMock.getById.mockResolvedValue(albumStub.oneAsset);
await expect( await expect(
sut.addAssets(authStub.adminSharedLink, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }), sut.addAssets(authStub.adminSharedLink, 'album-123', { ids: ['asset-1', 'asset-2', 'asset-3'] }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.album.checkSharedLinkAccess).toHaveBeenCalled(); expect(accessMock.album.checkSharedLinkAccess).toHaveBeenCalled();
}); });
}); });
describe('removeAssets', () => { describe('removeAssets', () => {
it('should allow the owner to remove assets', async () => { it('should allow the owner to remove assets', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValue(new Set(['asset-id'])); albumMock.getAssetIds.mockResolvedValue(new Set(['asset-id']));
await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([ await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([
{ success: true, id: 'asset-id' }, { success: true, id: 'asset-id' },
]); ]);
expect(mocks.album.removeAssetIds).toHaveBeenCalledWith('album-123', ['asset-id']); expect(albumMock.removeAssetIds).toHaveBeenCalledWith('album-123', ['asset-id']);
}); });
it('should skip assets not in the album', async () => { it('should skip assets not in the album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.empty)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.empty));
mocks.album.getAssetIds.mockResolvedValue(new Set()); albumMock.getAssetIds.mockResolvedValue(new Set());
await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([ await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([
{ success: false, id: 'asset-id', error: BulkIdErrorReason.NOT_FOUND }, { success: false, id: 'asset-id', error: BulkIdErrorReason.NOT_FOUND },
]); ]);
expect(mocks.album.update).not.toHaveBeenCalled(); expect(albumMock.update).not.toHaveBeenCalled();
}); });
it('should allow owner to remove all assets from the album', async () => { it('should allow owner to remove all assets from the album', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.oneAsset));
mocks.album.getAssetIds.mockResolvedValue(new Set(['asset-id'])); albumMock.getAssetIds.mockResolvedValue(new Set(['asset-id']));
await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([ await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([
{ success: true, id: 'asset-id' }, { success: true, id: 'asset-id' },
@@ -717,16 +728,16 @@ describe(AlbumService.name, () => {
}); });
it('should reset the thumbnail if it is removed', async () => { it('should reset the thumbnail if it is removed', async () => {
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123'])); accessMock.album.checkOwnerAccess.mockResolvedValue(new Set(['album-123']));
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-id']));
mocks.album.getById.mockResolvedValue(_.cloneDeep(albumStub.twoAssets)); albumMock.getById.mockResolvedValue(_.cloneDeep(albumStub.twoAssets));
mocks.album.getAssetIds.mockResolvedValue(new Set(['asset-id'])); albumMock.getAssetIds.mockResolvedValue(new Set(['asset-id']));
await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([ await expect(sut.removeAssets(authStub.admin, 'album-123', { ids: ['asset-id'] })).resolves.toEqual([
{ success: true, id: 'asset-id' }, { success: true, id: 'asset-id' },
]); ]);
expect(mocks.album.updateThumbnails).toHaveBeenCalled(); expect(albumMock.updateThumbnails).toHaveBeenCalled();
}); });
}); });
+28 -23
View File
@@ -1,45 +1,50 @@
import { BadRequestException } from '@nestjs/common'; import { BadRequestException } from '@nestjs/common';
import { Permission } from 'src/enum'; import { Permission } from 'src/enum';
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
import { APIKeyService } from 'src/services/api-key.service'; import { APIKeyService } from 'src/services/api-key.service';
import { IApiKeyRepository } from 'src/types';
import { keyStub } from 'test/fixtures/api-key.stub'; import { keyStub } from 'test/fixtures/api-key.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
describe(APIKeyService.name, () => { describe(APIKeyService.name, () => {
let sut: APIKeyService; let sut: APIKeyService;
let mocks: ServiceMocks;
let cryptoMock: Mocked<ICryptoRepository>;
let keyMock: Mocked<IApiKeyRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(APIKeyService)); ({ sut, cryptoMock, keyMock } = newTestService(APIKeyService));
}); });
describe('create', () => { describe('create', () => {
it('should create a new key', async () => { it('should create a new key', async () => {
mocks.apiKey.create.mockResolvedValue(keyStub.admin); keyMock.create.mockResolvedValue(keyStub.admin);
await sut.create(authStub.admin, { name: 'Test Key', permissions: [Permission.ALL] }); await sut.create(authStub.admin, { name: 'Test Key', permissions: [Permission.ALL] });
expect(mocks.apiKey.create).toHaveBeenCalledWith({ expect(keyMock.create).toHaveBeenCalledWith({
key: 'cmFuZG9tLWJ5dGVz (hashed)', key: 'cmFuZG9tLWJ5dGVz (hashed)',
name: 'Test Key', name: 'Test Key',
permissions: [Permission.ALL], permissions: [Permission.ALL],
userId: authStub.admin.user.id, userId: authStub.admin.user.id,
}); });
expect(mocks.crypto.newPassword).toHaveBeenCalled(); expect(cryptoMock.newPassword).toHaveBeenCalled();
expect(mocks.crypto.hashSha256).toHaveBeenCalled(); expect(cryptoMock.hashSha256).toHaveBeenCalled();
}); });
it('should not require a name', async () => { it('should not require a name', async () => {
mocks.apiKey.create.mockResolvedValue(keyStub.admin); keyMock.create.mockResolvedValue(keyStub.admin);
await sut.create(authStub.admin, { permissions: [Permission.ALL] }); await sut.create(authStub.admin, { permissions: [Permission.ALL] });
expect(mocks.apiKey.create).toHaveBeenCalledWith({ expect(keyMock.create).toHaveBeenCalledWith({
key: 'cmFuZG9tLWJ5dGVz (hashed)', key: 'cmFuZG9tLWJ5dGVz (hashed)',
name: 'API Key', name: 'API Key',
permissions: [Permission.ALL], permissions: [Permission.ALL],
userId: authStub.admin.user.id, userId: authStub.admin.user.id,
}); });
expect(mocks.crypto.newPassword).toHaveBeenCalled(); expect(cryptoMock.newPassword).toHaveBeenCalled();
expect(mocks.crypto.hashSha256).toHaveBeenCalled(); expect(cryptoMock.hashSha256).toHaveBeenCalled();
}); });
it('should throw an error if the api key does not have sufficient permissions', async () => { it('should throw an error if the api key does not have sufficient permissions', async () => {
@@ -55,16 +60,16 @@ describe(APIKeyService.name, () => {
BadRequestException, BadRequestException,
); );
expect(mocks.apiKey.update).not.toHaveBeenCalledWith('random-guid'); expect(keyMock.update).not.toHaveBeenCalledWith('random-guid');
}); });
it('should update a key', async () => { it('should update a key', async () => {
mocks.apiKey.getById.mockResolvedValue(keyStub.admin); keyMock.getById.mockResolvedValue(keyStub.admin);
mocks.apiKey.update.mockResolvedValue(keyStub.admin); keyMock.update.mockResolvedValue(keyStub.admin);
await sut.update(authStub.admin, 'random-guid', { name: 'New Name' }); await sut.update(authStub.admin, 'random-guid', { name: 'New Name' });
expect(mocks.apiKey.update).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid', { name: 'New Name' }); expect(keyMock.update).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid', { name: 'New Name' });
}); });
}); });
@@ -72,15 +77,15 @@ describe(APIKeyService.name, () => {
it('should throw an error if the key is not found', async () => { it('should throw an error if the key is not found', async () => {
await expect(sut.delete(authStub.admin, 'random-guid')).rejects.toBeInstanceOf(BadRequestException); await expect(sut.delete(authStub.admin, 'random-guid')).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.apiKey.delete).not.toHaveBeenCalledWith('random-guid'); expect(keyMock.delete).not.toHaveBeenCalledWith('random-guid');
}); });
it('should delete a key', async () => { it('should delete a key', async () => {
mocks.apiKey.getById.mockResolvedValue(keyStub.admin); keyMock.getById.mockResolvedValue(keyStub.admin);
await sut.delete(authStub.admin, 'random-guid'); await sut.delete(authStub.admin, 'random-guid');
expect(mocks.apiKey.delete).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid'); expect(keyMock.delete).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid');
}); });
}); });
@@ -88,25 +93,25 @@ describe(APIKeyService.name, () => {
it('should throw an error if the key is not found', async () => { it('should throw an error if the key is not found', async () => {
await expect(sut.getById(authStub.admin, 'random-guid')).rejects.toBeInstanceOf(BadRequestException); await expect(sut.getById(authStub.admin, 'random-guid')).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.apiKey.getById).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid'); expect(keyMock.getById).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid');
}); });
it('should get a key by id', async () => { it('should get a key by id', async () => {
mocks.apiKey.getById.mockResolvedValue(keyStub.admin); keyMock.getById.mockResolvedValue(keyStub.admin);
await sut.getById(authStub.admin, 'random-guid'); await sut.getById(authStub.admin, 'random-guid');
expect(mocks.apiKey.getById).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid'); expect(keyMock.getById).toHaveBeenCalledWith(authStub.admin.user.id, 'random-guid');
}); });
}); });
describe('getAll', () => { describe('getAll', () => {
it('should return all the keys for a user', async () => { it('should return all the keys for a user', async () => {
mocks.apiKey.getByUserId.mockResolvedValue([keyStub.admin]); keyMock.getByUserId.mockResolvedValue([keyStub.admin]);
await expect(sut.getAll(authStub.admin)).resolves.toHaveLength(1); await expect(sut.getAll(authStub.admin)).resolves.toHaveLength(1);
expect(mocks.apiKey.getByUserId).toHaveBeenCalledWith(authStub.admin.user.id); expect(keyMock.getByUserId).toHaveBeenCalledWith(authStub.admin.user.id);
}); });
}); });
}); });
+123 -113
View File
@@ -10,7 +10,10 @@ import { AssetMediaCreateDto, AssetMediaReplaceDto, AssetMediaSize, UploadFieldN
import { AssetFileEntity } from 'src/entities/asset-files.entity'; import { AssetFileEntity } from 'src/entities/asset-files.entity';
import { ASSET_CHECKSUM_CONSTRAINT, AssetEntity } from 'src/entities/asset.entity'; import { ASSET_CHECKSUM_CONSTRAINT, AssetEntity } from 'src/entities/asset.entity';
import { AssetFileType, AssetStatus, AssetType, CacheControl } from 'src/enum'; import { AssetFileType, AssetStatus, AssetType, CacheControl } from 'src/enum';
import { JobName } from 'src/interfaces/job.interface'; import { IAssetRepository } from 'src/interfaces/asset.interface';
import { IJobRepository, JobName } from 'src/interfaces/job.interface';
import { IStorageRepository } from 'src/interfaces/storage.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { AuthRequest } from 'src/middleware/auth.guard'; import { AuthRequest } from 'src/middleware/auth.guard';
import { AssetMediaService } from 'src/services/asset-media.service'; import { AssetMediaService } from 'src/services/asset-media.service';
import { ImmichFileResponse } from 'src/utils/file'; import { ImmichFileResponse } from 'src/utils/file';
@@ -18,7 +21,9 @@ import { assetStub } from 'test/fixtures/asset.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { fileStub } from 'test/fixtures/file.stub'; import { fileStub } from 'test/fixtures/file.stub';
import { userStub } from 'test/fixtures/user.stub'; import { userStub } from 'test/fixtures/user.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { IAccessRepositoryMock } from 'test/repositories/access.repository.mock';
import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex'); const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex');
@@ -198,10 +203,15 @@ const copiedAsset = Object.freeze({
describe(AssetMediaService.name, () => { describe(AssetMediaService.name, () => {
let sut: AssetMediaService; let sut: AssetMediaService;
let mocks: ServiceMocks;
let accessMock: IAccessRepositoryMock;
let assetMock: Mocked<IAssetRepository>;
let jobMock: Mocked<IJobRepository>;
let storageMock: Mocked<IStorageRepository>;
let userMock: Mocked<IUserRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(AssetMediaService)); ({ sut, accessMock, assetMock, jobMock, storageMock, userMock } = newTestService(AssetMediaService));
}); });
describe('getUploadAssetIdByChecksum', () => { describe('getUploadAssetIdByChecksum', () => {
@@ -211,25 +221,25 @@ describe(AssetMediaService.name, () => {
it('should handle a non-existent asset', async () => { it('should handle a non-existent asset', async () => {
await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('hex'))).resolves.toBeUndefined(); await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('hex'))).resolves.toBeUndefined();
expect(mocks.asset.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1); expect(assetMock.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1);
}); });
it('should find an existing asset', async () => { it('should find an existing asset', async () => {
mocks.asset.getUploadAssetIdByChecksum.mockResolvedValue('asset-id'); assetMock.getUploadAssetIdByChecksum.mockResolvedValue('asset-id');
await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('hex'))).resolves.toEqual({ await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('hex'))).resolves.toEqual({
id: 'asset-id', id: 'asset-id',
status: AssetMediaStatus.DUPLICATE, status: AssetMediaStatus.DUPLICATE,
}); });
expect(mocks.asset.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1); expect(assetMock.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1);
}); });
it('should find an existing asset by base64', async () => { it('should find an existing asset by base64', async () => {
mocks.asset.getUploadAssetIdByChecksum.mockResolvedValue('asset-id'); assetMock.getUploadAssetIdByChecksum.mockResolvedValue('asset-id');
await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('base64'))).resolves.toEqual({ await expect(sut.getUploadAssetIdByChecksum(authStub.admin, file1.toString('base64'))).resolves.toEqual({
id: 'asset-id', id: 'asset-id',
status: AssetMediaStatus.DUPLICATE, status: AssetMediaStatus.DUPLICATE,
}); });
expect(mocks.asset.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1); expect(assetMock.getUploadAssetIdByChecksum).toHaveBeenCalledWith(authStub.admin.user.id, file1);
}); });
}); });
@@ -298,14 +308,14 @@ describe(AssetMediaService.name, () => {
expect(sut.getUploadFolder(uploadFile.filename(UploadFieldName.PROFILE_DATA, 'image.jpg'))).toEqual( expect(sut.getUploadFolder(uploadFile.filename(UploadFieldName.PROFILE_DATA, 'image.jpg'))).toEqual(
'upload/profile/admin_id', 'upload/profile/admin_id',
); );
expect(mocks.storage.mkdirSync).toHaveBeenCalledWith('upload/profile/admin_id'); expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/profile/admin_id');
}); });
it('should return upload for everything else', () => { it('should return upload for everything else', () => {
expect(sut.getUploadFolder(uploadFile.filename(UploadFieldName.ASSET_DATA, 'image.jpg'))).toEqual( expect(sut.getUploadFolder(uploadFile.filename(UploadFieldName.ASSET_DATA, 'image.jpg'))).toEqual(
'upload/upload/admin_id/ra/nd', 'upload/upload/admin_id/ra/nd',
); );
expect(mocks.storage.mkdirSync).toHaveBeenCalledWith('upload/upload/admin_id/ra/nd'); expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/upload/admin_id/ra/nd');
}); });
}); });
@@ -320,7 +330,7 @@ describe(AssetMediaService.name, () => {
size: 42, size: 42,
}; };
mocks.asset.create.mockResolvedValue(assetEntity); assetMock.create.mockResolvedValue(assetEntity);
await expect( await expect(
sut.uploadAsset( sut.uploadAsset(
@@ -330,9 +340,9 @@ describe(AssetMediaService.name, () => {
), ),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.create).not.toHaveBeenCalled(); expect(assetMock.create).not.toHaveBeenCalled();
expect(mocks.user.updateUsage).not.toHaveBeenCalledWith(authStub.user1.user.id, file.size); expect(userMock.updateUsage).not.toHaveBeenCalledWith(authStub.user1.user.id, file.size);
expect(mocks.storage.utimes).not.toHaveBeenCalledWith( expect(storageMock.utimes).not.toHaveBeenCalledWith(
file.originalPath, file.originalPath,
expect.any(Date), expect.any(Date),
new Date(createDto.fileModifiedAt), new Date(createDto.fileModifiedAt),
@@ -349,16 +359,16 @@ describe(AssetMediaService.name, () => {
size: 42, size: 42,
}; };
mocks.asset.create.mockResolvedValue(assetEntity); assetMock.create.mockResolvedValue(assetEntity);
await expect(sut.uploadAsset(authStub.user1, createDto, file)).resolves.toEqual({ await expect(sut.uploadAsset(authStub.user1, createDto, file)).resolves.toEqual({
id: 'id_1', id: 'id_1',
status: AssetMediaStatus.CREATED, status: AssetMediaStatus.CREATED,
}); });
expect(mocks.asset.create).toHaveBeenCalled(); expect(assetMock.create).toHaveBeenCalled();
expect(mocks.user.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, file.size); expect(userMock.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, file.size);
expect(mocks.storage.utimes).toHaveBeenCalledWith( expect(storageMock.utimes).toHaveBeenCalledWith(
file.originalPath, file.originalPath,
expect.any(Date), expect.any(Date),
new Date(createDto.fileModifiedAt), new Date(createDto.fileModifiedAt),
@@ -377,19 +387,19 @@ describe(AssetMediaService.name, () => {
const error = new Error('unique key violation'); const error = new Error('unique key violation');
(error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT; (error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT;
mocks.asset.create.mockRejectedValue(error); assetMock.create.mockRejectedValue(error);
mocks.asset.getUploadAssetIdByChecksum.mockResolvedValue(assetEntity.id); assetMock.getUploadAssetIdByChecksum.mockResolvedValue(assetEntity.id);
await expect(sut.uploadAsset(authStub.user1, createDto, file)).resolves.toEqual({ await expect(sut.uploadAsset(authStub.user1, createDto, file)).resolves.toEqual({
id: 'id_1', id: 'id_1',
status: AssetMediaStatus.DUPLICATE, status: AssetMediaStatus.DUPLICATE,
}); });
expect(mocks.job.queue).toHaveBeenCalledWith({ expect(jobMock.queue).toHaveBeenCalledWith({
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { files: ['fake_path/asset_1.jpeg', undefined] }, data: { files: ['fake_path/asset_1.jpeg', undefined] },
}); });
expect(mocks.user.updateUsage).not.toHaveBeenCalled(); expect(userMock.updateUsage).not.toHaveBeenCalled();
}); });
it('should throw an error if the duplicate could not be found by checksum', async () => { it('should throw an error if the duplicate could not be found by checksum', async () => {
@@ -404,22 +414,22 @@ describe(AssetMediaService.name, () => {
const error = new Error('unique key violation'); const error = new Error('unique key violation');
(error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT; (error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT;
mocks.asset.create.mockRejectedValue(error); assetMock.create.mockRejectedValue(error);
await expect(sut.uploadAsset(authStub.user1, createDto, file)).rejects.toBeInstanceOf( await expect(sut.uploadAsset(authStub.user1, createDto, file)).rejects.toBeInstanceOf(
InternalServerErrorException, InternalServerErrorException,
); );
expect(mocks.job.queue).toHaveBeenCalledWith({ expect(jobMock.queue).toHaveBeenCalledWith({
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { files: ['fake_path/asset_1.jpeg', undefined] }, data: { files: ['fake_path/asset_1.jpeg', undefined] },
}); });
expect(mocks.user.updateUsage).not.toHaveBeenCalled(); expect(userMock.updateUsage).not.toHaveBeenCalled();
}); });
it('should handle a live photo', async () => { it('should handle a live photo', async () => {
mocks.asset.getById.mockResolvedValueOnce(assetStub.livePhotoMotionAsset); assetMock.getById.mockResolvedValueOnce(assetStub.livePhotoMotionAsset);
mocks.asset.create.mockResolvedValueOnce(assetStub.livePhotoStillAsset); assetMock.create.mockResolvedValueOnce(assetStub.livePhotoStillAsset);
await expect( await expect(
sut.uploadAsset( sut.uploadAsset(
@@ -432,13 +442,13 @@ describe(AssetMediaService.name, () => {
id: 'live-photo-still-asset', id: 'live-photo-still-asset',
}); });
expect(mocks.asset.getById).toHaveBeenCalledWith('live-photo-motion-asset'); expect(assetMock.getById).toHaveBeenCalledWith('live-photo-motion-asset');
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
}); });
it('should hide the linked motion asset', async () => { it('should hide the linked motion asset', async () => {
mocks.asset.getById.mockResolvedValueOnce({ ...assetStub.livePhotoMotionAsset, isVisible: true }); assetMock.getById.mockResolvedValueOnce({ ...assetStub.livePhotoMotionAsset, isVisible: true });
mocks.asset.create.mockResolvedValueOnce(assetStub.livePhotoStillAsset); assetMock.create.mockResolvedValueOnce(assetStub.livePhotoStillAsset);
await expect( await expect(
sut.uploadAsset( sut.uploadAsset(
@@ -451,25 +461,25 @@ describe(AssetMediaService.name, () => {
id: 'live-photo-still-asset', id: 'live-photo-still-asset',
}); });
expect(mocks.asset.getById).toHaveBeenCalledWith('live-photo-motion-asset'); expect(assetMock.getById).toHaveBeenCalledWith('live-photo-motion-asset');
expect(mocks.asset.update).toHaveBeenCalledWith({ id: 'live-photo-motion-asset', isVisible: false }); expect(assetMock.update).toHaveBeenCalledWith({ id: 'live-photo-motion-asset', isVisible: false });
}); });
it('should handle a sidecar file', async () => { it('should handle a sidecar file', async () => {
mocks.asset.getById.mockResolvedValueOnce(assetStub.image); assetMock.getById.mockResolvedValueOnce(assetStub.image);
mocks.asset.create.mockResolvedValueOnce(assetStub.image); assetMock.create.mockResolvedValueOnce(assetStub.image);
await expect(sut.uploadAsset(authStub.user1, createDto, fileStub.photo, fileStub.photoSidecar)).resolves.toEqual({ await expect(sut.uploadAsset(authStub.user1, createDto, fileStub.photo, fileStub.photoSidecar)).resolves.toEqual({
status: AssetMediaStatus.CREATED, status: AssetMediaStatus.CREATED,
id: assetStub.image.id, id: assetStub.image.id,
}); });
expect(mocks.storage.utimes).toHaveBeenCalledWith( expect(storageMock.utimes).toHaveBeenCalledWith(
fileStub.photoSidecar.originalPath, fileStub.photoSidecar.originalPath,
expect.any(Date), expect.any(Date),
new Date(createDto.fileModifiedAt), new Date(createDto.fileModifiedAt),
); );
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
}); });
}); });
@@ -477,22 +487,22 @@ describe(AssetMediaService.name, () => {
it('should require the asset.download permission', async () => { it('should require the asset.download permission', async () => {
await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).rejects.toBeInstanceOf(BadRequestException); await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
expect(mocks.access.asset.checkAlbumAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkAlbumAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1'])); expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['asset-1']));
}); });
it('should throw an error if the asset is not found', async () => { it('should throw an error if the asset is not found', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).rejects.toBeInstanceOf(NotFoundException); await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).rejects.toBeInstanceOf(NotFoundException);
expect(mocks.asset.getById).toHaveBeenCalledWith('asset-1', { files: true }); expect(assetMock.getById).toHaveBeenCalledWith('asset-1', { files: true });
}); });
it('should download a file', async () => { it('should download a file', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).resolves.toEqual( await expect(sut.downloadOriginal(authStub.admin, 'asset-1')).resolves.toEqual(
new ImmichFileResponse({ new ImmichFileResponse({
@@ -508,13 +518,13 @@ describe(AssetMediaService.name, () => {
it('should require asset.view permissions', async () => { it('should require asset.view permissions', async () => {
await expect(sut.viewThumbnail(authStub.admin, 'id', {})).rejects.toBeInstanceOf(BadRequestException); await expect(sut.viewThumbnail(authStub.admin, 'id', {})).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
expect(mocks.access.asset.checkAlbumAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkAlbumAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
}); });
it('should throw an error if the asset does not exist', async () => { it('should throw an error if the asset does not exist', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
await expect( await expect(
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }),
@@ -522,8 +532,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should throw an error if the requested thumbnail file does not exist', async () => { it('should throw an error if the requested thumbnail file does not exist', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue({ ...assetStub.image, files: [] }); assetMock.getById.mockResolvedValue({ ...assetStub.image, files: [] });
await expect( await expect(
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }),
@@ -531,8 +541,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should throw an error if the requested preview file does not exist', async () => { it('should throw an error if the requested preview file does not exist', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue({ assetMock.getById.mockResolvedValue({
...assetStub.image, ...assetStub.image,
files: [ files: [
{ {
@@ -551,8 +561,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should fall back to preview if the requested thumbnail file does not exist', async () => { it('should fall back to preview if the requested thumbnail file does not exist', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue({ assetMock.getById.mockResolvedValue({
...assetStub.image, ...assetStub.image,
files: [ files: [
{ {
@@ -579,8 +589,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should get preview file', async () => { it('should get preview file', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue({ ...assetStub.image }); assetMock.getById.mockResolvedValue({ ...assetStub.image });
await expect( await expect(
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.PREVIEW }),
).resolves.toEqual( ).resolves.toEqual(
@@ -594,8 +604,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should get thumbnail file', async () => { it('should get thumbnail file', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue({ ...assetStub.image }); assetMock.getById.mockResolvedValue({ ...assetStub.image });
await expect( await expect(
sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }), sut.viewThumbnail(authStub.admin, assetStub.image.id, { size: AssetMediaSize.THUMBNAIL }),
).resolves.toEqual( ).resolves.toEqual(
@@ -613,27 +623,27 @@ describe(AssetMediaService.name, () => {
it('should require asset.view permissions', async () => { it('should require asset.view permissions', async () => {
await expect(sut.playbackVideo(authStub.admin, 'id')).rejects.toBeInstanceOf(BadRequestException); await expect(sut.playbackVideo(authStub.admin, 'id')).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
expect(mocks.access.asset.checkAlbumAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkAlbumAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id'])); expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(userStub.admin.id, new Set(['id']));
}); });
it('should throw an error if the asset does not exist', async () => { it('should throw an error if the asset does not exist', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
await expect(sut.playbackVideo(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(NotFoundException); await expect(sut.playbackVideo(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(NotFoundException);
}); });
it('should throw an error if the asset is not a video', async () => { it('should throw an error if the asset is not a video', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await expect(sut.playbackVideo(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.playbackVideo(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException);
}); });
it('should return the encoded video path if available', async () => { it('should return the encoded video path if available', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.hasEncodedVideo.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.hasEncodedVideo.id]));
mocks.asset.getById.mockResolvedValue(assetStub.hasEncodedVideo); assetMock.getById.mockResolvedValue(assetStub.hasEncodedVideo);
await expect(sut.playbackVideo(authStub.admin, assetStub.hasEncodedVideo.id)).resolves.toEqual( await expect(sut.playbackVideo(authStub.admin, assetStub.hasEncodedVideo.id)).resolves.toEqual(
new ImmichFileResponse({ new ImmichFileResponse({
@@ -645,8 +655,8 @@ describe(AssetMediaService.name, () => {
}); });
it('should fall back to the original path', async () => { it('should fall back to the original path', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.video.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.video.id]));
mocks.asset.getById.mockResolvedValue(assetStub.video); assetMock.getById.mockResolvedValue(assetStub.video);
await expect(sut.playbackVideo(authStub.admin, assetStub.video.id)).resolves.toEqual( await expect(sut.playbackVideo(authStub.admin, assetStub.video.id)).resolves.toEqual(
new ImmichFileResponse({ new ImmichFileResponse({
@@ -660,12 +670,12 @@ describe(AssetMediaService.name, () => {
describe('checkExistingAssets', () => { describe('checkExistingAssets', () => {
it('should get existing asset ids', async () => { it('should get existing asset ids', async () => {
mocks.asset.getByDeviceIds.mockResolvedValue(['42']); assetMock.getByDeviceIds.mockResolvedValue(['42']);
await expect( await expect(
sut.checkExistingAssets(authStub.admin, { deviceId: '420', deviceAssetIds: ['69'] }), sut.checkExistingAssets(authStub.admin, { deviceId: '420', deviceAssetIds: ['69'] }),
).resolves.toEqual({ existingIds: ['42'] }); ).resolves.toEqual({ existingIds: ['42'] });
expect(mocks.asset.getByDeviceIds).toHaveBeenCalledWith(userStub.admin.id, '420', ['69']); expect(assetMock.getByDeviceIds).toHaveBeenCalledWith(userStub.admin.id, '420', ['69']);
}); });
}); });
@@ -675,26 +685,26 @@ describe(AssetMediaService.name, () => {
'Not found or no asset.update access', 'Not found or no asset.update access',
); );
expect(mocks.asset.create).not.toHaveBeenCalled(); expect(assetMock.create).not.toHaveBeenCalled();
}); });
it('should update a photo with no sidecar to photo with no sidecar', async () => { it('should update a photo with no sidecar to photo with no sidecar', async () => {
const updatedFile = fileStub.photo; const updatedFile = fileStub.photo;
const updatedAsset = { ...existingAsset, ...updatedFile }; const updatedAsset = { ...existingAsset, ...updatedFile };
mocks.asset.getById.mockResolvedValueOnce(existingAsset); assetMock.getById.mockResolvedValueOnce(existingAsset);
mocks.asset.getById.mockResolvedValueOnce(updatedAsset); assetMock.getById.mockResolvedValueOnce(updatedAsset);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([existingAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([existingAsset.id]));
// this is the original file size // this is the original file size
mocks.storage.stat.mockResolvedValue({ size: 0 } as Stats); storageMock.stat.mockResolvedValue({ size: 0 } as Stats);
// this is for the clone call // this is for the clone call
mocks.asset.create.mockResolvedValue(copiedAsset); assetMock.create.mockResolvedValue(copiedAsset);
await expect(sut.replaceAsset(authStub.user1, existingAsset.id, replaceDto, updatedFile)).resolves.toEqual({ await expect(sut.replaceAsset(authStub.user1, existingAsset.id, replaceDto, updatedFile)).resolves.toEqual({
status: AssetMediaStatus.REPLACED, status: AssetMediaStatus.REPLACED,
id: 'copied-asset', id: 'copied-asset',
}); });
expect(mocks.asset.update).toHaveBeenCalledWith( expect(assetMock.update).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
id: existingAsset.id, id: existingAsset.id,
sidecarPath: null, sidecarPath: null,
@@ -702,7 +712,7 @@ describe(AssetMediaService.name, () => {
originalPath: 'fake_path/photo1.jpeg', originalPath: 'fake_path/photo1.jpeg',
}), }),
); );
expect(mocks.asset.create).toHaveBeenCalledWith( expect(assetMock.create).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
sidecarPath: null, sidecarPath: null,
originalFileName: 'existing-filename.jpeg', originalFileName: 'existing-filename.jpeg',
@@ -710,12 +720,12 @@ describe(AssetMediaService.name, () => {
}), }),
); );
expect(mocks.asset.updateAll).toHaveBeenCalledWith([copiedAsset.id], { expect(assetMock.updateAll).toHaveBeenCalledWith([copiedAsset.id], {
deletedAt: expect.any(Date), deletedAt: expect.any(Date),
status: AssetStatus.TRASHED, status: AssetStatus.TRASHED,
}); });
expect(mocks.user.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size); expect(userMock.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size);
expect(mocks.storage.utimes).toHaveBeenCalledWith( expect(storageMock.utimes).toHaveBeenCalledWith(
updatedFile.originalPath, updatedFile.originalPath,
expect.any(Date), expect.any(Date),
new Date(replaceDto.fileModifiedAt), new Date(replaceDto.fileModifiedAt),
@@ -726,13 +736,13 @@ describe(AssetMediaService.name, () => {
const updatedFile = fileStub.photo; const updatedFile = fileStub.photo;
const sidecarFile = fileStub.photoSidecar; const sidecarFile = fileStub.photoSidecar;
const updatedAsset = { ...sidecarAsset, ...updatedFile }; const updatedAsset = { ...sidecarAsset, ...updatedFile };
mocks.asset.getById.mockResolvedValueOnce(existingAsset); assetMock.getById.mockResolvedValueOnce(existingAsset);
mocks.asset.getById.mockResolvedValueOnce(updatedAsset); assetMock.getById.mockResolvedValueOnce(updatedAsset);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id]));
// this is the original file size // this is the original file size
mocks.storage.stat.mockResolvedValue({ size: 0 } as Stats); storageMock.stat.mockResolvedValue({ size: 0 } as Stats);
// this is for the clone call // this is for the clone call
mocks.asset.create.mockResolvedValue(copiedAsset); assetMock.create.mockResolvedValue(copiedAsset);
await expect( await expect(
sut.replaceAsset(authStub.user1, sidecarAsset.id, replaceDto, updatedFile, sidecarFile), sut.replaceAsset(authStub.user1, sidecarAsset.id, replaceDto, updatedFile, sidecarFile),
@@ -741,12 +751,12 @@ describe(AssetMediaService.name, () => {
id: 'copied-asset', id: 'copied-asset',
}); });
expect(mocks.asset.updateAll).toHaveBeenCalledWith([copiedAsset.id], { expect(assetMock.updateAll).toHaveBeenCalledWith([copiedAsset.id], {
deletedAt: expect.any(Date), deletedAt: expect.any(Date),
status: AssetStatus.TRASHED, status: AssetStatus.TRASHED,
}); });
expect(mocks.user.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size); expect(userMock.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size);
expect(mocks.storage.utimes).toHaveBeenCalledWith( expect(storageMock.utimes).toHaveBeenCalledWith(
updatedFile.originalPath, updatedFile.originalPath,
expect.any(Date), expect.any(Date),
new Date(replaceDto.fileModifiedAt), new Date(replaceDto.fileModifiedAt),
@@ -757,25 +767,25 @@ describe(AssetMediaService.name, () => {
const updatedFile = fileStub.photo; const updatedFile = fileStub.photo;
const updatedAsset = { ...sidecarAsset, ...updatedFile }; const updatedAsset = { ...sidecarAsset, ...updatedFile };
mocks.asset.getById.mockResolvedValueOnce(sidecarAsset); assetMock.getById.mockResolvedValueOnce(sidecarAsset);
mocks.asset.getById.mockResolvedValueOnce(updatedAsset); assetMock.getById.mockResolvedValueOnce(updatedAsset);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id]));
// this is the original file size // this is the original file size
mocks.storage.stat.mockResolvedValue({ size: 0 } as Stats); storageMock.stat.mockResolvedValue({ size: 0 } as Stats);
// this is for the copy call // this is for the copy call
mocks.asset.create.mockResolvedValue(copiedAsset); assetMock.create.mockResolvedValue(copiedAsset);
await expect(sut.replaceAsset(authStub.user1, existingAsset.id, replaceDto, updatedFile)).resolves.toEqual({ await expect(sut.replaceAsset(authStub.user1, existingAsset.id, replaceDto, updatedFile)).resolves.toEqual({
status: AssetMediaStatus.REPLACED, status: AssetMediaStatus.REPLACED,
id: 'copied-asset', id: 'copied-asset',
}); });
expect(mocks.asset.updateAll).toHaveBeenCalledWith([copiedAsset.id], { expect(assetMock.updateAll).toHaveBeenCalledWith([copiedAsset.id], {
deletedAt: expect.any(Date), deletedAt: expect.any(Date),
status: AssetStatus.TRASHED, status: AssetStatus.TRASHED,
}); });
expect(mocks.user.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size); expect(userMock.updateUsage).toHaveBeenCalledWith(authStub.user1.user.id, updatedFile.size);
expect(mocks.storage.utimes).toHaveBeenCalledWith( expect(storageMock.utimes).toHaveBeenCalledWith(
updatedFile.originalPath, updatedFile.originalPath,
expect.any(Date), expect.any(Date),
new Date(replaceDto.fileModifiedAt), new Date(replaceDto.fileModifiedAt),
@@ -787,27 +797,27 @@ describe(AssetMediaService.name, () => {
const error = new Error('unique key violation'); const error = new Error('unique key violation');
(error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT; (error as any).constraint_name = ASSET_CHECKSUM_CONSTRAINT;
mocks.asset.update.mockRejectedValue(error); assetMock.update.mockRejectedValue(error);
mocks.asset.getById.mockResolvedValueOnce(sidecarAsset); assetMock.getById.mockResolvedValueOnce(sidecarAsset);
mocks.asset.getUploadAssetIdByChecksum.mockResolvedValue(sidecarAsset.id); assetMock.getUploadAssetIdByChecksum.mockResolvedValue(sidecarAsset.id);
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([sidecarAsset.id]));
// this is the original file size // this is the original file size
mocks.storage.stat.mockResolvedValue({ size: 0 } as Stats); storageMock.stat.mockResolvedValue({ size: 0 } as Stats);
// this is for the clone call // this is for the clone call
mocks.asset.create.mockResolvedValue(copiedAsset); assetMock.create.mockResolvedValue(copiedAsset);
await expect(sut.replaceAsset(authStub.user1, sidecarAsset.id, replaceDto, updatedFile)).resolves.toEqual({ await expect(sut.replaceAsset(authStub.user1, sidecarAsset.id, replaceDto, updatedFile)).resolves.toEqual({
status: AssetMediaStatus.DUPLICATE, status: AssetMediaStatus.DUPLICATE,
id: sidecarAsset.id, id: sidecarAsset.id,
}); });
expect(mocks.asset.create).not.toHaveBeenCalled(); expect(assetMock.create).not.toHaveBeenCalled();
expect(mocks.asset.updateAll).not.toHaveBeenCalled(); expect(assetMock.updateAll).not.toHaveBeenCalled();
expect(mocks.job.queue).toHaveBeenCalledWith({ expect(jobMock.queue).toHaveBeenCalledWith({
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { files: [updatedFile.originalPath, undefined] }, data: { files: [updatedFile.originalPath, undefined] },
}); });
expect(mocks.user.updateUsage).not.toHaveBeenCalled(); expect(userMock.updateUsage).not.toHaveBeenCalled();
}); });
}); });
@@ -816,7 +826,7 @@ describe(AssetMediaService.name, () => {
const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex'); const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex');
const file2 = Buffer.from('53be335e99f18a66ff12e9a901c7a6171dd76573', 'hex'); const file2 = Buffer.from('53be335e99f18a66ff12e9a901c7a6171dd76573', 'hex');
mocks.asset.getByChecksums.mockResolvedValue([ assetMock.getByChecksums.mockResolvedValue([
{ id: 'asset-1', checksum: file1 } as AssetEntity, { id: 'asset-1', checksum: file1 } as AssetEntity,
{ id: 'asset-2', checksum: file2 } as AssetEntity, { id: 'asset-2', checksum: file2 } as AssetEntity,
]); ]);
@@ -847,14 +857,14 @@ describe(AssetMediaService.name, () => {
], ],
}); });
expect(mocks.asset.getByChecksums).toHaveBeenCalledWith(authStub.admin.user.id, [file1, file2]); expect(assetMock.getByChecksums).toHaveBeenCalledWith(authStub.admin.user.id, [file1, file2]);
}); });
it('should return non-duplicates as well', async () => { it('should return non-duplicates as well', async () => {
const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex'); const file1 = Buffer.from('d2947b871a706081be194569951b7db246907957', 'hex');
const file2 = Buffer.from('53be335e99f18a66ff12e9a901c7a6171dd76573', 'hex'); const file2 = Buffer.from('53be335e99f18a66ff12e9a901c7a6171dd76573', 'hex');
mocks.asset.getByChecksums.mockResolvedValue([{ id: 'asset-1', checksum: file1 } as AssetEntity]); assetMock.getByChecksums.mockResolvedValue([{ id: 'asset-1', checksum: file1 } as AssetEntity]);
await expect( await expect(
sut.bulkUploadCheck(authStub.admin, { sut.bulkUploadCheck(authStub.admin, {
@@ -879,7 +889,7 @@ describe(AssetMediaService.name, () => {
], ],
}); });
expect(mocks.asset.getByChecksums).toHaveBeenCalledWith(authStub.admin.user.id, [file1, file2]); expect(assetMock.getByChecksums).toHaveBeenCalledWith(authStub.admin.user.id, [file1, file2]);
}); });
}); });
@@ -900,7 +910,7 @@ describe(AssetMediaService.name, () => {
await sut.onUploadError(request, file); await sut.onUploadError(request, file);
expect(mocks.job.queue).toHaveBeenCalledWith({ expect(jobMock.queue).toHaveBeenCalledWith({
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
data: { files: ['upload/upload/user-id/ra/nd/random-uuid.jpg'] }, data: { files: ['upload/upload/user-id/ra/nd/random-uuid.jpg'] },
}); });
+152 -137
View File
@@ -4,16 +4,22 @@ import { mapAsset } from 'src/dtos/asset-response.dto';
import { AssetJobName, AssetStatsResponseDto } from 'src/dtos/asset.dto'; import { AssetJobName, AssetStatsResponseDto } from 'src/dtos/asset.dto';
import { AssetEntity } from 'src/entities/asset.entity'; import { AssetEntity } from 'src/entities/asset.entity';
import { AssetStatus, AssetType } from 'src/enum'; import { AssetStatus, AssetType } from 'src/enum';
import { AssetStats } from 'src/interfaces/asset.interface'; import { AssetStats, IAssetRepository } from 'src/interfaces/asset.interface';
import { JobName, JobStatus } from 'src/interfaces/job.interface'; import { IEventRepository } from 'src/interfaces/event.interface';
import { IJobRepository, JobName, JobStatus } from 'src/interfaces/job.interface';
import { IPartnerRepository } from 'src/interfaces/partner.interface';
import { IStackRepository } from 'src/interfaces/stack.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { AssetService } from 'src/services/asset.service'; import { AssetService } from 'src/services/asset.service';
import { assetStub } from 'test/fixtures/asset.stub'; import { assetStub } from 'test/fixtures/asset.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { faceStub } from 'test/fixtures/face.stub'; import { faceStub } from 'test/fixtures/face.stub';
import { partnerStub } from 'test/fixtures/partner.stub'; import { partnerStub } from 'test/fixtures/partner.stub';
import { userStub } from 'test/fixtures/user.stub'; import { userStub } from 'test/fixtures/user.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { IAccessRepositoryMock } from 'test/repositories/access.repository.mock';
import { vitest } from 'vitest'; import { newTestService } from 'test/utils';
import { Mocked, vitest } from 'vitest';
const stats: AssetStats = { const stats: AssetStats = {
[AssetType.IMAGE]: 10, [AssetType.IMAGE]: 10,
@@ -30,18 +36,27 @@ const statResponse: AssetStatsResponseDto = {
describe(AssetService.name, () => { describe(AssetService.name, () => {
let sut: AssetService; let sut: AssetService;
let mocks: ServiceMocks;
let accessMock: IAccessRepositoryMock;
let assetMock: Mocked<IAssetRepository>;
let eventMock: Mocked<IEventRepository>;
let jobMock: Mocked<IJobRepository>;
let partnerMock: Mocked<IPartnerRepository>;
let stackMock: Mocked<IStackRepository>;
let systemMock: Mocked<ISystemMetadataRepository>;
let userMock: Mocked<IUserRepository>;
it('should work', () => { it('should work', () => {
expect(sut).toBeDefined(); expect(sut).toBeDefined();
}); });
const mockGetById = (assets: AssetEntity[]) => { const mockGetById = (assets: AssetEntity[]) => {
mocks.asset.getById.mockImplementation((assetId) => Promise.resolve(assets.find((asset) => asset.id === assetId))); assetMock.getById.mockImplementation((assetId) => Promise.resolve(assets.find((asset) => asset.id === assetId)));
}; };
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(AssetService)); ({ sut, accessMock, assetMock, eventMock, jobMock, partnerMock, stackMock, systemMock, userMock } =
newTestService(AssetService));
mockGetById([assetStub.livePhotoStillAsset, assetStub.livePhotoMotionAsset]); mockGetById([assetStub.livePhotoStillAsset, assetStub.livePhotoMotionAsset]);
}); });
@@ -62,8 +77,8 @@ describe(AssetService.name, () => {
const image3 = { ...assetStub.image, localDateTime: new Date(2015, 1, 15) }; const image3 = { ...assetStub.image, localDateTime: new Date(2015, 1, 15) };
const image4 = { ...assetStub.image, localDateTime: new Date(2009, 1, 15) }; const image4 = { ...assetStub.image, localDateTime: new Date(2009, 1, 15) };
mocks.partner.getAll.mockResolvedValue([]); partnerMock.getAll.mockResolvedValue([]);
mocks.asset.getByDayOfYear.mockResolvedValue([ assetMock.getByDayOfYear.mockResolvedValue([
{ {
yearsAgo: 1, yearsAgo: 1,
assets: [image1, image2], assets: [image1, image2],
@@ -84,16 +99,16 @@ describe(AssetService.name, () => {
{ yearsAgo: 15, title: '15 years ago', assets: [mapAsset(image4)] }, { yearsAgo: 15, title: '15 years ago', assets: [mapAsset(image4)] },
]); ]);
expect(mocks.asset.getByDayOfYear.mock.calls).toEqual([[[authStub.admin.user.id], { day: 15, month: 1 }]]); expect(assetMock.getByDayOfYear.mock.calls).toEqual([[[authStub.admin.user.id], { day: 15, month: 1 }]]);
}); });
it('should get memories with partners with inTimeline enabled', async () => { it('should get memories with partners with inTimeline enabled', async () => {
mocks.partner.getAll.mockResolvedValue([partnerStub.user1ToAdmin1]); partnerMock.getAll.mockResolvedValue([partnerStub.user1ToAdmin1]);
mocks.asset.getByDayOfYear.mockResolvedValue([]); assetMock.getByDayOfYear.mockResolvedValue([]);
await sut.getMemoryLane(authStub.admin, { day: 15, month: 1 }); await sut.getMemoryLane(authStub.admin, { day: 15, month: 1 });
expect(mocks.asset.getByDayOfYear.mock.calls).toEqual([ expect(assetMock.getByDayOfYear.mock.calls).toEqual([
[[authStub.admin.user.id, userStub.user1.id], { day: 15, month: 1 }], [[authStub.admin.user.id, userStub.user1.id], { day: 15, month: 1 }],
]); ]);
}); });
@@ -101,76 +116,76 @@ describe(AssetService.name, () => {
describe('getStatistics', () => { describe('getStatistics', () => {
it('should get the statistics for a user, excluding archived assets', async () => { it('should get the statistics for a user, excluding archived assets', async () => {
mocks.asset.getStatistics.mockResolvedValue(stats); assetMock.getStatistics.mockResolvedValue(stats);
await expect(sut.getStatistics(authStub.admin, { isArchived: false })).resolves.toEqual(statResponse); await expect(sut.getStatistics(authStub.admin, { isArchived: false })).resolves.toEqual(statResponse);
expect(mocks.asset.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isArchived: false }); expect(assetMock.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isArchived: false });
}); });
it('should get the statistics for a user for archived assets', async () => { it('should get the statistics for a user for archived assets', async () => {
mocks.asset.getStatistics.mockResolvedValue(stats); assetMock.getStatistics.mockResolvedValue(stats);
await expect(sut.getStatistics(authStub.admin, { isArchived: true })).resolves.toEqual(statResponse); await expect(sut.getStatistics(authStub.admin, { isArchived: true })).resolves.toEqual(statResponse);
expect(mocks.asset.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isArchived: true }); expect(assetMock.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isArchived: true });
}); });
it('should get the statistics for a user for favorite assets', async () => { it('should get the statistics for a user for favorite assets', async () => {
mocks.asset.getStatistics.mockResolvedValue(stats); assetMock.getStatistics.mockResolvedValue(stats);
await expect(sut.getStatistics(authStub.admin, { isFavorite: true })).resolves.toEqual(statResponse); await expect(sut.getStatistics(authStub.admin, { isFavorite: true })).resolves.toEqual(statResponse);
expect(mocks.asset.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isFavorite: true }); expect(assetMock.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, { isFavorite: true });
}); });
it('should get the statistics for a user for all assets', async () => { it('should get the statistics for a user for all assets', async () => {
mocks.asset.getStatistics.mockResolvedValue(stats); assetMock.getStatistics.mockResolvedValue(stats);
await expect(sut.getStatistics(authStub.admin, {})).resolves.toEqual(statResponse); await expect(sut.getStatistics(authStub.admin, {})).resolves.toEqual(statResponse);
expect(mocks.asset.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, {}); expect(assetMock.getStatistics).toHaveBeenCalledWith(authStub.admin.user.id, {});
}); });
}); });
describe('getRandom', () => { describe('getRandom', () => {
it('should get own random assets', async () => { it('should get own random assets', async () => {
mocks.asset.getRandom.mockResolvedValue([assetStub.image]); assetMock.getRandom.mockResolvedValue([assetStub.image]);
await sut.getRandom(authStub.admin, 1); await sut.getRandom(authStub.admin, 1);
expect(mocks.asset.getRandom).toHaveBeenCalledWith([authStub.admin.user.id], 1); expect(assetMock.getRandom).toHaveBeenCalledWith([authStub.admin.user.id], 1);
}); });
it('should not include partner assets if not in timeline', async () => { it('should not include partner assets if not in timeline', async () => {
mocks.asset.getRandom.mockResolvedValue([assetStub.image]); assetMock.getRandom.mockResolvedValue([assetStub.image]);
mocks.partner.getAll.mockResolvedValue([{ ...partnerStub.user1ToAdmin1, inTimeline: false }]); partnerMock.getAll.mockResolvedValue([{ ...partnerStub.user1ToAdmin1, inTimeline: false }]);
await sut.getRandom(authStub.admin, 1); await sut.getRandom(authStub.admin, 1);
expect(mocks.asset.getRandom).toHaveBeenCalledWith([authStub.admin.user.id], 1); expect(assetMock.getRandom).toHaveBeenCalledWith([authStub.admin.user.id], 1);
}); });
it('should include partner assets if in timeline', async () => { it('should include partner assets if in timeline', async () => {
mocks.asset.getRandom.mockResolvedValue([assetStub.image]); assetMock.getRandom.mockResolvedValue([assetStub.image]);
mocks.partner.getAll.mockResolvedValue([partnerStub.user1ToAdmin1]); partnerMock.getAll.mockResolvedValue([partnerStub.user1ToAdmin1]);
await sut.getRandom(authStub.admin, 1); await sut.getRandom(authStub.admin, 1);
expect(mocks.asset.getRandom).toHaveBeenCalledWith([userStub.admin.id, userStub.user1.id], 1); expect(assetMock.getRandom).toHaveBeenCalledWith([userStub.admin.id, userStub.user1.id], 1);
}); });
}); });
describe('get', () => { describe('get', () => {
it('should allow owner access', async () => { it('should allow owner access', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await sut.get(authStub.admin, assetStub.image.id); await sut.get(authStub.admin, assetStub.image.id);
expect(mocks.access.asset.checkOwnerAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkOwnerAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set([assetStub.image.id]), new Set([assetStub.image.id]),
); );
}); });
it('should allow shared link access', async () => { it('should allow shared link access', async () => {
mocks.access.asset.checkSharedLinkAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkSharedLinkAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await sut.get(authStub.adminSharedLink, assetStub.image.id); await sut.get(authStub.adminSharedLink, assetStub.image.id);
expect(mocks.access.asset.checkSharedLinkAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkSharedLinkAccess).toHaveBeenCalledWith(
authStub.adminSharedLink.sharedLink?.id, authStub.adminSharedLink.sharedLink?.id,
new Set([assetStub.image.id]), new Set([assetStub.image.id]),
); );
}); });
it('should strip metadata for shared link if exif is disabled', async () => { it('should strip metadata for shared link if exif is disabled', async () => {
mocks.access.asset.checkSharedLinkAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkSharedLinkAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
const result = await sut.get( const result = await sut.get(
{ ...authStub.adminSharedLink, sharedLink: { ...authStub.adminSharedLink.sharedLink!, showExif: false } }, { ...authStub.adminSharedLink, sharedLink: { ...authStub.adminSharedLink.sharedLink!, showExif: false } },
@@ -179,27 +194,27 @@ describe(AssetService.name, () => {
expect(result).toEqual(expect.objectContaining({ hasMetadata: false })); expect(result).toEqual(expect.objectContaining({ hasMetadata: false }));
expect(result).not.toHaveProperty('exifInfo'); expect(result).not.toHaveProperty('exifInfo');
expect(mocks.access.asset.checkSharedLinkAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkSharedLinkAccess).toHaveBeenCalledWith(
authStub.adminSharedLink.sharedLink?.id, authStub.adminSharedLink.sharedLink?.id,
new Set([assetStub.image.id]), new Set([assetStub.image.id]),
); );
}); });
it('should allow partner sharing access', async () => { it('should allow partner sharing access', async () => {
mocks.access.asset.checkPartnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkPartnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await sut.get(authStub.admin, assetStub.image.id); await sut.get(authStub.admin, assetStub.image.id);
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkPartnerAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set([assetStub.image.id]), new Set([assetStub.image.id]),
); );
}); });
it('should allow shared album access', async () => { it('should allow shared album access', async () => {
mocks.access.asset.checkAlbumAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkAlbumAccess.mockResolvedValue(new Set([assetStub.image.id]));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await sut.get(authStub.admin, assetStub.image.id); await sut.get(authStub.admin, assetStub.image.id);
expect(mocks.access.asset.checkAlbumAccess).toHaveBeenCalledWith( expect(accessMock.asset.checkAlbumAccess).toHaveBeenCalledWith(
authStub.admin.user.id, authStub.admin.user.id,
new Set([assetStub.image.id]), new Set([assetStub.image.id]),
); );
@@ -207,17 +222,17 @@ describe(AssetService.name, () => {
it('should throw an error for no access', async () => { it('should throw an error for no access', async () => {
await expect(sut.get(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.get(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.getById).not.toHaveBeenCalled(); expect(assetMock.getById).not.toHaveBeenCalled();
}); });
it('should throw an error for an invalid shared link', async () => { it('should throw an error for an invalid shared link', async () => {
await expect(sut.get(authStub.adminSharedLink, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.get(authStub.adminSharedLink, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.access.asset.checkOwnerAccess).not.toHaveBeenCalled(); expect(accessMock.asset.checkOwnerAccess).not.toHaveBeenCalled();
expect(mocks.asset.getById).not.toHaveBeenCalled(); expect(assetMock.getById).not.toHaveBeenCalled();
}); });
it('should throw an error if the asset could not be found', async () => { it('should throw an error if the asset could not be found', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));
await expect(sut.get(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.get(authStub.admin, assetStub.image.id)).rejects.toBeInstanceOf(BadRequestException);
}); });
}); });
@@ -227,40 +242,40 @@ describe(AssetService.name, () => {
await expect(sut.update(authStub.admin, 'asset-1', { isArchived: false })).rejects.toBeInstanceOf( await expect(sut.update(authStub.admin, 'asset-1', { isArchived: false })).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
}); });
it('should update the asset', async () => { it('should update the asset', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
mocks.asset.update.mockResolvedValue(assetStub.image); assetMock.update.mockResolvedValue(assetStub.image);
await sut.update(authStub.admin, 'asset-1', { isFavorite: true }); await sut.update(authStub.admin, 'asset-1', { isFavorite: true });
expect(mocks.asset.update).toHaveBeenCalledWith({ id: 'asset-1', isFavorite: true }); expect(assetMock.update).toHaveBeenCalledWith({ id: 'asset-1', isFavorite: true });
}); });
it('should update the exif description', async () => { it('should update the exif description', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
mocks.asset.update.mockResolvedValue(assetStub.image); assetMock.update.mockResolvedValue(assetStub.image);
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' }); await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', description: 'Test description' }); expect(assetMock.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', description: 'Test description' });
}); });
it('should update the exif rating', async () => { it('should update the exif rating', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.asset.getById.mockResolvedValueOnce(assetStub.image); assetMock.getById.mockResolvedValueOnce(assetStub.image);
mocks.asset.update.mockResolvedValueOnce(assetStub.image); assetMock.update.mockResolvedValueOnce(assetStub.image);
await sut.update(authStub.admin, 'asset-1', { rating: 3 }); await sut.update(authStub.admin, 'asset-1', { rating: 3 });
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', rating: 3 }); expect(assetMock.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', rating: 3 });
}); });
it('should fail linking a live video if the motion part could not be found', async () => { it('should fail linking a live video if the motion part could not be found', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
await expect( await expect(
sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, {
@@ -268,20 +283,20 @@ describe(AssetService.name, () => {
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.update).not.toHaveBeenCalledWith({ expect(assetMock.update).not.toHaveBeenCalledWith({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
livePhotoVideoId: assetStub.livePhotoMotionAsset.id, livePhotoVideoId: assetStub.livePhotoMotionAsset.id,
}); });
expect(mocks.asset.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true }); expect(assetMock.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true });
expect(mocks.event.emit).not.toHaveBeenCalledWith('asset.show', { expect(eventMock.emit).not.toHaveBeenCalledWith('asset.show', {
assetId: assetStub.livePhotoMotionAsset.id, assetId: assetStub.livePhotoMotionAsset.id,
userId: userStub.admin.id, userId: userStub.admin.id,
}); });
}); });
it('should fail linking a live video if the motion part is not a video', async () => { it('should fail linking a live video if the motion part is not a video', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
mocks.asset.getById.mockResolvedValue(assetStub.livePhotoStillAsset); assetMock.getById.mockResolvedValue(assetStub.livePhotoStillAsset);
await expect( await expect(
sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, {
@@ -289,20 +304,20 @@ describe(AssetService.name, () => {
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.update).not.toHaveBeenCalledWith({ expect(assetMock.update).not.toHaveBeenCalledWith({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
livePhotoVideoId: assetStub.livePhotoMotionAsset.id, livePhotoVideoId: assetStub.livePhotoMotionAsset.id,
}); });
expect(mocks.asset.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true }); expect(assetMock.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true });
expect(mocks.event.emit).not.toHaveBeenCalledWith('asset.show', { expect(eventMock.emit).not.toHaveBeenCalledWith('asset.show', {
assetId: assetStub.livePhotoMotionAsset.id, assetId: assetStub.livePhotoMotionAsset.id,
userId: userStub.admin.id, userId: userStub.admin.id,
}); });
}); });
it('should fail linking a live video if the motion part has a different owner', async () => { it('should fail linking a live video if the motion part has a different owner', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
mocks.asset.getById.mockResolvedValue(assetStub.livePhotoMotionAsset); assetMock.getById.mockResolvedValue(assetStub.livePhotoMotionAsset);
await expect( await expect(
sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, {
@@ -310,79 +325,79 @@ describe(AssetService.name, () => {
}), }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.update).not.toHaveBeenCalledWith({ expect(assetMock.update).not.toHaveBeenCalledWith({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
livePhotoVideoId: assetStub.livePhotoMotionAsset.id, livePhotoVideoId: assetStub.livePhotoMotionAsset.id,
}); });
expect(mocks.asset.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true }); expect(assetMock.update).not.toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true });
expect(mocks.event.emit).not.toHaveBeenCalledWith('asset.show', { expect(eventMock.emit).not.toHaveBeenCalledWith('asset.show', {
assetId: assetStub.livePhotoMotionAsset.id, assetId: assetStub.livePhotoMotionAsset.id,
userId: userStub.admin.id, userId: userStub.admin.id,
}); });
}); });
it('should link a live video', async () => { it('should link a live video', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
mocks.asset.getById.mockResolvedValueOnce({ assetMock.getById.mockResolvedValueOnce({
...assetStub.livePhotoMotionAsset, ...assetStub.livePhotoMotionAsset,
ownerId: authStub.admin.user.id, ownerId: authStub.admin.user.id,
isVisible: true, isVisible: true,
}); });
mocks.asset.getById.mockResolvedValueOnce(assetStub.image); assetMock.getById.mockResolvedValueOnce(assetStub.image);
mocks.asset.update.mockResolvedValue(assetStub.image); assetMock.update.mockResolvedValue(assetStub.image);
await sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { await sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, {
livePhotoVideoId: assetStub.livePhotoMotionAsset.id, livePhotoVideoId: assetStub.livePhotoMotionAsset.id,
}); });
expect(mocks.asset.update).toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: false }); expect(assetMock.update).toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: false });
expect(mocks.event.emit).toHaveBeenCalledWith('asset.hide', { expect(eventMock.emit).toHaveBeenCalledWith('asset.hide', {
assetId: assetStub.livePhotoMotionAsset.id, assetId: assetStub.livePhotoMotionAsset.id,
userId: userStub.admin.id, userId: userStub.admin.id,
}); });
expect(mocks.asset.update).toHaveBeenCalledWith({ expect(assetMock.update).toHaveBeenCalledWith({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
livePhotoVideoId: assetStub.livePhotoMotionAsset.id, livePhotoVideoId: assetStub.livePhotoMotionAsset.id,
}); });
}); });
it('should throw an error if asset could not be found after update', async () => { it('should throw an error if asset could not be found after update', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await expect(sut.update(authStub.admin, 'asset-1', { isFavorite: true })).rejects.toBeInstanceOf( await expect(sut.update(authStub.admin, 'asset-1', { isFavorite: true })).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
}); });
it('should unlink a live video', async () => { it('should unlink a live video', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
mocks.asset.getById.mockResolvedValueOnce(assetStub.livePhotoStillAsset); assetMock.getById.mockResolvedValueOnce(assetStub.livePhotoStillAsset);
mocks.asset.getById.mockResolvedValueOnce(assetStub.livePhotoMotionAsset); assetMock.getById.mockResolvedValueOnce(assetStub.livePhotoMotionAsset);
mocks.asset.update.mockResolvedValueOnce(assetStub.image); assetMock.update.mockResolvedValueOnce(assetStub.image);
await sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { livePhotoVideoId: null }); await sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { livePhotoVideoId: null });
expect(mocks.asset.update).toHaveBeenCalledWith({ expect(assetMock.update).toHaveBeenCalledWith({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
livePhotoVideoId: null, livePhotoVideoId: null,
}); });
expect(mocks.asset.update).toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true }); expect(assetMock.update).toHaveBeenCalledWith({ id: assetStub.livePhotoMotionAsset.id, isVisible: true });
expect(mocks.event.emit).toHaveBeenCalledWith('asset.show', { expect(eventMock.emit).toHaveBeenCalledWith('asset.show', {
assetId: assetStub.livePhotoMotionAsset.id, assetId: assetStub.livePhotoMotionAsset.id,
userId: userStub.admin.id, userId: userStub.admin.id,
}); });
}); });
it('should fail unlinking a live video if the asset could not be found', async () => { it('should fail unlinking a live video if the asset could not be found', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.livePhotoStillAsset.id]));
// eslint-disable-next-line unicorn/no-useless-undefined // eslint-disable-next-line unicorn/no-useless-undefined
mocks.asset.getById.mockResolvedValueOnce(undefined); assetMock.getById.mockResolvedValueOnce(undefined);
await expect( await expect(
sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { livePhotoVideoId: null }), sut.update(authStub.admin, assetStub.livePhotoStillAsset.id, { livePhotoVideoId: null }),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.event.emit).not.toHaveBeenCalled(); expect(eventMock.emit).not.toHaveBeenCalled();
}); });
}); });
@@ -397,13 +412,13 @@ describe(AssetService.name, () => {
}); });
it('should update all assets', async () => { it('should update all assets', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2']));
await sut.updateAll(authStub.admin, { ids: ['asset-1', 'asset-2'], isArchived: true }); await sut.updateAll(authStub.admin, { ids: ['asset-1', 'asset-2'], isArchived: true });
expect(mocks.asset.updateAll).toHaveBeenCalledWith(['asset-1', 'asset-2'], { isArchived: true }); expect(assetMock.updateAll).toHaveBeenCalledWith(['asset-1', 'asset-2'], { isArchived: true });
}); });
it('should not update Assets table if no relevant fields are provided', async () => { it('should not update Assets table if no relevant fields are provided', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.updateAll(authStub.admin, { await sut.updateAll(authStub.admin, {
ids: ['asset-1'], ids: ['asset-1'],
latitude: 0, latitude: 0,
@@ -413,11 +428,11 @@ describe(AssetService.name, () => {
duplicateId: undefined, duplicateId: undefined,
rating: undefined, rating: undefined,
}); });
expect(mocks.asset.updateAll).not.toHaveBeenCalled(); expect(assetMock.updateAll).not.toHaveBeenCalled();
}); });
it('should update Assets table if isArchived field is provided', async () => { it('should update Assets table if isArchived field is provided', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.updateAll(authStub.admin, { await sut.updateAll(authStub.admin, {
ids: ['asset-1'], ids: ['asset-1'],
latitude: 0, latitude: 0,
@@ -427,7 +442,7 @@ describe(AssetService.name, () => {
duplicateId: undefined, duplicateId: undefined,
rating: undefined, rating: undefined,
}); });
expect(mocks.asset.updateAll).toHaveBeenCalled(); expect(assetMock.updateAll).toHaveBeenCalled();
}); });
}); });
@@ -441,26 +456,26 @@ describe(AssetService.name, () => {
}); });
it('should force delete a batch of assets', async () => { it('should force delete a batch of assets', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset1', 'asset2'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset1', 'asset2']));
await sut.deleteAll(authStub.user1, { ids: ['asset1', 'asset2'], force: true }); await sut.deleteAll(authStub.user1, { ids: ['asset1', 'asset2'], force: true });
expect(mocks.event.emit).toHaveBeenCalledWith('assets.delete', { expect(eventMock.emit).toHaveBeenCalledWith('assets.delete', {
assetIds: ['asset1', 'asset2'], assetIds: ['asset1', 'asset2'],
userId: 'user-id', userId: 'user-id',
}); });
}); });
it('should soft delete a batch of assets', async () => { it('should soft delete a batch of assets', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset1', 'asset2'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset1', 'asset2']));
await sut.deleteAll(authStub.user1, { ids: ['asset1', 'asset2'], force: false }); await sut.deleteAll(authStub.user1, { ids: ['asset1', 'asset2'], force: false });
expect(mocks.asset.updateAll).toHaveBeenCalledWith(['asset1', 'asset2'], { expect(assetMock.updateAll).toHaveBeenCalledWith(['asset1', 'asset2'], {
deletedAt: expect.any(Date), deletedAt: expect.any(Date),
status: AssetStatus.TRASHED, status: AssetStatus.TRASHED,
}); });
expect(mocks.job.queue.mock.calls).toEqual([]); expect(jobMock.queue.mock.calls).toEqual([]);
}); });
}); });
@@ -474,27 +489,27 @@ describe(AssetService.name, () => {
}); });
it('should immediately queue assets for deletion if trash is disabled', async () => { it('should immediately queue assets for deletion if trash is disabled', async () => {
mocks.asset.getAll.mockResolvedValue({ hasNextPage: false, items: [assetStub.image] }); assetMock.getAll.mockResolvedValue({ hasNextPage: false, items: [assetStub.image] });
mocks.systemMetadata.get.mockResolvedValue({ trash: { enabled: false } }); systemMock.get.mockResolvedValue({ trash: { enabled: false } });
await expect(sut.handleAssetDeletionCheck()).resolves.toBe(JobStatus.SUCCESS); await expect(sut.handleAssetDeletionCheck()).resolves.toBe(JobStatus.SUCCESS);
expect(mocks.asset.getAll).toHaveBeenCalledWith(expect.anything(), { trashedBefore: new Date() }); expect(assetMock.getAll).toHaveBeenCalledWith(expect.anything(), { trashedBefore: new Date() });
expect(mocks.job.queueAll).toHaveBeenCalledWith([ expect(jobMock.queueAll).toHaveBeenCalledWith([
{ name: JobName.ASSET_DELETION, data: { id: assetStub.image.id, deleteOnDisk: true } }, { name: JobName.ASSET_DELETION, data: { id: assetStub.image.id, deleteOnDisk: true } },
]); ]);
}); });
it('should queue assets for deletion after trash duration', async () => { it('should queue assets for deletion after trash duration', async () => {
mocks.asset.getAll.mockResolvedValue({ hasNextPage: false, items: [assetStub.image] }); assetMock.getAll.mockResolvedValue({ hasNextPage: false, items: [assetStub.image] });
mocks.systemMetadata.get.mockResolvedValue({ trash: { enabled: true, days: 7 } }); systemMock.get.mockResolvedValue({ trash: { enabled: true, days: 7 } });
await expect(sut.handleAssetDeletionCheck()).resolves.toBe(JobStatus.SUCCESS); await expect(sut.handleAssetDeletionCheck()).resolves.toBe(JobStatus.SUCCESS);
expect(mocks.asset.getAll).toHaveBeenCalledWith(expect.anything(), { expect(assetMock.getAll).toHaveBeenCalledWith(expect.anything(), {
trashedBefore: DateTime.now().minus({ days: 7 }).toJSDate(), trashedBefore: DateTime.now().minus({ days: 7 }).toJSDate(),
}); });
expect(mocks.job.queueAll).toHaveBeenCalledWith([ expect(jobMock.queueAll).toHaveBeenCalledWith([
{ name: JobName.ASSET_DELETION, data: { id: assetStub.image.id, deleteOnDisk: true } }, { name: JobName.ASSET_DELETION, data: { id: assetStub.image.id, deleteOnDisk: true } },
]); ]);
}); });
@@ -504,11 +519,11 @@ describe(AssetService.name, () => {
it('should remove faces', async () => { it('should remove faces', async () => {
const assetWithFace = { ...assetStub.image, faces: [faceStub.face1, faceStub.mergeFace1] }; const assetWithFace = { ...assetStub.image, faces: [faceStub.face1, faceStub.mergeFace1] };
mocks.asset.getById.mockResolvedValue(assetWithFace); assetMock.getById.mockResolvedValue(assetWithFace);
await sut.handleAssetDeletion({ id: assetWithFace.id, deleteOnDisk: true }); await sut.handleAssetDeletion({ id: assetWithFace.id, deleteOnDisk: true });
expect(mocks.job.queue.mock.calls).toEqual([ expect(jobMock.queue.mock.calls).toEqual([
[ [
{ {
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
@@ -525,41 +540,41 @@ describe(AssetService.name, () => {
], ],
]); ]);
expect(mocks.asset.remove).toHaveBeenCalledWith(assetWithFace); expect(assetMock.remove).toHaveBeenCalledWith(assetWithFace);
}); });
it('should update stack primary asset if deleted asset was primary asset in a stack', async () => { it('should update stack primary asset if deleted asset was primary asset in a stack', async () => {
mocks.asset.getById.mockResolvedValue(assetStub.primaryImage as AssetEntity); assetMock.getById.mockResolvedValue(assetStub.primaryImage as AssetEntity);
await sut.handleAssetDeletion({ id: assetStub.primaryImage.id, deleteOnDisk: true }); await sut.handleAssetDeletion({ id: assetStub.primaryImage.id, deleteOnDisk: true });
expect(mocks.stack.update).toHaveBeenCalledWith('stack-1', { expect(stackMock.update).toHaveBeenCalledWith('stack-1', {
id: 'stack-1', id: 'stack-1',
primaryAssetId: 'stack-child-asset-1', primaryAssetId: 'stack-child-asset-1',
}); });
}); });
it('should delete the entire stack if deleted asset was the primary asset and the stack would only contain one asset afterwards', async () => { it('should delete the entire stack if deleted asset was the primary asset and the stack would only contain one asset afterwards', async () => {
mocks.asset.getById.mockResolvedValue({ assetMock.getById.mockResolvedValue({
...assetStub.primaryImage, ...assetStub.primaryImage,
stack: { ...assetStub.primaryImage.stack, assets: assetStub.primaryImage.stack!.assets.slice(0, 2) }, stack: { ...assetStub.primaryImage.stack, assets: assetStub.primaryImage.stack!.assets.slice(0, 2) },
} as AssetEntity); } as AssetEntity);
await sut.handleAssetDeletion({ id: assetStub.primaryImage.id, deleteOnDisk: true }); await sut.handleAssetDeletion({ id: assetStub.primaryImage.id, deleteOnDisk: true });
expect(mocks.stack.delete).toHaveBeenCalledWith('stack-1'); expect(stackMock.delete).toHaveBeenCalledWith('stack-1');
}); });
it('should delete a live photo', async () => { it('should delete a live photo', async () => {
mocks.asset.getById.mockResolvedValue(assetStub.livePhotoStillAsset); assetMock.getById.mockResolvedValue(assetStub.livePhotoStillAsset);
mocks.asset.getLivePhotoCount.mockResolvedValue(0); assetMock.getLivePhotoCount.mockResolvedValue(0);
await sut.handleAssetDeletion({ await sut.handleAssetDeletion({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
deleteOnDisk: true, deleteOnDisk: true,
}); });
expect(mocks.job.queue.mock.calls).toEqual([ expect(jobMock.queue.mock.calls).toEqual([
[ [
{ {
name: JobName.ASSET_DELETION, name: JobName.ASSET_DELETION,
@@ -581,15 +596,15 @@ describe(AssetService.name, () => {
}); });
it('should not delete a live motion part if it is being used by another asset', async () => { it('should not delete a live motion part if it is being used by another asset', async () => {
mocks.asset.getLivePhotoCount.mockResolvedValue(2); assetMock.getLivePhotoCount.mockResolvedValue(2);
mocks.asset.getById.mockResolvedValue(assetStub.livePhotoStillAsset); assetMock.getById.mockResolvedValue(assetStub.livePhotoStillAsset);
await sut.handleAssetDeletion({ await sut.handleAssetDeletion({
id: assetStub.livePhotoStillAsset.id, id: assetStub.livePhotoStillAsset.id,
deleteOnDisk: true, deleteOnDisk: true,
}); });
expect(mocks.job.queue.mock.calls).toEqual([ expect(jobMock.queue.mock.calls).toEqual([
[ [
{ {
name: JobName.DELETE_FILES, name: JobName.DELETE_FILES,
@@ -602,9 +617,9 @@ describe(AssetService.name, () => {
}); });
it('should update usage', async () => { it('should update usage', async () => {
mocks.asset.getById.mockResolvedValue(assetStub.image); assetMock.getById.mockResolvedValue(assetStub.image);
await sut.handleAssetDeletion({ id: assetStub.image.id, deleteOnDisk: true }); await sut.handleAssetDeletion({ id: assetStub.image.id, deleteOnDisk: true });
expect(mocks.user.updateUsage).toHaveBeenCalledWith(assetStub.image.ownerId, -5000); expect(userMock.updateUsage).toHaveBeenCalledWith(assetStub.image.ownerId, -5000);
}); });
it('should fail if asset could not be found', async () => { it('should fail if asset could not be found', async () => {
@@ -616,27 +631,27 @@ describe(AssetService.name, () => {
describe('run', () => { describe('run', () => {
it('should run the refresh faces job', async () => { it('should run the refresh faces job', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REFRESH_FACES }); await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REFRESH_FACES });
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.FACE_DETECTION, data: { id: 'asset-1' } }]); expect(jobMock.queueAll).toHaveBeenCalledWith([{ name: JobName.FACE_DETECTION, data: { id: 'asset-1' } }]);
}); });
it('should run the refresh metadata job', async () => { it('should run the refresh metadata job', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REFRESH_METADATA }); await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REFRESH_METADATA });
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.METADATA_EXTRACTION, data: { id: 'asset-1' } }]); expect(jobMock.queueAll).toHaveBeenCalledWith([{ name: JobName.METADATA_EXTRACTION, data: { id: 'asset-1' } }]);
}); });
it('should run the refresh thumbnails job', async () => { it('should run the refresh thumbnails job', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REGENERATE_THUMBNAIL }); await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.REGENERATE_THUMBNAIL });
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1' } }]); expect(jobMock.queueAll).toHaveBeenCalledWith([{ name: JobName.GENERATE_THUMBNAILS, data: { id: 'asset-1' } }]);
}); });
it('should run the transcode video', async () => { it('should run the transcode video', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1'])); accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.TRANSCODE_VIDEO }); await sut.run(authStub.admin, { assetIds: ['asset-1'], name: AssetJobName.TRANSCODE_VIDEO });
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.VIDEO_CONVERSION, data: { id: 'asset-1' } }]); expect(jobMock.queueAll).toHaveBeenCalledWith([{ name: JobName.VIDEO_CONVERSION, data: { id: 'asset-1' } }]);
}); });
}); });
@@ -644,7 +659,7 @@ describe(AssetService.name, () => {
it('get assets by device id', async () => { it('get assets by device id', async () => {
const assets = [assetStub.image, assetStub.image1]; const assets = [assetStub.image, assetStub.image1];
mocks.asset.getAllByDeviceId.mockResolvedValue(assets.map((asset) => asset.deviceAssetId)); assetMock.getAllByDeviceId.mockResolvedValue(assets.map((asset) => asset.deviceAssetId));
const deviceId = 'device-id'; const deviceId = 'device-id';
const result = await sut.getUserAssetsByDeviceId(authStub.user1, deviceId); const result = await sut.getUserAssetsByDeviceId(authStub.user1, deviceId);
+52 -42
View File
@@ -1,18 +1,28 @@
import { BadRequestException } from '@nestjs/common'; import { BadRequestException } from '@nestjs/common';
import { FileReportItemDto } from 'src/dtos/audit.dto'; import { FileReportItemDto } from 'src/dtos/audit.dto';
import { AssetFileType, AssetPathType, DatabaseAction, EntityType, PersonPathType, UserPathType } from 'src/enum'; import { AssetFileType, AssetPathType, DatabaseAction, EntityType, PersonPathType, UserPathType } from 'src/enum';
import { IAssetRepository } from 'src/interfaces/asset.interface';
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
import { JobStatus } from 'src/interfaces/job.interface'; import { JobStatus } from 'src/interfaces/job.interface';
import { IPersonRepository } from 'src/interfaces/person.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { AuditService } from 'src/services/audit.service'; import { AuditService } from 'src/services/audit.service';
import { IAuditRepository } from 'src/types';
import { auditStub } from 'test/fixtures/audit.stub'; import { auditStub } from 'test/fixtures/audit.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
describe(AuditService.name, () => { describe(AuditService.name, () => {
let sut: AuditService; let sut: AuditService;
let mocks: ServiceMocks; let auditMock: Mocked<IAuditRepository>;
let assetMock: Mocked<IAssetRepository>;
let cryptoMock: Mocked<ICryptoRepository>;
let personMock: Mocked<IPersonRepository>;
let userMock: Mocked<IUserRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(AuditService)); ({ sut, auditMock, assetMock, cryptoMock, personMock, userMock } = newTestService(AuditService));
}); });
it('should work', () => { it('should work', () => {
@@ -22,13 +32,13 @@ describe(AuditService.name, () => {
describe('handleCleanup', () => { describe('handleCleanup', () => {
it('should delete old audit entries', async () => { it('should delete old audit entries', async () => {
await expect(sut.handleCleanup()).resolves.toBe(JobStatus.SUCCESS); await expect(sut.handleCleanup()).resolves.toBe(JobStatus.SUCCESS);
expect(mocks.audit.removeBefore).toHaveBeenCalledWith(expect.any(Date)); expect(auditMock.removeBefore).toHaveBeenCalledWith(expect.any(Date));
}); });
}); });
describe('getDeletes', () => { describe('getDeletes', () => {
it('should require full sync if the request is older than 100 days', async () => { it('should require full sync if the request is older than 100 days', async () => {
mocks.audit.getAfter.mockResolvedValue([]); auditMock.getAfter.mockResolvedValue([]);
const date = new Date(2022, 0, 1); const date = new Date(2022, 0, 1);
await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({ await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({
@@ -36,7 +46,7 @@ describe(AuditService.name, () => {
ids: [], ids: [],
}); });
expect(mocks.audit.getAfter).toHaveBeenCalledWith(date, { expect(auditMock.getAfter).toHaveBeenCalledWith(date, {
action: DatabaseAction.DELETE, action: DatabaseAction.DELETE,
userIds: [authStub.admin.user.id], userIds: [authStub.admin.user.id],
entityType: EntityType.ASSET, entityType: EntityType.ASSET,
@@ -44,7 +54,7 @@ describe(AuditService.name, () => {
}); });
it('should get any new or updated assets and deleted ids', async () => { it('should get any new or updated assets and deleted ids', async () => {
mocks.audit.getAfter.mockResolvedValue([auditStub.delete.entityId]); auditMock.getAfter.mockResolvedValue([auditStub.delete.entityId]);
const date = new Date(); const date = new Date();
await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({ await expect(sut.getDeletes(authStub.admin, { after: date, entityType: EntityType.ASSET })).resolves.toEqual({
@@ -52,7 +62,7 @@ describe(AuditService.name, () => {
ids: ['asset-deleted'], ids: ['asset-deleted'],
}); });
expect(mocks.audit.getAfter).toHaveBeenCalledWith(date, { expect(auditMock.getAfter).toHaveBeenCalledWith(date, {
action: DatabaseAction.DELETE, action: DatabaseAction.DELETE,
userIds: [authStub.admin.user.id], userIds: [authStub.admin.user.id],
entityType: EntityType.ASSET, entityType: EntityType.ASSET,
@@ -64,7 +74,7 @@ describe(AuditService.name, () => {
it('should fail if the file is not in the immich path', async () => { it('should fail if the file is not in the immich path', async () => {
await expect(sut.getChecksums({ filenames: ['foo/bar'] })).rejects.toBeInstanceOf(BadRequestException); await expect(sut.getChecksums({ filenames: ['foo/bar'] })).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.crypto.hashFile).not.toHaveBeenCalled(); expect(cryptoMock.hashFile).not.toHaveBeenCalled();
}); });
it('should get checksum for valid file', async () => { it('should get checksum for valid file', async () => {
@@ -72,7 +82,7 @@ describe(AuditService.name, () => {
{ filename: './upload/my-file.jpg', checksum: expect.any(String) }, { filename: './upload/my-file.jpg', checksum: expect.any(String) },
]); ]);
expect(mocks.crypto.hashFile).toHaveBeenCalledWith('./upload/my-file.jpg'); expect(cryptoMock.hashFile).toHaveBeenCalledWith('./upload/my-file.jpg');
}); });
}); });
@@ -84,10 +94,10 @@ describe(AuditService.name, () => {
]), ]),
).rejects.toBeInstanceOf(BadRequestException); ).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update encoded video path', async () => { it('should update encoded video path', async () => {
@@ -99,10 +109,10 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.asset.update).toHaveBeenCalledWith({ id: 'my-id', encodedVideoPath: './upload/my-video.mp4' }); expect(assetMock.update).toHaveBeenCalledWith({ id: 'my-id', encodedVideoPath: './upload/my-video.mp4' });
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update preview path', async () => { it('should update preview path', async () => {
@@ -114,14 +124,14 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.asset.upsertFile).toHaveBeenCalledWith({ expect(assetMock.upsertFile).toHaveBeenCalledWith({
assetId: 'my-id', assetId: 'my-id',
type: AssetFileType.PREVIEW, type: AssetFileType.PREVIEW,
path: './upload/my-preview.png', path: './upload/my-preview.png',
}); });
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update thumbnail path', async () => { it('should update thumbnail path', async () => {
@@ -133,14 +143,14 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.asset.upsertFile).toHaveBeenCalledWith({ expect(assetMock.upsertFile).toHaveBeenCalledWith({
assetId: 'my-id', assetId: 'my-id',
type: AssetFileType.THUMBNAIL, type: AssetFileType.THUMBNAIL,
path: './upload/my-thumbnail.webp', path: './upload/my-thumbnail.webp',
}); });
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update original path', async () => { it('should update original path', async () => {
@@ -152,10 +162,10 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.asset.update).toHaveBeenCalledWith({ id: 'my-id', originalPath: './upload/my-original.png' }); expect(assetMock.update).toHaveBeenCalledWith({ id: 'my-id', originalPath: './upload/my-original.png' });
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update sidecar path', async () => { it('should update sidecar path', async () => {
@@ -167,10 +177,10 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.asset.update).toHaveBeenCalledWith({ id: 'my-id', sidecarPath: './upload/my-sidecar.xmp' }); expect(assetMock.update).toHaveBeenCalledWith({ id: 'my-id', sidecarPath: './upload/my-sidecar.xmp' });
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update face path', async () => { it('should update face path', async () => {
@@ -182,10 +192,10 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.person.update).toHaveBeenCalledWith({ id: 'my-id', thumbnailPath: './upload/my-face.jpg' }); expect(personMock.update).toHaveBeenCalledWith({ id: 'my-id', thumbnailPath: './upload/my-face.jpg' });
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
it('should update profile path', async () => { it('should update profile path', async () => {
@@ -197,10 +207,10 @@ describe(AuditService.name, () => {
} as FileReportItemDto, } as FileReportItemDto,
]); ]);
expect(mocks.user.update).toHaveBeenCalledWith('my-id', { profileImagePath: './upload/my-profile-pic.jpg' }); expect(userMock.update).toHaveBeenCalledWith('my-id', { profileImagePath: './upload/my-profile-pic.jpg' });
expect(mocks.asset.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
expect(mocks.asset.upsertFile).not.toHaveBeenCalled(); expect(assetMock.upsertFile).not.toHaveBeenCalled();
expect(mocks.person.update).not.toHaveBeenCalled(); expect(personMock.update).not.toHaveBeenCalled();
}); });
}); });
}); });
+146 -129
View File
@@ -3,14 +3,22 @@ import { AuthDto, SignUpDto } from 'src/dtos/auth.dto';
import { UserMetadataEntity } from 'src/entities/user-metadata.entity'; import { UserMetadataEntity } from 'src/entities/user-metadata.entity';
import { UserEntity } from 'src/entities/user.entity'; import { UserEntity } from 'src/entities/user.entity';
import { AuthType, Permission } from 'src/enum'; import { AuthType, Permission } from 'src/enum';
import { ICryptoRepository } from 'src/interfaces/crypto.interface';
import { IEventRepository } from 'src/interfaces/event.interface';
import { ISessionRepository } from 'src/interfaces/session.interface';
import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { AuthService } from 'src/services/auth.service'; import { AuthService } from 'src/services/auth.service';
import { IApiKeyRepository, IOAuthRepository } from 'src/types';
import { keyStub } from 'test/fixtures/api-key.stub'; import { keyStub } from 'test/fixtures/api-key.stub';
import { authStub } from 'test/fixtures/auth.stub'; import { authStub } from 'test/fixtures/auth.stub';
import { sessionStub } from 'test/fixtures/session.stub'; import { sessionStub } from 'test/fixtures/session.stub';
import { sharedLinkStub } from 'test/fixtures/shared-link.stub'; import { sharedLinkStub } from 'test/fixtures/shared-link.stub';
import { systemConfigStub } from 'test/fixtures/system-config.stub'; import { systemConfigStub } from 'test/fixtures/system-config.stub';
import { userStub } from 'test/fixtures/user.stub'; import { userStub } from 'test/fixtures/user.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
const oauthResponse = { const oauthResponse = {
accessToken: 'cmFuZG9tLWJ5dGVz', accessToken: 'cmFuZG9tLWJ5dGVz',
@@ -50,14 +58,23 @@ const oauthUserWithDefaultQuota = {
describe('AuthService', () => { describe('AuthService', () => {
let sut: AuthService; let sut: AuthService;
let mocks: ServiceMocks;
let cryptoMock: Mocked<ICryptoRepository>;
let eventMock: Mocked<IEventRepository>;
let keyMock: Mocked<IApiKeyRepository>;
let oauthMock: Mocked<IOAuthRepository>;
let sessionMock: Mocked<ISessionRepository>;
let sharedLinkMock: Mocked<ISharedLinkRepository>;
let systemMock: Mocked<ISystemMetadataRepository>;
let userMock: Mocked<IUserRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(AuthService)); ({ sut, cryptoMock, eventMock, keyMock, oauthMock, sessionMock, sharedLinkMock, systemMock, userMock } =
newTestService(AuthService));
mocks.oauth.authorize.mockResolvedValue('access-token'); oauthMock.authorize.mockResolvedValue('access-token');
mocks.oauth.getProfile.mockResolvedValue({ sub, email }); oauthMock.getProfile.mockResolvedValue({ sub, email });
mocks.oauth.getLogoutEndpoint.mockResolvedValue('http://end-session-endpoint'); oauthMock.getLogoutEndpoint.mockResolvedValue('http://end-session-endpoint');
}); });
it('should be defined', () => { it('should be defined', () => {
@@ -67,31 +84,31 @@ describe('AuthService', () => {
describe('onBootstrap', () => { describe('onBootstrap', () => {
it('should init the repo', () => { it('should init the repo', () => {
sut.onBootstrap(); sut.onBootstrap();
expect(mocks.oauth.init).toHaveBeenCalled(); expect(oauthMock.init).toHaveBeenCalled();
}); });
}); });
describe('login', () => { describe('login', () => {
it('should throw an error if password login is disabled', async () => { it('should throw an error if password login is disabled', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.disabled); systemMock.get.mockResolvedValue(systemConfigStub.disabled);
await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException); await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException);
}); });
it('should check the user exists', async () => { it('should check the user exists', async () => {
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException); await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException);
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1); expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
}); });
it('should check the user has a password', async () => { it('should check the user has a password', async () => {
mocks.user.getByEmail.mockResolvedValue({} as UserEntity); userMock.getByEmail.mockResolvedValue({} as UserEntity);
await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException); await expect(sut.login(fixtures.login, loginDetails)).rejects.toBeInstanceOf(UnauthorizedException);
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1); expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
}); });
it('should successfully log the user in', async () => { it('should successfully log the user in', async () => {
mocks.user.getByEmail.mockResolvedValue(userStub.user1); userMock.getByEmail.mockResolvedValue(userStub.user1);
mocks.session.create.mockResolvedValue(sessionStub.valid); sessionMock.create.mockResolvedValue(sessionStub.valid);
await expect(sut.login(fixtures.login, loginDetails)).resolves.toEqual({ await expect(sut.login(fixtures.login, loginDetails)).resolves.toEqual({
accessToken: 'cmFuZG9tLWJ5dGVz', accessToken: 'cmFuZG9tLWJ5dGVz',
userId: 'user-id', userId: 'user-id',
@@ -101,7 +118,7 @@ describe('AuthService', () => {
isAdmin: false, isAdmin: false,
shouldChangePassword: false, shouldChangePassword: false,
}); });
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1); expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
}); });
}); });
@@ -110,23 +127,23 @@ describe('AuthService', () => {
const auth = { user: { email: 'test@imimch.com' } } as AuthDto; const auth = { user: { email: 'test@imimch.com' } } as AuthDto;
const dto = { password: 'old-password', newPassword: 'new-password' }; const dto = { password: 'old-password', newPassword: 'new-password' };
mocks.user.getByEmail.mockResolvedValue({ userMock.getByEmail.mockResolvedValue({
email: 'test@immich.com', email: 'test@immich.com',
password: 'hash-password', password: 'hash-password',
} as UserEntity); } as UserEntity);
mocks.user.update.mockResolvedValue(userStub.user1); userMock.update.mockResolvedValue(userStub.user1);
await sut.changePassword(auth, dto); await sut.changePassword(auth, dto);
expect(mocks.user.getByEmail).toHaveBeenCalledWith(auth.user.email, true); expect(userMock.getByEmail).toHaveBeenCalledWith(auth.user.email, true);
expect(mocks.crypto.compareBcrypt).toHaveBeenCalledWith('old-password', 'hash-password'); expect(cryptoMock.compareBcrypt).toHaveBeenCalledWith('old-password', 'hash-password');
}); });
it('should throw when auth user email is not found', async () => { it('should throw when auth user email is not found', async () => {
const auth = { user: { email: 'test@imimch.com' } } as AuthDto; const auth = { user: { email: 'test@imimch.com' } } as AuthDto;
const dto = { password: 'old-password', newPassword: 'new-password' }; const dto = { password: 'old-password', newPassword: 'new-password' };
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
await expect(sut.changePassword(auth, dto)).rejects.toBeInstanceOf(UnauthorizedException); await expect(sut.changePassword(auth, dto)).rejects.toBeInstanceOf(UnauthorizedException);
}); });
@@ -135,9 +152,9 @@ describe('AuthService', () => {
const auth = { user: { email: 'test@imimch.com' } as UserEntity }; const auth = { user: { email: 'test@imimch.com' } as UserEntity };
const dto = { password: 'old-password', newPassword: 'new-password' }; const dto = { password: 'old-password', newPassword: 'new-password' };
mocks.crypto.compareBcrypt.mockReturnValue(false); cryptoMock.compareBcrypt.mockReturnValue(false);
mocks.user.getByEmail.mockResolvedValue({ userMock.getByEmail.mockResolvedValue({
email: 'test@immich.com', email: 'test@immich.com',
password: 'hash-password', password: 'hash-password',
} as UserEntity); } as UserEntity);
@@ -149,7 +166,7 @@ describe('AuthService', () => {
const auth = { user: { email: 'test@imimch.com' } } as AuthDto; const auth = { user: { email: 'test@imimch.com' } } as AuthDto;
const dto = { password: 'old-password', newPassword: 'new-password' }; const dto = { password: 'old-password', newPassword: 'new-password' };
mocks.user.getByEmail.mockResolvedValue({ userMock.getByEmail.mockResolvedValue({
email: 'test@immich.com', email: 'test@immich.com',
password: '', password: '',
} as UserEntity); } as UserEntity);
@@ -160,7 +177,7 @@ describe('AuthService', () => {
describe('logout', () => { describe('logout', () => {
it('should return the end session endpoint', async () => { it('should return the end session endpoint', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
const auth = { user: { id: '123' } } as AuthDto; const auth = { user: { id: '123' } } as AuthDto;
await expect(sut.logout(auth, AuthType.OAUTH)).resolves.toEqual({ await expect(sut.logout(auth, AuthType.OAUTH)).resolves.toEqual({
successful: true, successful: true,
@@ -185,8 +202,8 @@ describe('AuthService', () => {
redirectUri: '/auth/login?autoLaunch=0', redirectUri: '/auth/login?autoLaunch=0',
}); });
expect(mocks.session.delete).toHaveBeenCalledWith('token123'); expect(sessionMock.delete).toHaveBeenCalledWith('token123');
expect(mocks.event.emit).toHaveBeenCalledWith('session.delete', { sessionId: 'token123' }); expect(eventMock.emit).toHaveBeenCalledWith('session.delete', { sessionId: 'token123' });
}); });
it('should return the default redirect if auth type is OAUTH but oauth is not enabled', async () => { it('should return the default redirect if auth type is OAUTH but oauth is not enabled', async () => {
@@ -203,14 +220,14 @@ describe('AuthService', () => {
const dto: SignUpDto = { email: 'test@immich.com', password: 'password', name: 'immich admin' }; const dto: SignUpDto = { email: 'test@immich.com', password: 'password', name: 'immich admin' };
it('should only allow one admin', async () => { it('should only allow one admin', async () => {
mocks.user.getAdmin.mockResolvedValue({} as UserEntity); userMock.getAdmin.mockResolvedValue({} as UserEntity);
await expect(sut.adminSignUp(dto)).rejects.toBeInstanceOf(BadRequestException); await expect(sut.adminSignUp(dto)).rejects.toBeInstanceOf(BadRequestException);
expect(mocks.user.getAdmin).toHaveBeenCalled(); expect(userMock.getAdmin).toHaveBeenCalled();
}); });
it('should sign up the admin', async () => { it('should sign up the admin', async () => {
mocks.user.getAdmin.mockResolvedValue(void 0); userMock.getAdmin.mockResolvedValue(void 0);
mocks.user.create.mockResolvedValue({ userMock.create.mockResolvedValue({
...dto, ...dto,
id: 'admin', id: 'admin',
createdAt: new Date('2021-01-01'), createdAt: new Date('2021-01-01'),
@@ -223,8 +240,8 @@ describe('AuthService', () => {
email: 'test@immich.com', email: 'test@immich.com',
name: 'immich admin', name: 'immich admin',
}); });
expect(mocks.user.getAdmin).toHaveBeenCalled(); expect(userMock.getAdmin).toHaveBeenCalled();
expect(mocks.user.create).toHaveBeenCalled(); expect(userMock.create).toHaveBeenCalled();
}); });
}); });
@@ -240,8 +257,8 @@ describe('AuthService', () => {
}); });
it('should validate using authorization header', async () => { it('should validate using authorization header', async () => {
mocks.user.get.mockResolvedValue(userStub.user1); userMock.get.mockResolvedValue(userStub.user1);
mocks.session.getByToken.mockResolvedValue(sessionStub.valid as any); sessionMock.getByToken.mockResolvedValue(sessionStub.valid);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { authorization: 'Bearer auth_token' }, headers: { authorization: 'Bearer auth_token' },
@@ -267,7 +284,7 @@ describe('AuthService', () => {
}); });
it('should not accept an expired key', async () => { it('should not accept an expired key', async () => {
mocks.sharedLink.getByKey.mockResolvedValue(sharedLinkStub.expired); sharedLinkMock.getByKey.mockResolvedValue(sharedLinkStub.expired);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-share-key': 'key' }, headers: { 'x-immich-share-key': 'key' },
@@ -278,7 +295,7 @@ describe('AuthService', () => {
}); });
it('should not accept a key on a non-shared route', async () => { it('should not accept a key on a non-shared route', async () => {
mocks.sharedLink.getByKey.mockResolvedValue(sharedLinkStub.valid); sharedLinkMock.getByKey.mockResolvedValue(sharedLinkStub.valid);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-share-key': 'key' }, headers: { 'x-immich-share-key': 'key' },
@@ -289,8 +306,8 @@ describe('AuthService', () => {
}); });
it('should not accept a key without a user', async () => { it('should not accept a key without a user', async () => {
mocks.sharedLink.getByKey.mockResolvedValue(sharedLinkStub.expired); sharedLinkMock.getByKey.mockResolvedValue(sharedLinkStub.expired);
mocks.user.get.mockResolvedValue(void 0); userMock.get.mockResolvedValue(void 0);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-share-key': 'key' }, headers: { 'x-immich-share-key': 'key' },
@@ -301,8 +318,8 @@ describe('AuthService', () => {
}); });
it('should accept a base64url key', async () => { it('should accept a base64url key', async () => {
mocks.sharedLink.getByKey.mockResolvedValue(sharedLinkStub.valid); sharedLinkMock.getByKey.mockResolvedValue(sharedLinkStub.valid);
mocks.user.get.mockResolvedValue(userStub.admin); userMock.get.mockResolvedValue(userStub.admin);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-share-key': sharedLinkStub.valid.key.toString('base64url') }, headers: { 'x-immich-share-key': sharedLinkStub.valid.key.toString('base64url') },
@@ -313,12 +330,12 @@ describe('AuthService', () => {
user: userStub.admin, user: userStub.admin,
sharedLink: sharedLinkStub.valid, sharedLink: sharedLinkStub.valid,
}); });
expect(mocks.sharedLink.getByKey).toHaveBeenCalledWith(sharedLinkStub.valid.key); expect(sharedLinkMock.getByKey).toHaveBeenCalledWith(sharedLinkStub.valid.key);
}); });
it('should accept a hex key', async () => { it('should accept a hex key', async () => {
mocks.sharedLink.getByKey.mockResolvedValue(sharedLinkStub.valid); sharedLinkMock.getByKey.mockResolvedValue(sharedLinkStub.valid);
mocks.user.get.mockResolvedValue(userStub.admin); userMock.get.mockResolvedValue(userStub.admin);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-share-key': sharedLinkStub.valid.key.toString('hex') }, headers: { 'x-immich-share-key': sharedLinkStub.valid.key.toString('hex') },
@@ -329,13 +346,13 @@ describe('AuthService', () => {
user: userStub.admin, user: userStub.admin,
sharedLink: sharedLinkStub.valid, sharedLink: sharedLinkStub.valid,
}); });
expect(mocks.sharedLink.getByKey).toHaveBeenCalledWith(sharedLinkStub.valid.key); expect(sharedLinkMock.getByKey).toHaveBeenCalledWith(sharedLinkStub.valid.key);
}); });
}); });
describe('validate - user token', () => { describe('validate - user token', () => {
it('should throw if no token is found', async () => { it('should throw if no token is found', async () => {
mocks.session.getByToken.mockResolvedValue(void 0); sessionMock.getByToken.mockResolvedValue(void 0);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-immich-user-token': 'auth_token' }, headers: { 'x-immich-user-token': 'auth_token' },
@@ -346,7 +363,7 @@ describe('AuthService', () => {
}); });
it('should return an auth dto', async () => { it('should return an auth dto', async () => {
mocks.session.getByToken.mockResolvedValue(sessionStub.valid as any); sessionMock.getByToken.mockResolvedValue(sessionStub.valid);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { cookie: 'immich_access_token=auth_token' }, headers: { cookie: 'immich_access_token=auth_token' },
@@ -360,7 +377,7 @@ describe('AuthService', () => {
}); });
it('should throw if admin route and not an admin', async () => { it('should throw if admin route and not an admin', async () => {
mocks.session.getByToken.mockResolvedValue(sessionStub.valid as any); sessionMock.getByToken.mockResolvedValue(sessionStub.valid);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { cookie: 'immich_access_token=auth_token' }, headers: { cookie: 'immich_access_token=auth_token' },
@@ -371,8 +388,8 @@ describe('AuthService', () => {
}); });
it('should update when access time exceeds an hour', async () => { it('should update when access time exceeds an hour', async () => {
mocks.session.getByToken.mockResolvedValue(sessionStub.inactive as any); sessionMock.getByToken.mockResolvedValue(sessionStub.inactive);
mocks.session.update.mockResolvedValue(sessionStub.valid); sessionMock.update.mockResolvedValue(sessionStub.valid);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { cookie: 'immich_access_token=auth_token' }, headers: { cookie: 'immich_access_token=auth_token' },
@@ -380,13 +397,13 @@ describe('AuthService', () => {
metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' }, metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' },
}), }),
).resolves.toBeDefined(); ).resolves.toBeDefined();
expect(mocks.session.update.mock.calls[0][1]).toMatchObject({ id: 'not_active', updatedAt: expect.any(Date) }); expect(sessionMock.update.mock.calls[0][1]).toMatchObject({ id: 'not_active', updatedAt: expect.any(Date) });
}); });
}); });
describe('validate - api key', () => { describe('validate - api key', () => {
it('should throw an error if no api key is found', async () => { it('should throw an error if no api key is found', async () => {
mocks.apiKey.getKey.mockResolvedValue(void 0); keyMock.getKey.mockResolvedValue(void 0);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-api-key': 'auth_token' }, headers: { 'x-api-key': 'auth_token' },
@@ -394,11 +411,11 @@ describe('AuthService', () => {
metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' }, metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' },
}), }),
).rejects.toBeInstanceOf(UnauthorizedException); ).rejects.toBeInstanceOf(UnauthorizedException);
expect(mocks.apiKey.getKey).toHaveBeenCalledWith('auth_token (hashed)'); expect(keyMock.getKey).toHaveBeenCalledWith('auth_token (hashed)');
}); });
it('should throw an error if api key has insufficient permissions', async () => { it('should throw an error if api key has insufficient permissions', async () => {
mocks.apiKey.getKey.mockResolvedValue(keyStub.authKey); keyMock.getKey.mockResolvedValue(keyStub.authKey);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-api-key': 'auth_token' }, headers: { 'x-api-key': 'auth_token' },
@@ -409,7 +426,7 @@ describe('AuthService', () => {
}); });
it('should return an auth dto', async () => { it('should return an auth dto', async () => {
mocks.apiKey.getKey.mockResolvedValue(keyStub.authKey); keyMock.getKey.mockResolvedValue(keyStub.authKey);
await expect( await expect(
sut.authenticate({ sut.authenticate({
headers: { 'x-api-key': 'auth_token' }, headers: { 'x-api-key': 'auth_token' },
@@ -417,7 +434,7 @@ describe('AuthService', () => {
metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' }, metadata: { adminRoute: false, sharedLinkRoute: false, uri: 'test' },
}), }),
).resolves.toEqual({ user: userStub.admin, apiKey: keyStub.authKey }); ).resolves.toEqual({ user: userStub.admin, apiKey: keyStub.authKey });
expect(mocks.apiKey.getKey).toHaveBeenCalledWith('auth_token (hashed)'); expect(keyMock.getKey).toHaveBeenCalledWith('auth_token (hashed)');
}); });
}); });
@@ -435,14 +452,14 @@ describe('AuthService', () => {
describe('authorize', () => { describe('authorize', () => {
it('should fail if oauth is disabled', async () => { it('should fail if oauth is disabled', async () => {
mocks.systemMetadata.get.mockResolvedValue({ oauth: { enabled: false } }); systemMock.get.mockResolvedValue({ oauth: { enabled: false } });
await expect(sut.authorize({ redirectUri: 'https://demo.immich.app' })).rejects.toBeInstanceOf( await expect(sut.authorize({ redirectUri: 'https://demo.immich.app' })).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
}); });
it('should authorize the user', async () => { it('should authorize the user', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithMobileOverride); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithMobileOverride);
await sut.authorize({ redirectUri: 'https://demo.immich.app' }); await sut.authorize({ redirectUri: 'https://demo.immich.app' });
}); });
}); });
@@ -453,71 +470,71 @@ describe('AuthService', () => {
}); });
it('should not allow auto registering', async () => { it('should not allow auto registering', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled); systemMock.get.mockResolvedValue(systemConfigStub.oauthEnabled);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toBeInstanceOf( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1); expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
}); });
it('should link an existing user', async () => { it('should link an existing user', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthEnabled); systemMock.get.mockResolvedValue(systemConfigStub.oauthEnabled);
mocks.user.getByEmail.mockResolvedValue(userStub.user1); userMock.getByEmail.mockResolvedValue(userStub.user1);
mocks.user.update.mockResolvedValue(userStub.user1); userMock.update.mockResolvedValue(userStub.user1);
mocks.session.create.mockResolvedValue(sessionStub.valid); sessionMock.create.mockResolvedValue(sessionStub.valid);
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(1); expect(userMock.getByEmail).toHaveBeenCalledTimes(1);
expect(mocks.user.update).toHaveBeenCalledWith(userStub.user1.id, { oauthId: sub }); expect(userMock.update).toHaveBeenCalledWith(userStub.user1.id, { oauthId: sub });
}); });
it('should not link to a user with a different oauth sub', async () => { it('should not link to a user with a different oauth sub', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithAutoRegister); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithAutoRegister);
mocks.user.getByEmail.mockResolvedValueOnce({ ...userStub.user1, oauthId: 'existing-sub' }); userMock.getByEmail.mockResolvedValueOnce({ ...userStub.user1, oauthId: 'existing-sub' });
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toThrow( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toThrow(
BadRequestException, BadRequestException,
); );
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
expect(mocks.user.create).not.toHaveBeenCalled(); expect(userMock.create).not.toHaveBeenCalled();
}); });
it('should allow auto registering by default', async () => { it('should allow auto registering by default', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.session.create.mockResolvedValue(sessionStub.valid); sessionMock.create.mockResolvedValue(sessionStub.valid);
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.getByEmail).toHaveBeenCalledTimes(2); // second call is for domain check before create expect(userMock.getByEmail).toHaveBeenCalledTimes(2); // second call is for domain check before create
expect(mocks.user.create).toHaveBeenCalledTimes(1); expect(userMock.create).toHaveBeenCalledTimes(1);
}); });
it('should throw an error if user should be auto registered but the email claim does not exist', async () => { it('should throw an error if user should be auto registered but the email claim does not exist', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.session.create.mockResolvedValue(sessionStub.valid); sessionMock.create.mockResolvedValue(sessionStub.valid);
mocks.oauth.getProfile.mockResolvedValue({ sub, email: undefined }); oauthMock.getProfile.mockResolvedValue({ sub, email: undefined });
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toBeInstanceOf( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.user.getByEmail).not.toHaveBeenCalled(); expect(userMock.getByEmail).not.toHaveBeenCalled();
expect(mocks.user.create).not.toHaveBeenCalled(); expect(userMock.create).not.toHaveBeenCalled();
}); });
for (const url of [ for (const url of [
@@ -529,68 +546,68 @@ describe('AuthService', () => {
'app.immich:///oauth-callback?code=abc123', 'app.immich:///oauth-callback?code=abc123',
]) { ]) {
it(`should use the mobile redirect override for a url of ${url}`, async () => { it(`should use the mobile redirect override for a url of ${url}`, async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithMobileOverride); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithMobileOverride);
mocks.user.getByOAuthId.mockResolvedValue(userStub.user1); userMock.getByOAuthId.mockResolvedValue(userStub.user1);
mocks.session.create.mockResolvedValue(sessionStub.valid); sessionMock.create.mockResolvedValue(sessionStub.valid);
await sut.callback({ url }, loginDetails); await sut.callback({ url }, loginDetails);
expect(mocks.oauth.getProfile).toHaveBeenCalledWith(expect.objectContaining({}), url, 'http://mobile-redirect'); expect(oauthMock.getProfile).toHaveBeenCalledWith(expect.objectContaining({}), url, 'http://mobile-redirect');
}); });
} }
it('should use the default quota', async () => { it('should use the default quota', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 }); expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
}); });
it('should ignore an invalid storage quota', async () => { it('should ignore an invalid storage quota', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.oauth.getProfile.mockResolvedValue({ sub, email, immich_quota: 'abc' }); oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 'abc' });
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 }); expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
}); });
it('should ignore a negative quota', async () => { it('should ignore a negative quota', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.oauth.getProfile.mockResolvedValue({ sub, email, immich_quota: -5 }); oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: -5 });
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 }); expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
}); });
it('should not set quota for 0 quota', async () => { it('should not set quota for 0 quota', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.oauth.getProfile.mockResolvedValue({ sub, email, immich_quota: 0 }); oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 0 });
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.create).toHaveBeenCalledWith({ expect(userMock.create).toHaveBeenCalledWith({
email, email,
name: ' ', name: ' ',
oauthId: sub, oauthId: sub,
@@ -600,17 +617,17 @@ describe('AuthService', () => {
}); });
it('should use a valid storage quota', async () => { it('should use a valid storage quota', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota); systemMock.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
mocks.user.getByEmail.mockResolvedValue(void 0); userMock.getByEmail.mockResolvedValue(void 0);
mocks.user.getAdmin.mockResolvedValue(userStub.user1); userMock.getAdmin.mockResolvedValue(userStub.user1);
mocks.user.create.mockResolvedValue(userStub.user1); userMock.create.mockResolvedValue(userStub.user1);
mocks.oauth.getProfile.mockResolvedValue({ sub, email, immich_quota: 5 }); oauthMock.getProfile.mockResolvedValue({ sub, email, immich_quota: 5 });
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse, oauthResponse,
); );
expect(mocks.user.create).toHaveBeenCalledWith({ expect(userMock.create).toHaveBeenCalledWith({
email, email,
name: ' ', name: ' ',
oauthId: sub, oauthId: sub,
@@ -622,34 +639,34 @@ describe('AuthService', () => {
describe('link', () => { describe('link', () => {
it('should link an account', async () => { it('should link an account', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
mocks.user.update.mockResolvedValue(userStub.user1); userMock.update.mockResolvedValue(userStub.user1);
await sut.link(authStub.user1, { url: 'http://immich/user-settings?code=abc123' }); await sut.link(authStub.user1, { url: 'http://immich/user-settings?code=abc123' });
expect(mocks.user.update).toHaveBeenCalledWith(authStub.user1.user.id, { oauthId: sub }); expect(userMock.update).toHaveBeenCalledWith(authStub.user1.user.id, { oauthId: sub });
}); });
it('should not link an already linked oauth.sub', async () => { it('should not link an already linked oauth.sub', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
mocks.user.getByOAuthId.mockResolvedValue({ id: 'other-user' } as UserEntity); userMock.getByOAuthId.mockResolvedValue({ id: 'other-user' } as UserEntity);
await expect(sut.link(authStub.user1, { url: 'http://immich/user-settings?code=abc123' })).rejects.toBeInstanceOf( await expect(sut.link(authStub.user1, { url: 'http://immich/user-settings?code=abc123' })).rejects.toBeInstanceOf(
BadRequestException, BadRequestException,
); );
expect(mocks.user.update).not.toHaveBeenCalled(); expect(userMock.update).not.toHaveBeenCalled();
}); });
}); });
describe('unlink', () => { describe('unlink', () => {
it('should unlink an account', async () => { it('should unlink an account', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.enabled); systemMock.get.mockResolvedValue(systemConfigStub.enabled);
mocks.user.update.mockResolvedValue(userStub.user1); userMock.update.mockResolvedValue(userStub.user1);
await sut.unlink(authStub.user1); await sut.unlink(authStub.user1);
expect(mocks.user.update).toHaveBeenCalledWith(authStub.user1.user.id, { oauthId: '' }); expect(userMock.update).toHaveBeenCalledWith(authStub.user1.user.id, { oauthId: '' });
}); });
}); });
}); });
+1 -2
View File
@@ -17,7 +17,6 @@ import {
mapLoginResponse, mapLoginResponse,
} from 'src/dtos/auth.dto'; } from 'src/dtos/auth.dto';
import { UserAdminResponseDto, mapUserAdmin } from 'src/dtos/user.dto'; import { UserAdminResponseDto, mapUserAdmin } from 'src/dtos/user.dto';
import { SessionEntity } from 'src/entities/session.entity';
import { UserEntity } from 'src/entities/user.entity'; import { UserEntity } from 'src/entities/user.entity';
import { AuthType, ImmichCookie, ImmichHeader, ImmichQuery, Permission } from 'src/enum'; import { AuthType, ImmichCookie, ImmichHeader, ImmichQuery, Permission } from 'src/enum';
import { OAuthProfile } from 'src/repositories/oauth.repository'; import { OAuthProfile } from 'src/repositories/oauth.repository';
@@ -339,7 +338,7 @@ export class AuthService extends BaseService {
await this.sessionRepository.update(session.id, { id: session.id, updatedAt: new Date() }); await this.sessionRepository.update(session.id, { id: session.id, updatedAt: new Date() });
} }
return { user: session.user as unknown as UserEntity, session: session as unknown as SessionEntity }; return { user: session.user, session };
} }
throw new UnauthorizedException('Invalid user token'); throw new UnauthorizedException('Invalid user token');
+65 -54
View File
@@ -2,18 +2,29 @@ import { PassThrough } from 'node:stream';
import { defaults, SystemConfig } from 'src/config'; import { defaults, SystemConfig } from 'src/config';
import { StorageCore } from 'src/cores/storage.core'; import { StorageCore } from 'src/cores/storage.core';
import { ImmichWorker, StorageFolder } from 'src/enum'; import { ImmichWorker, StorageFolder } from 'src/enum';
import { IDatabaseRepository } from 'src/interfaces/database.interface';
import { JobStatus } from 'src/interfaces/job.interface'; import { JobStatus } from 'src/interfaces/job.interface';
import { IProcessRepository } from 'src/interfaces/process.interface';
import { IStorageRepository } from 'src/interfaces/storage.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { BackupService } from 'src/services/backup.service'; import { BackupService } from 'src/services/backup.service';
import { IConfigRepository, ICronRepository } from 'src/types';
import { systemConfigStub } from 'test/fixtures/system-config.stub'; import { systemConfigStub } from 'test/fixtures/system-config.stub';
import { mockSpawn, newTestService, ServiceMocks } from 'test/utils'; import { mockSpawn, newTestService } from 'test/utils';
import { describe } from 'vitest'; import { describe, Mocked } from 'vitest';
describe(BackupService.name, () => { describe(BackupService.name, () => {
let sut: BackupService; let sut: BackupService;
let mocks: ServiceMocks;
let databaseMock: Mocked<IDatabaseRepository>;
let configMock: Mocked<IConfigRepository>;
let cronMock: Mocked<ICronRepository>;
let processMock: Mocked<IProcessRepository>;
let storageMock: Mocked<IStorageRepository>;
let systemMock: Mocked<ISystemMetadataRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(BackupService)); ({ sut, cronMock, configMock, databaseMock, processMock, storageMock, systemMock } = newTestService(BackupService));
}); });
it('should work', () => { it('should work', () => {
@@ -22,32 +33,32 @@ describe(BackupService.name, () => {
describe('onBootstrapEvent', () => { describe('onBootstrapEvent', () => {
it('should init cron job and handle config changes', async () => { it('should init cron job and handle config changes', async () => {
mocks.database.tryLock.mockResolvedValue(true); databaseMock.tryLock.mockResolvedValue(true);
await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig }); await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig });
expect(mocks.cron.create).toHaveBeenCalled(); expect(cronMock.create).toHaveBeenCalled();
}); });
it('should not initialize backup database cron job when lock is taken', async () => { it('should not initialize backup database cron job when lock is taken', async () => {
mocks.database.tryLock.mockResolvedValue(false); databaseMock.tryLock.mockResolvedValue(false);
await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig }); await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig });
expect(mocks.cron.create).not.toHaveBeenCalled(); expect(cronMock.create).not.toHaveBeenCalled();
}); });
it('should not initialise backup database job when running on microservices', async () => { it('should not initialise backup database job when running on microservices', async () => {
mocks.config.getWorker.mockReturnValue(ImmichWorker.MICROSERVICES); configMock.getWorker.mockReturnValue(ImmichWorker.MICROSERVICES);
await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig }); await sut.onConfigInit({ newConfig: systemConfigStub.backupEnabled as SystemConfig });
expect(mocks.cron.create).not.toHaveBeenCalled(); expect(cronMock.create).not.toHaveBeenCalled();
}); });
}); });
describe('onConfigUpdateEvent', () => { describe('onConfigUpdateEvent', () => {
beforeEach(async () => { beforeEach(async () => {
mocks.database.tryLock.mockResolvedValue(true); databaseMock.tryLock.mockResolvedValue(true);
await sut.onConfigInit({ newConfig: defaults }); await sut.onConfigInit({ newConfig: defaults });
}); });
@@ -64,66 +75,66 @@ describe(BackupService.name, () => {
} as SystemConfig, } as SystemConfig,
}); });
expect(mocks.cron.update).toHaveBeenCalledWith({ name: 'backupDatabase', expression: '0 1 * * *', start: true }); expect(cronMock.update).toHaveBeenCalledWith({ name: 'backupDatabase', expression: '0 1 * * *', start: true });
expect(mocks.cron.update).toHaveBeenCalled(); expect(cronMock.update).toHaveBeenCalled();
}); });
it('should do nothing if instance does not have the backup database lock', async () => { it('should do nothing if instance does not have the backup database lock', async () => {
mocks.database.tryLock.mockResolvedValue(false); databaseMock.tryLock.mockResolvedValue(false);
await sut.onConfigInit({ newConfig: defaults }); await sut.onConfigInit({ newConfig: defaults });
sut.onConfigUpdate({ newConfig: systemConfigStub.backupEnabled as SystemConfig, oldConfig: defaults }); sut.onConfigUpdate({ newConfig: systemConfigStub.backupEnabled as SystemConfig, oldConfig: defaults });
expect(mocks.cron.update).not.toHaveBeenCalled(); expect(cronMock.update).not.toHaveBeenCalled();
}); });
}); });
describe('cleanupDatabaseBackups', () => { describe('cleanupDatabaseBackups', () => {
it('should do nothing if not reached keepLastAmount', async () => { it('should do nothing if not reached keepLastAmount', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.backupEnabled); systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
mocks.storage.readdir.mockResolvedValue(['immich-db-backup-1.sql.gz']); storageMock.readdir.mockResolvedValue(['immich-db-backup-1.sql.gz']);
await sut.cleanupDatabaseBackups(); await sut.cleanupDatabaseBackups();
expect(mocks.storage.unlink).not.toHaveBeenCalled(); expect(storageMock.unlink).not.toHaveBeenCalled();
}); });
it('should remove failed backup files', async () => { it('should remove failed backup files', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.backupEnabled); systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
mocks.storage.readdir.mockResolvedValue([ storageMock.readdir.mockResolvedValue([
'immich-db-backup-123.sql.gz.tmp', 'immich-db-backup-123.sql.gz.tmp',
'immich-db-backup-234.sql.gz', 'immich-db-backup-234.sql.gz',
'immich-db-backup-345.sql.gz.tmp', 'immich-db-backup-345.sql.gz.tmp',
]); ]);
await sut.cleanupDatabaseBackups(); await sut.cleanupDatabaseBackups();
expect(mocks.storage.unlink).toHaveBeenCalledTimes(2); expect(storageMock.unlink).toHaveBeenCalledTimes(2);
expect(mocks.storage.unlink).toHaveBeenCalledWith( expect(storageMock.unlink).toHaveBeenCalledWith(
`${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-123.sql.gz.tmp`, `${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-123.sql.gz.tmp`,
); );
expect(mocks.storage.unlink).toHaveBeenCalledWith( expect(storageMock.unlink).toHaveBeenCalledWith(
`${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-345.sql.gz.tmp`, `${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-345.sql.gz.tmp`,
); );
}); });
it('should remove old backup files over keepLastAmount', async () => { it('should remove old backup files over keepLastAmount', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.backupEnabled); systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
mocks.storage.readdir.mockResolvedValue(['immich-db-backup-1.sql.gz', 'immich-db-backup-2.sql.gz']); storageMock.readdir.mockResolvedValue(['immich-db-backup-1.sql.gz', 'immich-db-backup-2.sql.gz']);
await sut.cleanupDatabaseBackups(); await sut.cleanupDatabaseBackups();
expect(mocks.storage.unlink).toHaveBeenCalledTimes(1); expect(storageMock.unlink).toHaveBeenCalledTimes(1);
expect(mocks.storage.unlink).toHaveBeenCalledWith( expect(storageMock.unlink).toHaveBeenCalledWith(
`${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-1.sql.gz`, `${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-1.sql.gz`,
); );
}); });
it('should remove old backup files over keepLastAmount and failed backups', async () => { it('should remove old backup files over keepLastAmount and failed backups', async () => {
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.backupEnabled); systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
mocks.storage.readdir.mockResolvedValue([ storageMock.readdir.mockResolvedValue([
'immich-db-backup-1.sql.gz.tmp', 'immich-db-backup-1.sql.gz.tmp',
'immich-db-backup-2.sql.gz', 'immich-db-backup-2.sql.gz',
'immich-db-backup-3.sql.gz', 'immich-db-backup-3.sql.gz',
]); ]);
await sut.cleanupDatabaseBackups(); await sut.cleanupDatabaseBackups();
expect(mocks.storage.unlink).toHaveBeenCalledTimes(2); expect(storageMock.unlink).toHaveBeenCalledTimes(2);
expect(mocks.storage.unlink).toHaveBeenCalledWith( expect(storageMock.unlink).toHaveBeenCalledWith(
`${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-1.sql.gz.tmp`, `${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-1.sql.gz.tmp`,
); );
expect(mocks.storage.unlink).toHaveBeenCalledWith( expect(storageMock.unlink).toHaveBeenCalledWith(
`${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-2.sql.gz`, `${StorageCore.getBaseFolder(StorageFolder.BACKUPS)}/immich-db-backup-2.sql.gz`,
); );
}); });
@@ -131,57 +142,57 @@ describe(BackupService.name, () => {
describe('handleBackupDatabase', () => { describe('handleBackupDatabase', () => {
beforeEach(() => { beforeEach(() => {
mocks.storage.readdir.mockResolvedValue([]); storageMock.readdir.mockResolvedValue([]);
mocks.process.spawn.mockReturnValue(mockSpawn(0, 'data', '')); processMock.spawn.mockReturnValue(mockSpawn(0, 'data', ''));
mocks.storage.rename.mockResolvedValue(); storageMock.rename.mockResolvedValue();
mocks.storage.unlink.mockResolvedValue(); storageMock.unlink.mockResolvedValue();
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.backupEnabled); systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
mocks.storage.createWriteStream.mockReturnValue(new PassThrough()); storageMock.createWriteStream.mockReturnValue(new PassThrough());
}); });
it('should run a database backup successfully', async () => { it('should run a database backup successfully', async () => {
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.SUCCESS); expect(result).toBe(JobStatus.SUCCESS);
expect(mocks.storage.createWriteStream).toHaveBeenCalled(); expect(storageMock.createWriteStream).toHaveBeenCalled();
}); });
it('should rename file on success', async () => { it('should rename file on success', async () => {
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.SUCCESS); expect(result).toBe(JobStatus.SUCCESS);
expect(mocks.storage.rename).toHaveBeenCalled(); expect(storageMock.rename).toHaveBeenCalled();
}); });
it('should fail if pg_dumpall fails', async () => { it('should fail if pg_dumpall fails', async () => {
mocks.process.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error')); processMock.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error'));
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
it('should not rename file if pgdump fails and gzip succeeds', async () => { it('should not rename file if pgdump fails and gzip succeeds', async () => {
mocks.process.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error')); processMock.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error'));
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
expect(mocks.storage.rename).not.toHaveBeenCalled(); expect(storageMock.rename).not.toHaveBeenCalled();
}); });
it('should fail if gzip fails', async () => { it('should fail if gzip fails', async () => {
mocks.process.spawn.mockReturnValueOnce(mockSpawn(0, 'data', '')); processMock.spawn.mockReturnValueOnce(mockSpawn(0, 'data', ''));
mocks.process.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error')); processMock.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error'));
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
it('should fail if write stream fails', async () => { it('should fail if write stream fails', async () => {
mocks.storage.createWriteStream.mockImplementation(() => { storageMock.createWriteStream.mockImplementation(() => {
throw new Error('error'); throw new Error('error');
}); });
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
it('should fail if rename fails', async () => { it('should fail if rename fails', async () => {
mocks.storage.rename.mockRejectedValue(new Error('error')); storageMock.rename.mockRejectedValue(new Error('error'));
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
it('should ignore unlink failing and still return failed job status', async () => { it('should ignore unlink failing and still return failed job status', async () => {
mocks.process.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error')); processMock.spawn.mockReturnValueOnce(mockSpawn(1, '', 'error'));
mocks.storage.unlink.mockRejectedValue(new Error('error')); storageMock.unlink.mockRejectedValue(new Error('error'));
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(mocks.storage.unlink).toHaveBeenCalled(); expect(storageMock.unlink).toHaveBeenCalled();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
it.each` it.each`
@@ -195,9 +206,9 @@ describe(BackupService.name, () => {
`( `(
`should use pg_dumpall $expectedVersion with postgres version $postgresVersion`, `should use pg_dumpall $expectedVersion with postgres version $postgresVersion`,
async ({ postgresVersion, expectedVersion }) => { async ({ postgresVersion, expectedVersion }) => {
mocks.database.getPostgresVersion.mockResolvedValue(postgresVersion); databaseMock.getPostgresVersion.mockResolvedValue(postgresVersion);
await sut.handleBackupDatabase(); await sut.handleBackupDatabase();
expect(mocks.process.spawn).toHaveBeenCalledWith( expect(processMock.spawn).toHaveBeenCalledWith(
`/usr/lib/postgresql/${expectedVersion}/bin/pg_dumpall`, `/usr/lib/postgresql/${expectedVersion}/bin/pg_dumpall`,
expect.any(Array), expect.any(Array),
expect.any(Object), expect.any(Object),
@@ -209,9 +220,9 @@ describe(BackupService.name, () => {
${'13.99.99'} ${'13.99.99'}
${'18.0.0'} ${'18.0.0'}
`(`should fail if postgres version $postgresVersion is not supported`, async ({ postgresVersion }) => { `(`should fail if postgres version $postgresVersion is not supported`, async ({ postgresVersion }) => {
mocks.database.getPostgresVersion.mockResolvedValue(postgresVersion); databaseMock.getPostgresVersion.mockResolvedValue(postgresVersion);
const result = await sut.handleBackupDatabase(); const result = await sut.handleBackupDatabase();
expect(mocks.process.spawn).not.toHaveBeenCalled(); expect(processMock.spawn).not.toHaveBeenCalled();
expect(result).toBe(JobStatus.FAILED); expect(result).toBe(JobStatus.FAILED);
}); });
}); });
+7 -8
View File
@@ -17,10 +17,13 @@ import { IMachineLearningRepository } from 'src/interfaces/machine-learning.inte
import { IMoveRepository } from 'src/interfaces/move.interface'; import { IMoveRepository } from 'src/interfaces/move.interface';
import { IPartnerRepository } from 'src/interfaces/partner.interface'; import { IPartnerRepository } from 'src/interfaces/partner.interface';
import { IPersonRepository } from 'src/interfaces/person.interface'; import { IPersonRepository } from 'src/interfaces/person.interface';
import { IProcessRepository } from 'src/interfaces/process.interface';
import { ISearchRepository } from 'src/interfaces/search.interface'; import { ISearchRepository } from 'src/interfaces/search.interface';
import { ISessionRepository } from 'src/interfaces/session.interface';
import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface'; import { ISharedLinkRepository } from 'src/interfaces/shared-link.interface';
import { IStackRepository } from 'src/interfaces/stack.interface'; import { IStackRepository } from 'src/interfaces/stack.interface';
import { IStorageRepository } from 'src/interfaces/storage.interface'; import { IStorageRepository } from 'src/interfaces/storage.interface';
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { ITagRepository } from 'src/interfaces/tag.interface'; import { ITagRepository } from 'src/interfaces/tag.interface';
import { IUserRepository } from 'src/interfaces/user.interface'; import { IUserRepository } from 'src/interfaces/user.interface';
import { AccessRepository } from 'src/repositories/access.repository'; import { AccessRepository } from 'src/repositories/access.repository';
@@ -30,7 +33,6 @@ import { ApiKeyRepository } from 'src/repositories/api-key.repository';
import { AuditRepository } from 'src/repositories/audit.repository'; import { AuditRepository } from 'src/repositories/audit.repository';
import { ConfigRepository } from 'src/repositories/config.repository'; import { ConfigRepository } from 'src/repositories/config.repository';
import { CronRepository } from 'src/repositories/cron.repository'; import { CronRepository } from 'src/repositories/cron.repository';
import { CryptoRepository } from 'src/repositories/crypto.repository';
import { LoggingRepository } from 'src/repositories/logging.repository'; import { LoggingRepository } from 'src/repositories/logging.repository';
import { MapRepository } from 'src/repositories/map.repository'; import { MapRepository } from 'src/repositories/map.repository';
import { MediaRepository } from 'src/repositories/media.repository'; import { MediaRepository } from 'src/repositories/media.repository';
@@ -38,10 +40,7 @@ import { MemoryRepository } from 'src/repositories/memory.repository';
import { MetadataRepository } from 'src/repositories/metadata.repository'; import { MetadataRepository } from 'src/repositories/metadata.repository';
import { NotificationRepository } from 'src/repositories/notification.repository'; import { NotificationRepository } from 'src/repositories/notification.repository';
import { OAuthRepository } from 'src/repositories/oauth.repository'; import { OAuthRepository } from 'src/repositories/oauth.repository';
import { ProcessRepository } from 'src/repositories/process.repository';
import { ServerInfoRepository } from 'src/repositories/server-info.repository'; import { ServerInfoRepository } from 'src/repositories/server-info.repository';
import { SessionRepository } from 'src/repositories/session.repository';
import { SystemMetadataRepository } from 'src/repositories/system-metadata.repository';
import { TelemetryRepository } from 'src/repositories/telemetry.repository'; import { TelemetryRepository } from 'src/repositories/telemetry.repository';
import { TrashRepository } from 'src/repositories/trash.repository'; import { TrashRepository } from 'src/repositories/trash.repository';
import { VersionHistoryRepository } from 'src/repositories/version-history.repository'; import { VersionHistoryRepository } from 'src/repositories/version-history.repository';
@@ -62,7 +61,7 @@ export class BaseService {
@Inject(IAssetRepository) protected assetRepository: IAssetRepository, @Inject(IAssetRepository) protected assetRepository: IAssetRepository,
protected configRepository: ConfigRepository, protected configRepository: ConfigRepository,
protected cronRepository: CronRepository, protected cronRepository: CronRepository,
@Inject(ICryptoRepository) protected cryptoRepository: CryptoRepository, @Inject(ICryptoRepository) protected cryptoRepository: ICryptoRepository,
@Inject(IDatabaseRepository) protected databaseRepository: IDatabaseRepository, @Inject(IDatabaseRepository) protected databaseRepository: IDatabaseRepository,
@Inject(IEventRepository) protected eventRepository: IEventRepository, @Inject(IEventRepository) protected eventRepository: IEventRepository,
@Inject(IJobRepository) protected jobRepository: IJobRepository, @Inject(IJobRepository) protected jobRepository: IJobRepository,
@@ -78,14 +77,14 @@ export class BaseService {
protected oauthRepository: OAuthRepository, protected oauthRepository: OAuthRepository,
@Inject(IPartnerRepository) protected partnerRepository: IPartnerRepository, @Inject(IPartnerRepository) protected partnerRepository: IPartnerRepository,
@Inject(IPersonRepository) protected personRepository: IPersonRepository, @Inject(IPersonRepository) protected personRepository: IPersonRepository,
protected processRepository: ProcessRepository, @Inject(IProcessRepository) protected processRepository: IProcessRepository,
@Inject(ISearchRepository) protected searchRepository: ISearchRepository, @Inject(ISearchRepository) protected searchRepository: ISearchRepository,
protected serverInfoRepository: ServerInfoRepository, protected serverInfoRepository: ServerInfoRepository,
protected sessionRepository: SessionRepository, @Inject(ISessionRepository) protected sessionRepository: ISessionRepository,
@Inject(ISharedLinkRepository) protected sharedLinkRepository: ISharedLinkRepository, @Inject(ISharedLinkRepository) protected sharedLinkRepository: ISharedLinkRepository,
@Inject(IStackRepository) protected stackRepository: IStackRepository, @Inject(IStackRepository) protected stackRepository: IStackRepository,
@Inject(IStorageRepository) protected storageRepository: IStorageRepository, @Inject(IStorageRepository) protected storageRepository: IStorageRepository,
protected systemMetadataRepository: SystemMetadataRepository, @Inject(ISystemMetadataRepository) protected systemMetadataRepository: ISystemMetadataRepository,
@Inject(ITagRepository) protected tagRepository: ITagRepository, @Inject(ITagRepository) protected tagRepository: ITagRepository,
protected telemetryRepository: TelemetryRepository, protected telemetryRepository: TelemetryRepository,
protected trashRepository: TrashRepository, protected trashRepository: TrashRepository,
+19 -15
View File
@@ -1,27 +1,31 @@
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
import { IUserRepository } from 'src/interfaces/user.interface';
import { CliService } from 'src/services/cli.service'; import { CliService } from 'src/services/cli.service';
import { userStub } from 'test/fixtures/user.stub'; import { userStub } from 'test/fixtures/user.stub';
import { newTestService, ServiceMocks } from 'test/utils'; import { newTestService } from 'test/utils';
import { describe, it } from 'vitest'; import { Mocked, describe, it } from 'vitest';
describe(CliService.name, () => { describe(CliService.name, () => {
let sut: CliService; let sut: CliService;
let mocks: ServiceMocks;
let userMock: Mocked<IUserRepository>;
let systemMock: Mocked<ISystemMetadataRepository>;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(CliService)); ({ sut, userMock, systemMock } = newTestService(CliService));
}); });
describe('listUsers', () => { describe('listUsers', () => {
it('should list users', async () => { it('should list users', async () => {
mocks.user.getList.mockResolvedValue([userStub.admin]); userMock.getList.mockResolvedValue([userStub.admin]);
await expect(sut.listUsers()).resolves.toEqual([expect.objectContaining({ isAdmin: true })]); await expect(sut.listUsers()).resolves.toEqual([expect.objectContaining({ isAdmin: true })]);
expect(mocks.user.getList).toHaveBeenCalledWith({ withDeleted: true }); expect(userMock.getList).toHaveBeenCalledWith({ withDeleted: true });
}); });
}); });
describe('resetAdminPassword', () => { describe('resetAdminPassword', () => {
it('should only work when there is an admin account', async () => { it('should only work when there is an admin account', async () => {
mocks.user.getAdmin.mockResolvedValue(void 0); userMock.getAdmin.mockResolvedValue(void 0);
const ask = vitest.fn().mockResolvedValue('new-password'); const ask = vitest.fn().mockResolvedValue('new-password');
await expect(sut.resetAdminPassword(ask)).rejects.toThrowError('Admin account does not exist'); await expect(sut.resetAdminPassword(ask)).rejects.toThrowError('Admin account does not exist');
@@ -30,12 +34,12 @@ describe(CliService.name, () => {
}); });
it('should default to a random password', async () => { it('should default to a random password', async () => {
mocks.user.getAdmin.mockResolvedValue(userStub.admin); userMock.getAdmin.mockResolvedValue(userStub.admin);
const ask = vitest.fn().mockImplementation(() => {}); const ask = vitest.fn().mockImplementation(() => {});
const response = await sut.resetAdminPassword(ask); const response = await sut.resetAdminPassword(ask);
const [id, update] = mocks.user.update.mock.calls[0]; const [id, update] = userMock.update.mock.calls[0];
expect(response.provided).toBe(false); expect(response.provided).toBe(false);
expect(ask).toHaveBeenCalled(); expect(ask).toHaveBeenCalled();
@@ -44,12 +48,12 @@ describe(CliService.name, () => {
}); });
it('should use the supplied password', async () => { it('should use the supplied password', async () => {
mocks.user.getAdmin.mockResolvedValue(userStub.admin); userMock.getAdmin.mockResolvedValue(userStub.admin);
const ask = vitest.fn().mockResolvedValue('new-password'); const ask = vitest.fn().mockResolvedValue('new-password');
const response = await sut.resetAdminPassword(ask); const response = await sut.resetAdminPassword(ask);
const [id, update] = mocks.user.update.mock.calls[0]; const [id, update] = userMock.update.mock.calls[0];
expect(response.provided).toBe(true); expect(response.provided).toBe(true);
expect(ask).toHaveBeenCalled(); expect(ask).toHaveBeenCalled();
@@ -61,28 +65,28 @@ describe(CliService.name, () => {
describe('disablePasswordLogin', () => { describe('disablePasswordLogin', () => {
it('should disable password login', async () => { it('should disable password login', async () => {
await sut.disablePasswordLogin(); await sut.disablePasswordLogin();
expect(mocks.systemMetadata.set).toHaveBeenCalledWith('system-config', { passwordLogin: { enabled: false } }); expect(systemMock.set).toHaveBeenCalledWith('system-config', { passwordLogin: { enabled: false } });
}); });
}); });
describe('enablePasswordLogin', () => { describe('enablePasswordLogin', () => {
it('should enable password login', async () => { it('should enable password login', async () => {
await sut.enablePasswordLogin(); await sut.enablePasswordLogin();
expect(mocks.systemMetadata.set).toHaveBeenCalledWith('system-config', {}); expect(systemMock.set).toHaveBeenCalledWith('system-config', {});
}); });
}); });
describe('disableOAuthLogin', () => { describe('disableOAuthLogin', () => {
it('should disable oauth login', async () => { it('should disable oauth login', async () => {
await sut.disableOAuthLogin(); await sut.disableOAuthLogin();
expect(mocks.systemMetadata.set).toHaveBeenCalledWith('system-config', {}); expect(systemMock.set).toHaveBeenCalledWith('system-config', {});
}); });
}); });
describe('enableOAuthLogin', () => { describe('enableOAuthLogin', () => {
it('should enable oauth login', async () => { it('should enable oauth login', async () => {
await sut.enableOAuthLogin(); await sut.enableOAuthLogin();
expect(mocks.systemMetadata.set).toHaveBeenCalledWith('system-config', { oauth: { enabled: true } }); expect(systemMock.set).toHaveBeenCalledWith('system-config', { oauth: { enabled: true } });
}); });
}); });
}); });
+125 -116
View File
@@ -1,12 +1,21 @@
import { DatabaseExtension, EXTENSION_NAMES, VectorExtension } from 'src/interfaces/database.interface'; import {
DatabaseExtension,
EXTENSION_NAMES,
IDatabaseRepository,
VectorExtension,
} from 'src/interfaces/database.interface';
import { DatabaseService } from 'src/services/database.service'; import { DatabaseService } from 'src/services/database.service';
import { IConfigRepository, ILoggingRepository } from 'src/types';
import { mockEnvData } from 'test/repositories/config.repository.mock'; import { mockEnvData } from 'test/repositories/config.repository.mock';
import { newTestService, ServiceMocks } from 'test/utils'; import { newTestService } from 'test/utils';
import { Mocked } from 'vitest';
describe(DatabaseService.name, () => { describe(DatabaseService.name, () => {
let sut: DatabaseService; let sut: DatabaseService;
let mocks: ServiceMocks;
let configMock: Mocked<IConfigRepository>;
let databaseMock: Mocked<IDatabaseRepository>;
let loggerMock: Mocked<ILoggingRepository>;
let extensionRange: string; let extensionRange: string;
let versionBelowRange: string; let versionBelowRange: string;
let minVersionInRange: string; let minVersionInRange: string;
@@ -14,16 +23,16 @@ describe(DatabaseService.name, () => {
let versionAboveRange: string; let versionAboveRange: string;
beforeEach(() => { beforeEach(() => {
({ sut, mocks } = newTestService(DatabaseService)); ({ sut, configMock, databaseMock, loggerMock } = newTestService(DatabaseService));
extensionRange = '0.2.x'; extensionRange = '0.2.x';
mocks.database.getExtensionVersionRange.mockReturnValue(extensionRange); databaseMock.getExtensionVersionRange.mockReturnValue(extensionRange);
versionBelowRange = '0.1.0'; versionBelowRange = '0.1.0';
minVersionInRange = '0.2.0'; minVersionInRange = '0.2.0';
updateInRange = '0.2.1'; updateInRange = '0.2.1';
versionAboveRange = '0.3.0'; versionAboveRange = '0.3.0';
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
}); });
@@ -35,11 +44,11 @@ describe(DatabaseService.name, () => {
describe('onBootstrap', () => { describe('onBootstrap', () => {
it('should throw an error if PostgreSQL version is below minimum supported version', async () => { it('should throw an error if PostgreSQL version is below minimum supported version', async () => {
mocks.database.getPostgresVersion.mockResolvedValueOnce('13.10.0'); databaseMock.getPostgresVersion.mockResolvedValueOnce('13.10.0');
await expect(sut.onBootstrap()).rejects.toThrow('Invalid PostgreSQL version. Found 13.10.0'); await expect(sut.onBootstrap()).rejects.toThrow('Invalid PostgreSQL version. Found 13.10.0');
expect(mocks.database.getPostgresVersion).toHaveBeenCalledTimes(1); expect(databaseMock.getPostgresVersion).toHaveBeenCalledTimes(1);
}); });
describe.each(<Array<{ extension: VectorExtension; extensionName: string }>>[ describe.each(<Array<{ extension: VectorExtension; extensionName: string }>>[
@@ -47,7 +56,7 @@ describe(DatabaseService.name, () => {
{ extension: DatabaseExtension.VECTORS, extensionName: EXTENSION_NAMES[DatabaseExtension.VECTORS] }, { extension: DatabaseExtension.VECTORS, extensionName: EXTENSION_NAMES[DatabaseExtension.VECTORS] },
])('should work with $extensionName', ({ extension, extensionName }) => { ])('should work with $extensionName', ({ extension, extensionName }) => {
beforeEach(() => { beforeEach(() => {
mocks.config.getEnv.mockReturnValue( configMock.getEnv.mockReturnValue(
mockEnvData({ mockEnvData({
database: { database: {
config: { config: {
@@ -76,34 +85,34 @@ describe(DatabaseService.name, () => {
}); });
it(`should start up successfully with ${extension}`, async () => { it(`should start up successfully with ${extension}`, async () => {
mocks.database.getPostgresVersion.mockResolvedValue('14.0.0'); databaseMock.getPostgresVersion.mockResolvedValue('14.0.0');
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
installedVersion: null, installedVersion: null,
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
}); });
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.getPostgresVersion).toHaveBeenCalled(); expect(databaseMock.getPostgresVersion).toHaveBeenCalled();
expect(mocks.database.createExtension).toHaveBeenCalledWith(extension); expect(databaseMock.createExtension).toHaveBeenCalledWith(extension);
expect(mocks.database.createExtension).toHaveBeenCalledTimes(1); expect(databaseMock.createExtension).toHaveBeenCalledTimes(1);
expect(mocks.database.getExtensionVersion).toHaveBeenCalled(); expect(databaseMock.getExtensionVersion).toHaveBeenCalled();
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should throw an error if the ${extension} extension is not installed`, async () => { it(`should throw an error if the ${extension} extension is not installed`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ installedVersion: null, availableVersion: null }); databaseMock.getExtensionVersion.mockResolvedValue({ installedVersion: null, availableVersion: null });
const message = `The ${extensionName} extension is not available in this Postgres instance. const message = `The ${extensionName} extension is not available in this Postgres instance.
If using a container image, ensure the image has the extension installed.`; If using a container image, ensure the image has the extension installed.`;
await expect(sut.onBootstrap()).rejects.toThrow(message); await expect(sut.onBootstrap()).rejects.toThrow(message);
expect(mocks.database.createExtension).not.toHaveBeenCalled(); expect(databaseMock.createExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should throw an error if the ${extension} extension version is below minimum supported version`, async () => { it(`should throw an error if the ${extension} extension version is below minimum supported version`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
installedVersion: versionBelowRange, installedVersion: versionBelowRange,
availableVersion: versionBelowRange, availableVersion: versionBelowRange,
}); });
@@ -112,80 +121,80 @@ describe(DatabaseService.name, () => {
`The ${extensionName} extension version is ${versionBelowRange}, but Immich only supports ${extensionRange}`, `The ${extensionName} extension version is ${versionBelowRange}, but Immich only supports ${extensionRange}`,
); );
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should throw an error if ${extension} extension version is a nightly`, async () => { it(`should throw an error if ${extension} extension version is a nightly`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ installedVersion: '0.0.0', availableVersion: '0.0.0' }); databaseMock.getExtensionVersion.mockResolvedValue({ installedVersion: '0.0.0', availableVersion: '0.0.0' });
await expect(sut.onBootstrap()).rejects.toThrow( await expect(sut.onBootstrap()).rejects.toThrow(
`The ${extensionName} extension version is 0.0.0, which means it is a nightly release.`, `The ${extensionName} extension version is 0.0.0, which means it is a nightly release.`,
); );
expect(mocks.database.createExtension).not.toHaveBeenCalled(); expect(databaseMock.createExtension).not.toHaveBeenCalled();
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should do in-range update for ${extension} extension`, async () => { it(`should do in-range update for ${extension} extension`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: updateInRange, availableVersion: updateInRange,
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
}); });
mocks.database.updateVectorExtension.mockResolvedValue({ restartRequired: false }); databaseMock.updateVectorExtension.mockResolvedValue({ restartRequired: false });
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange); expect(databaseMock.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange);
expect(mocks.database.updateVectorExtension).toHaveBeenCalledTimes(1); expect(databaseMock.updateVectorExtension).toHaveBeenCalledTimes(1);
expect(mocks.database.getExtensionVersion).toHaveBeenCalled(); expect(databaseMock.getExtensionVersion).toHaveBeenCalled();
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should not upgrade ${extension} if same version`, async () => { it(`should not upgrade ${extension} if same version`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
}); });
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should throw error if ${extension} available version is below range`, async () => { it(`should throw error if ${extension} available version is below range`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: versionBelowRange, availableVersion: versionBelowRange,
installedVersion: null, installedVersion: null,
}); });
await expect(sut.onBootstrap()).rejects.toThrow(); await expect(sut.onBootstrap()).rejects.toThrow();
expect(mocks.database.createExtension).not.toHaveBeenCalled(); expect(databaseMock.createExtension).not.toHaveBeenCalled();
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should throw error if ${extension} available version is above range`, async () => { it(`should throw error if ${extension} available version is above range`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: versionAboveRange, availableVersion: versionAboveRange,
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
}); });
await expect(sut.onBootstrap()).rejects.toThrow(); await expect(sut.onBootstrap()).rejects.toThrow();
expect(mocks.database.createExtension).not.toHaveBeenCalled(); expect(databaseMock.createExtension).not.toHaveBeenCalled();
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it('should throw error if available version is below installed version', async () => { it('should throw error if available version is below installed version', async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
installedVersion: updateInRange, installedVersion: updateInRange,
}); });
@@ -194,13 +203,13 @@ describe(DatabaseService.name, () => {
`The database currently has ${extensionName} ${updateInRange} activated, but the Postgres instance only has ${minVersionInRange} available.`, `The database currently has ${extensionName} ${updateInRange} activated, but the Postgres instance only has ${minVersionInRange} available.`,
); );
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it('should throw error if installed version is not in version range', async () => { it('should throw error if installed version is not in version range', async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
installedVersion: versionAboveRange, installedVersion: versionAboveRange,
}); });
@@ -209,84 +218,84 @@ describe(DatabaseService.name, () => {
`The ${extensionName} extension version is ${versionAboveRange}, but Immich only supports`, `The ${extensionName} extension version is ${versionAboveRange}, but Immich only supports`,
); );
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should raise error if ${extension} extension upgrade failed`, async () => { it(`should raise error if ${extension} extension upgrade failed`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: updateInRange, availableVersion: updateInRange,
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
}); });
mocks.database.updateVectorExtension.mockRejectedValue(new Error('Failed to update extension')); databaseMock.updateVectorExtension.mockRejectedValue(new Error('Failed to update extension'));
await expect(sut.onBootstrap()).rejects.toThrow('Failed to update extension'); await expect(sut.onBootstrap()).rejects.toThrow('Failed to update extension');
expect(mocks.logger.warn.mock.calls[0][0]).toContain( expect(loggerMock.warn.mock.calls[0][0]).toContain(
`The ${extensionName} extension can be updated to ${updateInRange}.`, `The ${extensionName} extension can be updated to ${updateInRange}.`,
); );
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
expect(mocks.database.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange); expect(databaseMock.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange);
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should warn if ${extension} extension update requires restart`, async () => { it(`should warn if ${extension} extension update requires restart`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
availableVersion: updateInRange, availableVersion: updateInRange,
installedVersion: minVersionInRange, installedVersion: minVersionInRange,
}); });
mocks.database.updateVectorExtension.mockResolvedValue({ restartRequired: true }); databaseMock.updateVectorExtension.mockResolvedValue({ restartRequired: true });
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.logger.warn).toHaveBeenCalledTimes(1); expect(loggerMock.warn).toHaveBeenCalledTimes(1);
expect(mocks.logger.warn.mock.calls[0][0]).toContain(extensionName); expect(loggerMock.warn.mock.calls[0][0]).toContain(extensionName);
expect(mocks.database.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange); expect(databaseMock.updateVectorExtension).toHaveBeenCalledWith(extension, updateInRange);
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should reindex ${extension} indices if needed`, async () => { it(`should reindex ${extension} indices if needed`, async () => {
mocks.database.shouldReindex.mockResolvedValue(true); databaseMock.shouldReindex.mockResolvedValue(true);
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.shouldReindex).toHaveBeenCalledTimes(2); expect(databaseMock.shouldReindex).toHaveBeenCalledTimes(2);
expect(mocks.database.reindex).toHaveBeenCalledTimes(2); expect(databaseMock.reindex).toHaveBeenCalledTimes(2);
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
it(`should throw an error if reindexing fails`, async () => { it(`should throw an error if reindexing fails`, async () => {
mocks.database.shouldReindex.mockResolvedValue(true); databaseMock.shouldReindex.mockResolvedValue(true);
mocks.database.reindex.mockRejectedValue(new Error('Error reindexing')); databaseMock.reindex.mockRejectedValue(new Error('Error reindexing'));
await expect(sut.onBootstrap()).rejects.toBeDefined(); await expect(sut.onBootstrap()).rejects.toBeDefined();
expect(mocks.database.shouldReindex).toHaveBeenCalledTimes(1); expect(databaseMock.shouldReindex).toHaveBeenCalledTimes(1);
expect(mocks.database.reindex).toHaveBeenCalledTimes(1); expect(databaseMock.reindex).toHaveBeenCalledTimes(1);
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
expect(mocks.logger.warn).toHaveBeenCalledWith( expect(loggerMock.warn).toHaveBeenCalledWith(
expect.stringContaining('Could not run vector reindexing checks.'), expect.stringContaining('Could not run vector reindexing checks.'),
); );
}); });
it(`should not reindex ${extension} indices if not needed`, async () => { it(`should not reindex ${extension} indices if not needed`, async () => {
mocks.database.shouldReindex.mockResolvedValue(false); databaseMock.shouldReindex.mockResolvedValue(false);
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.shouldReindex).toHaveBeenCalledTimes(2); expect(databaseMock.shouldReindex).toHaveBeenCalledTimes(2);
expect(mocks.database.reindex).toHaveBeenCalledTimes(0); expect(databaseMock.reindex).toHaveBeenCalledTimes(0);
expect(mocks.database.runMigrations).toHaveBeenCalledTimes(1); expect(databaseMock.runMigrations).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal).not.toHaveBeenCalled(); expect(loggerMock.fatal).not.toHaveBeenCalled();
}); });
}); });
it('should skip migrations if DB_SKIP_MIGRATIONS=true', async () => { it('should skip migrations if DB_SKIP_MIGRATIONS=true', async () => {
mocks.config.getEnv.mockReturnValue( configMock.getEnv.mockReturnValue(
mockEnvData({ mockEnvData({
database: { database: {
config: { config: {
@@ -315,11 +324,11 @@ describe(DatabaseService.name, () => {
await expect(sut.onBootstrap()).resolves.toBeUndefined(); await expect(sut.onBootstrap()).resolves.toBeUndefined();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should throw error if pgvector extension could not be created`, async () => { it(`should throw error if pgvector extension could not be created`, async () => {
mocks.config.getEnv.mockReturnValue( configMock.getEnv.mockReturnValue(
mockEnvData({ mockEnvData({
database: { database: {
config: { config: {
@@ -345,41 +354,41 @@ describe(DatabaseService.name, () => {
}, },
}), }),
); );
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
installedVersion: null, installedVersion: null,
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
}); });
mocks.database.updateVectorExtension.mockResolvedValue({ restartRequired: false }); databaseMock.updateVectorExtension.mockResolvedValue({ restartRequired: false });
mocks.database.createExtension.mockRejectedValue(new Error('Failed to create extension')); databaseMock.createExtension.mockRejectedValue(new Error('Failed to create extension'));
await expect(sut.onBootstrap()).rejects.toThrow('Failed to create extension'); await expect(sut.onBootstrap()).rejects.toThrow('Failed to create extension');
expect(mocks.logger.fatal).toHaveBeenCalledTimes(1); expect(loggerMock.fatal).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal.mock.calls[0][0]).toContain( expect(loggerMock.fatal.mock.calls[0][0]).toContain(
`Alternatively, if your Postgres instance has pgvecto.rs, you may use this instead`, `Alternatively, if your Postgres instance has pgvecto.rs, you may use this instead`,
); );
expect(mocks.database.createExtension).toHaveBeenCalledTimes(1); expect(databaseMock.createExtension).toHaveBeenCalledTimes(1);
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
it(`should throw error if pgvecto.rs extension could not be created`, async () => { it(`should throw error if pgvecto.rs extension could not be created`, async () => {
mocks.database.getExtensionVersion.mockResolvedValue({ databaseMock.getExtensionVersion.mockResolvedValue({
installedVersion: null, installedVersion: null,
availableVersion: minVersionInRange, availableVersion: minVersionInRange,
}); });
mocks.database.updateVectorExtension.mockResolvedValue({ restartRequired: false }); databaseMock.updateVectorExtension.mockResolvedValue({ restartRequired: false });
mocks.database.createExtension.mockRejectedValue(new Error('Failed to create extension')); databaseMock.createExtension.mockRejectedValue(new Error('Failed to create extension'));
await expect(sut.onBootstrap()).rejects.toThrow('Failed to create extension'); await expect(sut.onBootstrap()).rejects.toThrow('Failed to create extension');
expect(mocks.logger.fatal).toHaveBeenCalledTimes(1); expect(loggerMock.fatal).toHaveBeenCalledTimes(1);
expect(mocks.logger.fatal.mock.calls[0][0]).toContain( expect(loggerMock.fatal.mock.calls[0][0]).toContain(
`Alternatively, if your Postgres instance has pgvector, you may use this instead`, `Alternatively, if your Postgres instance has pgvector, you may use this instead`,
); );
expect(mocks.database.createExtension).toHaveBeenCalledTimes(1); expect(databaseMock.createExtension).toHaveBeenCalledTimes(1);
expect(mocks.database.updateVectorExtension).not.toHaveBeenCalled(); expect(databaseMock.updateVectorExtension).not.toHaveBeenCalled();
expect(mocks.database.runMigrations).not.toHaveBeenCalled(); expect(databaseMock.runMigrations).not.toHaveBeenCalled();
}); });
}); });
@@ -394,38 +403,38 @@ describe(DatabaseService.name, () => {
it('should not override interval', () => { it('should not override interval', () => {
sut.handleConnectionError(new Error('Error')); sut.handleConnectionError(new Error('Error'));
expect(mocks.logger.error).toHaveBeenCalled(); expect(loggerMock.error).toHaveBeenCalled();
sut.handleConnectionError(new Error('foo')); sut.handleConnectionError(new Error('foo'));
expect(mocks.logger.error).toHaveBeenCalledTimes(1); expect(loggerMock.error).toHaveBeenCalledTimes(1);
}); });
it('should reconnect when interval elapses', async () => { it('should reconnect when interval elapses', async () => {
mocks.database.reconnect.mockResolvedValue(true); databaseMock.reconnect.mockResolvedValue(true);
sut.handleConnectionError(new Error('error')); sut.handleConnectionError(new Error('error'));
await vi.advanceTimersByTimeAsync(5000); await vi.advanceTimersByTimeAsync(5000);
expect(mocks.database.reconnect).toHaveBeenCalledTimes(1); expect(databaseMock.reconnect).toHaveBeenCalledTimes(1);
expect(mocks.logger.log).toHaveBeenCalledWith('Database reconnected'); expect(loggerMock.log).toHaveBeenCalledWith('Database reconnected');
await vi.advanceTimersByTimeAsync(5000); await vi.advanceTimersByTimeAsync(5000);
expect(mocks.database.reconnect).toHaveBeenCalledTimes(1); expect(databaseMock.reconnect).toHaveBeenCalledTimes(1);
}); });
it('should try again when reconnection fails', async () => { it('should try again when reconnection fails', async () => {
mocks.database.reconnect.mockResolvedValueOnce(false); databaseMock.reconnect.mockResolvedValueOnce(false);
sut.handleConnectionError(new Error('error')); sut.handleConnectionError(new Error('error'));
await vi.advanceTimersByTimeAsync(5000); await vi.advanceTimersByTimeAsync(5000);
expect(mocks.database.reconnect).toHaveBeenCalledTimes(1); expect(databaseMock.reconnect).toHaveBeenCalledTimes(1);
expect(mocks.logger.warn).toHaveBeenCalledWith(expect.stringContaining('Database connection failed')); expect(loggerMock.warn).toHaveBeenCalledWith(expect.stringContaining('Database connection failed'));
mocks.database.reconnect.mockResolvedValueOnce(true); databaseMock.reconnect.mockResolvedValueOnce(true);
await vi.advanceTimersByTimeAsync(5000); await vi.advanceTimersByTimeAsync(5000);
expect(mocks.database.reconnect).toHaveBeenCalledTimes(2); expect(databaseMock.reconnect).toHaveBeenCalledTimes(2);
expect(mocks.logger.log).toHaveBeenCalledWith('Database reconnected'); expect(loggerMock.log).toHaveBeenCalledWith('Database reconnected');
}); });
}); });
}); });

Some files were not shown because too many files have changed in this diff Show More