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
pull/28271/head
Timon 2026-05-07 18:00:54 +02:00 committed by GitHub
parent fe2bf0c6dd
commit 7de73dc176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 11 deletions

View File

@ -395,6 +395,26 @@ export const columns = {
'asset.height',
'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'],
syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'],
syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId', 'profileImagePath', 'profileChangedAt'],

View File

@ -739,7 +739,6 @@ select
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
@ -748,14 +747,15 @@ select
"asset"."width",
"asset"."height",
"asset"."isEdited",
$1 as "isFavorite",
"asset"."updateId"
from
"asset" as "asset"
where
"asset"."updateId" < $1
and "asset"."updateId" <= $2
and "asset"."updateId" >= $3
and "ownerId" = $4
"asset"."updateId" < $2
and "asset"."updateId" <= $3
and "asset"."updateId" >= $4
and "ownerId" = $5
order by
"asset"."updateId" asc
@ -791,7 +791,6 @@ select
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
@ -800,19 +799,20 @@ select
"asset"."width",
"asset"."height",
"asset"."isEdited",
$1 as "isFavorite",
"asset"."updateId"
from
"asset" as "asset"
where
"asset"."updateId" < $1
and "asset"."updateId" > $2
"asset"."updateId" < $2
and "asset"."updateId" > $3
and "ownerId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
"sharedWithId" = $4
)
order by
"asset"."updateId" asc

View File

@ -595,7 +595,8 @@ class PartnerAssetsSync extends BaseSync {
@GenerateSql({ params: [dummyBackfillOptions, DummyValue.UUID], stream: true })
getBackfill(options: SyncBackfillOptions, partnerId: string) {
return this.backfillQuery('asset', options)
.select(columns.syncAsset)
.select(columns.syncPartnerAsset)
.select(sql.val(false).as('isFavorite'))
.select('asset.updateId')
.where('ownerId', '=', partnerId)
.stream();
@ -614,7 +615,8 @@ class PartnerAssetsSync extends BaseSync {
@GenerateSql({ params: [dummyQueryOptions], stream: true })
getUpserts(options: SyncQueryOptions) {
return this.upsertQuery('asset', options)
.select(columns.syncAsset)
.select(columns.syncPartnerAsset)
.select(sql.val(false).as('isFavorite'))
.select('asset.updateId')
.where('ownerId', 'in', (eb) =>
eb.selectFrom('partner').select(['sharedById']).where('sharedWithId', '=', options.userId),

View File

@ -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
}