1
1
/*
2
- Copyright 2019-2024 The Matrix.org Foundation C.I.C.
2
+ Copyright 2019-2021 The Matrix.org Foundation C.I.C.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -14,14 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import {
18
- extractRequestError ,
19
- LogLevel ,
20
- LogService ,
21
- MembershipEvent ,
22
- Permalinks ,
23
- UserID ,
24
- } from "@vector-im/matrix-bot-sdk" ;
17
+ import { extractRequestError , LogLevel , LogService , MembershipEvent } from "@vector-im/matrix-bot-sdk" ;
25
18
26
19
import { ALL_RULE_TYPES as ALL_BAN_LIST_RULE_TYPES } from "./models/ListRule" ;
27
20
import { COMMAND_PREFIX , handleCommand } from "./commands/CommandHandler" ;
@@ -41,7 +34,6 @@ import { RoomMemberManager } from "./RoomMembers";
41
34
import ProtectedRoomsConfig from "./ProtectedRoomsConfig" ;
42
35
import { MatrixEmitter , MatrixSendClient } from "./MatrixEmitter" ;
43
36
import { OpenMetrics } from "./webapis/OpenMetrics" ;
44
- import { LRUCache } from "lru-cache" ;
45
37
import { ModCache } from "./ModCache" ;
46
38
47
39
export const STATE_NOT_STARTED = "not_started" ;
@@ -90,11 +82,6 @@ export class Mjolnir {
90
82
91
83
public readonly policyListManager : PolicyListManager ;
92
84
93
- public readonly lastBotMentionForRoomId = new LRUCache < string , true > ( {
94
- ttl : 1000 * 60 * 8 , // 8 minutes
95
- ttlAutopurge : true ,
96
- } ) ;
97
-
98
85
/**
99
86
* Members of the moderator room and others who should not be banned, ACL'd etc.
100
87
*/
@@ -220,29 +207,9 @@ export class Mjolnir {
220
207
221
208
matrixEmitter . on ( "room.message" , async ( roomId , event ) => {
222
209
const eventContent = event . content ;
210
+ if ( roomId !== this . managementRoomId ) return ;
223
211
if ( typeof eventContent !== "object" ) return ;
224
212
225
- if ( this . config . forwardMentionsToManagementRoom && this . protectedRoomsTracker . isProtectedRoom ( roomId ) ) {
226
- if ( eventContent ?. [ "m.mentions" ] ?. user_ids ?. includes ( this . clientUserId ) ) {
227
- LogService . info ( "Mjolnir" , `Bot mentioned ${ roomId } by ${ event . sender } ` ) ;
228
- // Bot mentioned in a public room.
229
- if ( this . lastBotMentionForRoomId . has ( roomId ) ) {
230
- // Mentioned too recently, ignore.
231
- return ;
232
- }
233
- this . lastBotMentionForRoomId . set ( roomId , true ) ;
234
- const permalink = Permalinks . forEvent ( roomId , event . event_id , [
235
- new UserID ( this . clientUserId ) . domain ,
236
- ] ) ;
237
- await this . managementRoomOutput . logMessage (
238
- LogLevel . INFO ,
239
- "Mjolnir" ,
240
- `Bot mentioned ${ roomId } by ${ event . sender } in ${ permalink } ` ,
241
- roomId ,
242
- ) ;
243
- }
244
- }
245
-
246
213
const { msgtype, body : originalBody , sender } = eventContent ;
247
214
const eventId = event . event_id ;
248
215
if ( msgtype !== "m.text" || typeof originalBody !== "string" ) {
0 commit comments