fix(server): force full sync on either public users transition

Re-enabling public users left previously hidden users stuck missing
from non-admin candidate lists, for the same reason as the disable
direction: incremental sync never re-fetches already-acked rows.
This commit is contained in:
br4yd 2026-08-05 11:02:25 +02:00
parent 36f1744063
commit 3cc2d61b32
No known key found for this signature in database
2 changed files with 13 additions and 3 deletions

View file

@ -89,7 +89,7 @@ const throwSessionRequired = () => {
export class SyncService extends BaseService {
@OnEvent({ name: 'ConfigUpdate', workers: [ImmichWorker.Api] })
async onConfigUpdate({ newConfig, oldConfig }: ArgOf<'ConfigUpdate'>) {
if (oldConfig.server.publicUsers && !newConfig.server.publicUsers) {
if (oldConfig.server.publicUsers !== newConfig.server.publicUsers) {
await this.sessionRepository.requireFullSyncForNonAdmins();
}
}

View file

@ -275,14 +275,14 @@ describe(SyncService.name, () => {
await expect(isPendingSyncReset(ctx.database, session.id)).resolves.toBe(false);
});
it('should not require a full sync when public users is enabled', async () => {
it('should require a full sync for non-admins when public users is enabled', async () => {
const { sut, ctx } = setup(await getKyselyDB());
const { user } = await ctx.newUser();
const { session } = await ctx.newSession({ userId: user.id });
await sut.onConfigUpdate({ oldConfig: withPublicUsers(false), newConfig: withPublicUsers(true) });
await expect(isPendingSyncReset(ctx.database, session.id)).resolves.toBe(false);
await expect(isPendingSyncReset(ctx.database, session.id)).resolves.toBe(true);
});
it('should not require a full sync when public users was already disabled', async () => {
@ -294,5 +294,15 @@ describe(SyncService.name, () => {
await expect(isPendingSyncReset(ctx.database, session.id)).resolves.toBe(false);
});
it('should not require a full sync when public users was already enabled', async () => {
const { sut, ctx } = setup(await getKyselyDB());
const { user } = await ctx.newUser();
const { session } = await ctx.newSession({ userId: user.id });
await sut.onConfigUpdate({ oldConfig: withPublicUsers(true), newConfig: withPublicUsers(true) });
await expect(isPendingSyncReset(ctx.database, session.id)).resolves.toBe(false);
});
});
});