-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fix: shared link add to album #27063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Kysely, sql } from 'kysely'; | ||
|
|
||
| export async function up(db: Kysely<any>): Promise<void> { | ||
| await sql` | ||
| DELETE FROM "shared_link_asset" | ||
| USING "shared_link" | ||
| WHERE "shared_link_asset"."sharedLinkId" = "shared_link"."id" AND "shared_link"."type" = 'ALBUM'; | ||
| `.execute(db); | ||
| } | ||
|
|
||
| export async function down(): Promise<void> { | ||
| // noop | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { BadRequestException, Injectable, InternalServerErrorException, NotFound | |
| import { extname } from 'node:path'; | ||
| import sanitize from 'sanitize-filename'; | ||
| import { StorageCore } from 'src/cores/storage.core'; | ||
| import { Asset } from 'src/database'; | ||
| import { Asset, AuthSharedLink } from 'src/database'; | ||
| import { | ||
| AssetBulkUploadCheckResponseDto, | ||
| AssetMediaResponseDto, | ||
|
|
@@ -152,7 +152,7 @@ export class AssetMediaService extends BaseService { | |
| const asset = await this.create(auth.user.id, dto, file, sidecarFile); | ||
|
|
||
| if (auth.sharedLink) { | ||
| await this.sharedLinkRepository.addAssets(auth.sharedLink.id, [asset.id]); | ||
| await this.addToSharedLink(auth.sharedLink, asset.id); | ||
| } | ||
|
|
||
| await this.userRepository.updateUsage(auth.user.id, file.size); | ||
|
|
@@ -326,6 +326,12 @@ export class AssetMediaService extends BaseService { | |
| }; | ||
| } | ||
|
|
||
| private async addToSharedLink(sharedLink: AuthSharedLink, assetId: string) { | ||
| await (sharedLink.albumId | ||
| ? this.albumRepository.addAssetIds(sharedLink.albumId, [assetId]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate guest uploads to a shared album return an internal server error:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I'll update it to ignore conflicts. |
||
| : this.sharedLinkRepository.addAssets(sharedLink.id, [assetId])); | ||
| } | ||
|
|
||
| private async handleUploadError( | ||
| error: any, | ||
| auth: AuthDto, | ||
|
|
@@ -347,7 +353,7 @@ export class AssetMediaService extends BaseService { | |
| } | ||
|
|
||
| if (auth.sharedLink) { | ||
| await this.sharedLinkRepository.addAssets(auth.sharedLink.id, [duplicateId]); | ||
| await this.addToSharedLink(auth.sharedLink, duplicateId); | ||
| } | ||
|
|
||
| return { status: AssetMediaStatus.DUPLICATE, id: duplicateId }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.