Skip to content

Commit

Permalink
fix(bluetooth-low-energy): use original id for allowlist check
Browse files Browse the repository at this point in the history
Otherwise this leads to confusing config requirements with overridden
tag ids.

Closes #596
  • Loading branch information
mKeRix committed Apr 11, 2021
1 parent d0c5c52 commit 6a5d0cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -424,7 +424,9 @@ describe('BluetoothLowEnergyService', () => {
const handleDistanceSpy = jest
.spyOn(service, 'handleNewDistance')
.mockImplementation(() => undefined);
const allowlistSpy = jest.spyOn(service, 'isOnAllowlist').mockReturnValue(true);
const allowlistSpy = jest
.spyOn(service, 'isOnAllowlist')
.mockReturnValue(true);
jest.spyOn(service, 'isAllowlistEnabled').mockReturnValue(true);
mockConfig.tagOverrides = {
abcd: {
Expand All @@ -445,7 +447,7 @@ describe('BluetoothLowEnergyService', () => {
tagId: 'new-id',
})
);
expect(allowlistSpy).toHaveBeenCalledWith('new-id')
expect(allowlistSpy).toHaveBeenCalledWith('abcd');
});

it('should apply a tag name override if it exists', async () => {
Expand Down Expand Up @@ -1290,7 +1292,7 @@ describe('BluetoothLowEnergyService', () => {

expect(discoverSpy).toHaveBeenCalledTimes(1);

jest.advanceTimersByTime(1 * 60 * 1000);
jest.advanceTimersByTime(60 * 1000);

await service.handleDiscovery(peripheral);

Expand Down
Expand Up @@ -93,7 +93,6 @@ export class BluetoothLowEnergyService
}

tag = await this.applyCompanionAppOverride(tag);
tag = this.applyOverrides(tag);

if (!this.seenIds.has(tag.id)) {
this.logger.log(
Expand All @@ -107,6 +106,7 @@ export class BluetoothLowEnergyService
(!this.isAllowlistEnabled() && this.isDenylistEnabled())) &&
!this.isOnDenylist(tag.id)
) {
tag = this.applyOverrides(tag);
tag.rssi = this.filterRssi(tag.id, tag.rssi);

const globalSettings = this.configService.get('global');
Expand Down

0 comments on commit 6a5d0cc

Please sign in to comment.