mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-09-15 05:52:39 +00:00
(new Promise()).resolve() doesn't exist. simplify event id
This commit is contained in:
parent
7049f191a6
commit
abd305cc93
@ -21,35 +21,23 @@ describe("Test: Report polling", function() {
|
|||||||
it("Mjolnir correctly retreives a report from synapse", async function() {
|
it("Mjolnir correctly retreives a report from synapse", async function() {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
|
|
||||||
const reportPromise = new Promise();
|
const reportPromise = new Promise(async (resolve, reject) => {
|
||||||
|
|
||||||
await this.mjolnir.registerProtection(new class implements IProtection {
|
await this.mjolnir.registerProtection(new class implements IProtection {
|
||||||
name = "jYvufI";
|
name = "jYvufI";
|
||||||
description = "A test protection";
|
description = "A test protection";
|
||||||
settings = { };
|
settings = { };
|
||||||
handleReport = async (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
|
handleReport = (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
|
||||||
reportPromise.resolve(null);
|
resolve(null);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
});
|
||||||
await this.mjolnir.enableProtection("jYvufI");
|
await this.mjolnir.enableProtection("jYvufI");
|
||||||
|
|
||||||
const roomId = this.mjolnir.managementRoomId;
|
const roomId = this.mjolnir.managementRoomId;
|
||||||
await this.mjolnir.client.inviteUser(await client.getUserId(), roomId);
|
await this.mjolnir.client.inviteUser(await client.getUserId(), roomId);
|
||||||
await client.joinRoom(roomId);
|
await client.joinRoom(roomId);
|
||||||
|
|
||||||
let reply = new Promise(async (resolve, reject) => {
|
const eventId = await badUser.sendMesosage(roomId, {msgtype: "m.text", body: "uwNd3q"});
|
||||||
const messageId = await badUser.sendMesosage(roomId, {msgtype: "m.text", body: "uwNd3q"});
|
|
||||||
badUser.on('room.event', (eventRoomId, event) => {
|
|
||||||
if (
|
|
||||||
eventRoomId === roomId
|
|
||||||
&& event?.event_id === messageId
|
|
||||||
) {
|
|
||||||
resolve(messageId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const eventId = await reply;
|
|
||||||
|
|
||||||
await client.doRequest(
|
await client.doRequest(
|
||||||
"POST",
|
"POST",
|
||||||
`/_matrix/client/r0/rooms/${encodeURIComponent(roomId)}/report/${encodeURIComponent(eventId)}`, "", {
|
`/_matrix/client/r0/rooms/${encodeURIComponent(roomId)}/report/${encodeURIComponent(eventId)}`, "", {
|
||||||
|
Loading…
Reference in New Issue
Block a user