mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix: no notification if release check is disabled (#25688)
This commit is contained in:
parent
1a04caee29
commit
0be1ffade6
2 changed files with 14 additions and 1 deletions
|
|
@ -130,7 +130,7 @@ describe(VersionService.name, () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onWebsocketConnectionEvent', () => {
|
describe('onWebsocketConnection', () => {
|
||||||
it('should send on_server_version client event', async () => {
|
it('should send on_server_version client event', async () => {
|
||||||
await sut.onWebsocketConnection({ userId: '42' });
|
await sut.onWebsocketConnection({ userId: '42' });
|
||||||
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_server_version', '42', expect.any(SemVer));
|
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_server_version', '42', expect.any(SemVer));
|
||||||
|
|
@ -143,5 +143,12 @@ describe(VersionService.name, () => {
|
||||||
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_server_version', '42', expect.any(SemVer));
|
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_server_version', '42', expect.any(SemVer));
|
||||||
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_new_release', '42', expect.any(Object));
|
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_new_release', '42', expect.any(Object));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not send a release notification when the version check is disabled', async () => {
|
||||||
|
mocks.systemMetadata.get.mockResolvedValueOnce({ newVersionCheck: { enabled: false } });
|
||||||
|
await sut.onWebsocketConnection({ userId: '42' });
|
||||||
|
expect(mocks.websocket.clientSend).toHaveBeenCalledWith('on_server_version', '42', expect.any(SemVer));
|
||||||
|
expect(mocks.websocket.clientSend).not.toHaveBeenCalledWith('on_new_release', '42', expect.any(Object));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,12 @@ export class VersionService extends BaseService {
|
||||||
@OnEvent({ name: 'WebsocketConnect' })
|
@OnEvent({ name: 'WebsocketConnect' })
|
||||||
async onWebsocketConnection({ userId }: ArgOf<'WebsocketConnect'>) {
|
async onWebsocketConnection({ userId }: ArgOf<'WebsocketConnect'>) {
|
||||||
this.websocketRepository.clientSend('on_server_version', userId, serverVersion);
|
this.websocketRepository.clientSend('on_server_version', userId, serverVersion);
|
||||||
|
|
||||||
|
const { newVersionCheck } = await this.getConfig({ withCache: true });
|
||||||
|
if (!newVersionCheck.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const metadata = await this.systemMetadataRepository.get(SystemMetadataKey.VersionCheckState);
|
const metadata = await this.systemMetadataRepository.get(SystemMetadataKey.VersionCheckState);
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
this.websocketRepository.clientSend('on_new_release', userId, asNotification(metadata));
|
this.websocketRepository.clientSend('on_new_release', userId, asNotification(metadata));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue