Skip to content

Commit

Permalink
Do not send event hash to WebSocket clients
Browse files Browse the repository at this point in the history
  • Loading branch information
coocos committed Apr 10, 2021
1 parent eecfae4 commit 9aae77b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { events, RescueEvent } from "./services/events";
import { fetchFeedEvents } from "./services/feed";

export const pollFeed = (
eventCallback: (event: RescueEvent) => void
eventCallback: (event: Omit<RescueEvent, "hash">) => void
): cron.ScheduledTask => {
const task = cron.schedule(config.feed.schedule, async () => {
try {
Expand All @@ -15,7 +15,11 @@ export const pollFeed = (
if (!(await events.exists(event))) {
logger.info("New event", event);
await events.add(event);
eventCallback(event);
eventCallback({
location: event.location,
time: event.time,
type: event.type,
});
}
}
} catch (err) {
Expand Down
2 changes: 0 additions & 2 deletions src/server.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ describe("Server", () => {
type: "rakennuspalo: pieni",
location: "Kokkola",
time: "2021-03-01T15:59:04.000Z",
hash: "c7aae8a31f3d31d228aa33368be142663bad9577",
},
{
type: "rakennuspalo: pieni",
location: "Helsinki",
time: "2021-03-01T15:40:52.000Z",
hash: "169a28a0c1979d7c105490bde4e30ce5b64418a5",
},
]);
client.close();
Expand Down
2 changes: 0 additions & 2 deletions src/websocket/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe("WebSocket server", () => {
type: "rakennuspalo: keskisuuri",
location: "Tuusula",
time: new Date("2021-01-31T22:00:00.000Z"),
hash: "2a39407ee0570aae8f3ba2842e11aa28ce0f5d9f",
});
});
client.on("message", (data) => {
Expand All @@ -31,7 +30,6 @@ describe("WebSocket server", () => {
type: "rakennuspalo: keskisuuri",
location: "Tuusula",
time: "2021-01-31T22:00:00.000Z",
hash: "2a39407ee0570aae8f3ba2842e11aa28ce0f5d9f",
});
client.close();
done();
Expand Down

0 comments on commit 9aae77b

Please sign in to comment.