From ba460c5cbb2be49341abfea8f0792a1399a87ccf Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Wed, 15 Feb 2023 14:24:01 +0100 Subject: [PATCH] Revert "decrypt poll relations before processing (#3148)" This reverts commit cdd7dbbb2b12ba97e8d0a6368f7ca42be5131a62. --- spec/unit/models/poll.spec.ts | 4 ---- src/models/poll.ts | 3 --- 2 files changed, 7 deletions(-) diff --git a/spec/unit/models/poll.spec.ts b/spec/unit/models/poll.spec.ts index 245d5646501..9ca3df7a2fa 100644 --- a/spec/unit/models/poll.spec.ts +++ b/spec/unit/models/poll.spec.ts @@ -20,7 +20,6 @@ import { M_POLL_END, M_POLL_KIND_DISCLOSED, M_POLL_RESPONSE } from "../../../src import { PollStartEvent } from "../../../src/extensible_events_v1/PollStartEvent"; import { Poll } from "../../../src/models/poll"; import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../test-utils/client"; -import { flushPromises } from "../../test-utils/flushPromises"; jest.useFakeTimers(); @@ -28,7 +27,6 @@ describe("Poll", () => { const userId = "@alice:server.org"; const mockClient = getMockClientWithEventEmitter({ ...mockClientMethodsUser(userId), - decryptEventIfNeeded: jest.fn().mockResolvedValue(true), relations: jest.fn(), }); const roomId = "!room:server"; @@ -174,8 +172,6 @@ describe("Poll", () => { jest.spyOn(poll, "emit"); const responses = await poll.getResponses(); - await flushPromises(); - expect(mockClient.relations.mock.calls).toEqual([ [roomId, basePollStartEvent.getId(), "m.reference", undefined, { from: undefined }], [roomId, basePollStartEvent.getId(), "m.reference", undefined, { from: "test-next-1" }], diff --git a/src/models/poll.ts b/src/models/poll.ts index 8a080ef9015..7c5d245f7e7 100644 --- a/src/models/poll.ts +++ b/src/models/poll.ts @@ -149,14 +149,11 @@ export class Poll extends TypedEventEmitter, P }, ); - await Promise.all(allRelations.events.map((event) => this.matrixClient.decryptEventIfNeeded(event))); - const responses = this.responses || new Relations("m.reference", M_POLL_RESPONSE.name, this.matrixClient, [M_POLL_RESPONSE.altName!]); const pollEndEvent = allRelations.events.find((event) => M_POLL_END.matches(event.getType())); - if (this.validateEndEvent(pollEndEvent)) { this.endEvent = pollEndEvent; this.refilterResponsesOnEnd();