Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure encrypted events are not handled twice #267

Merged
merged 6 commits into from
Oct 30, 2020

Conversation

Half-Shot
Copy link
Contributor

Fixes #266

This should address some problems with the encrypted event tracking

@Half-Shot Half-Shot requested a review from a team October 30, 2020 14:35

// Delete the event from the pending list
this.eventsPendingSync.delete(event.event_id);
let index = this.eventsPendingAS.findIndex((e) => e.event_id === event.event_id);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible we might get multiple sync events stored.

Copy link
Member

@benparsons benparsons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questions

src/components/encryption.ts Show resolved Hide resolved
@@ -86,16 +86,18 @@ export class EncryptedEventBroker {
private onEphemeralEvent: ((event: EphemeralEvent) => void)|undefined,
private getIntent: (userId: string) => Intent
) {
if (this.onEphemeralEvent) {
this.presenceCleanupInterval = setInterval(() => {
const ts = Date.now() - 30000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

30s wants to be a config var?

Copy link
Contributor Author

@Half-Shot Half-Shot Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make it a const but I don't think there is any value in it being a config value, it's just a cache lifetime.

src/components/encryption.ts Show resolved Hide resolved
this.eventsPendingSync.delete(event.event_id);
let index = this.eventsPendingAS.findIndex((e) => e.event_id === event.event_id);
do {
this.eventsPendingAS.splice(index, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would all of this be possible with this.eventsPendingAS = this.eventsPendingAS.filter((e) => e.event_id !== event.event_id)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I prefer that.

Copy link
Member

@benparsons benparsons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Half-Shot Half-Shot merged commit 298c164 into develop Oct 30, 2020
@Half-Shot Half-Shot deleted the hs/improve-broker-duplication-checking branch May 2, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EncryptedEventBroker may emit twice for a single event when two users are syncing
2 participants