Skip to content

Commit

Permalink
Skipp DeviceSerialNumber syncing.
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed Dec 6, 2018
1 parent 5982b4f commit 84049b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions webpack/connectivity/__tests__/auto_sync_test.ts
Expand Up @@ -125,6 +125,12 @@ describe("routeMqttData", () => {
results.status === "ERR" && expect(results.reason).toEqual(Reason.BAD_CHAN);
});

it("tosses out resources that the FE does not care about", () => {
const results =
routeMqttData("bot/device_9/sync/DeviceSerialNumber/1", toBinary({}));
expect(results.status).toEqual("SKIP");
});

it("handles well formed deletion data", () => {
const results = routeMqttData("bot/device_9/sync/Sequence/1", toBinary({}));
expect(results.status).toEqual("DELETE");
Expand Down
5 changes: 4 additions & 1 deletion webpack/connectivity/auto_sync.ts
Expand Up @@ -14,6 +14,8 @@ export function decodeBinary(payload: Buffer): SyncPayload {
return JSON.parse((payload).toString());
}

const SKIP_THESE = ["DeviceSerialNumber"]; // Only FBOS Cares about this one.

export function routeMqttData(chan: string, payload: Buffer): MqttDataResult<TaggedResource> {
/** Skip irrelevant messages */
if (!chan.includes("sync")) { return { status: "SKIP" }; }
Expand All @@ -23,7 +25,8 @@ export function routeMqttData(chan: string, payload: Buffer): MqttDataResult<Tag
if (parts.length !== 5) { return { status: "ERR", reason: Reason.BAD_CHAN }; }

const id = parseInt(parts.pop() || "0", 10);
const kind = parts.pop() as TaggedResource["kind"]; // TODO FIXME RC 31OCT18
const kind = parts.pop() as TaggedResource["kind"];
if (SKIP_THESE.includes(kind)) { return { status: "SKIP" }; }
const { body, args } = decodeBinary(payload);

if (body) {
Expand Down

0 comments on commit 84049b1

Please sign in to comment.