fix(server): hide isFavorite from partner asset sync stream (#28035)

* fix(server): hide isFavorite from partner asset sync stream

* use new column entry instead

* sync sql

* add migration

* use sql.val

* sync sql
This commit is contained in:
Timon
2026-05-07 18:00:54 +02:00
committed by GitHub
parent fe2bf0c6dd
commit 7de73dc176
4 changed files with 43 additions and 11 deletions
+20
View File
@@ -395,6 +395,26 @@ export const columns = {
'asset.height', 'asset.height',
'asset.isEdited', 'asset.isEdited',
], ],
syncPartnerAsset: [
'asset.id',
'asset.ownerId',
'asset.originalFileName',
'asset.thumbhash',
'asset.checksum',
'asset.fileCreatedAt',
'asset.fileModifiedAt',
'asset.localDateTime',
'asset.type',
'asset.deletedAt',
'asset.visibility',
'asset.duration',
'asset.livePhotoVideoId',
'asset.stackId',
'asset.libraryId',
'asset.width',
'asset.height',
'asset.isEdited',
],
syncAlbumUser: ['album_user.albumId as albumId', 'album_user.userId as userId', 'album_user.role'], syncAlbumUser: ['album_user.albumId as albumId', 'album_user.userId as userId', 'album_user.role'],
syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'], syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'],
syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId', 'profileImagePath', 'profileChangedAt'], syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId', 'profileImagePath', 'profileChangedAt'],
+9 -9
View File
@@ -739,7 +739,6 @@ select
"asset"."localDateTime", "asset"."localDateTime",
"asset"."type", "asset"."type",
"asset"."deletedAt", "asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId", "asset"."livePhotoVideoId",
@@ -748,14 +747,15 @@ select
"asset"."width", "asset"."width",
"asset"."height", "asset"."height",
"asset"."isEdited", "asset"."isEdited",
$1 as "isFavorite",
"asset"."updateId" "asset"."updateId"
from from
"asset" as "asset" "asset" as "asset"
where where
"asset"."updateId" < $1 "asset"."updateId" < $2
and "asset"."updateId" <= $2 and "asset"."updateId" <= $3
and "asset"."updateId" >= $3 and "asset"."updateId" >= $4
and "ownerId" = $4 and "ownerId" = $5
order by order by
"asset"."updateId" asc "asset"."updateId" asc
@@ -791,7 +791,6 @@ select
"asset"."localDateTime", "asset"."localDateTime",
"asset"."type", "asset"."type",
"asset"."deletedAt", "asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility", "asset"."visibility",
"asset"."duration", "asset"."duration",
"asset"."livePhotoVideoId", "asset"."livePhotoVideoId",
@@ -800,19 +799,20 @@ select
"asset"."width", "asset"."width",
"asset"."height", "asset"."height",
"asset"."isEdited", "asset"."isEdited",
$1 as "isFavorite",
"asset"."updateId" "asset"."updateId"
from from
"asset" as "asset" "asset" as "asset"
where where
"asset"."updateId" < $1 "asset"."updateId" < $2
and "asset"."updateId" > $2 and "asset"."updateId" > $3
and "ownerId" in ( and "ownerId" in (
select select
"sharedById" "sharedById"
from from
"partner" "partner"
where where
"sharedWithId" = $3 "sharedWithId" = $4
) )
order by order by
"asset"."updateId" asc "asset"."updateId" asc
+4 -2
View File
@@ -595,7 +595,8 @@ class PartnerAssetsSync extends BaseSync {
@GenerateSql({ params: [dummyBackfillOptions, DummyValue.UUID], stream: true }) @GenerateSql({ params: [dummyBackfillOptions, DummyValue.UUID], stream: true })
getBackfill(options: SyncBackfillOptions, partnerId: string) { getBackfill(options: SyncBackfillOptions, partnerId: string) {
return this.backfillQuery('asset', options) return this.backfillQuery('asset', options)
.select(columns.syncAsset) .select(columns.syncPartnerAsset)
.select(sql.val(false).as('isFavorite'))
.select('asset.updateId') .select('asset.updateId')
.where('ownerId', '=', partnerId) .where('ownerId', '=', partnerId)
.stream(); .stream();
@@ -614,7 +615,8 @@ class PartnerAssetsSync extends BaseSync {
@GenerateSql({ params: [dummyQueryOptions], stream: true }) @GenerateSql({ params: [dummyQueryOptions], stream: true })
getUpserts(options: SyncQueryOptions) { getUpserts(options: SyncQueryOptions) {
return this.upsertQuery('asset', options) return this.upsertQuery('asset', options)
.select(columns.syncAsset) .select(columns.syncPartnerAsset)
.select(sql.val(false).as('isFavorite'))
.select('asset.updateId') .select('asset.updateId')
.where('ownerId', 'in', (eb) => .where('ownerId', 'in', (eb) =>
eb.selectFrom('partner').select(['sharedById']).where('sharedWithId', '=', options.userId), eb.selectFrom('partner').select(['sharedById']).where('sharedWithId', '=', options.userId),
@@ -0,0 +1,10 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
// isFavorite was incorrectly included in partner asset sync on server <=2.X.X
await sql`DELETE FROM session_sync_checkpoint WHERE type in ('PartnerAssetV1', 'PartnerAssetBackfillV1')`.execute(db);
}
export async function down(): Promise<void> {
// Not implemented
}