@@ -122,14 +122,15 @@ async def handle_invite(self, room_id: RoomID, user_id: UserID, inviter: 'u.User
122
122
return
123
123
await user .ensure_started ()
124
124
portal = po .Portal .get_by_mxid (room_id )
125
- if user and await user .has_full_access (allow_bot = True ) and portal :
126
- await portal .invite_telegram (inviter , user )
125
+ if user and await user .has_full_access (allow_bot = True ):
126
+ if portal and portal .allow_bridging :
127
+ await portal .invite_telegram (inviter , user )
127
128
128
129
async def handle_join (self , room_id : RoomID , user_id : UserID , event_id : EventID ) -> None :
129
130
user = await u .User .get_by_mxid (user_id ).ensure_started ()
130
131
131
132
portal = po .Portal .get_by_mxid (room_id )
132
- if not portal :
133
+ if not portal or not portal . allow_bridging :
133
134
return
134
135
135
136
if not user .relaybot_whitelisted :
@@ -152,7 +153,7 @@ async def get_leave_handle_info(self) -> Tuple[po.Portal, u.User]:
152
153
async def handle_leave (self , room_id : RoomID , user_id : UserID , event_id : EventID ) -> None :
153
154
self .log .debug (f"{ user_id } left { room_id } " )
154
155
portal = po .Portal .get_by_mxid (room_id )
155
- if not portal :
156
+ if not portal or not portal . allow_bridging :
156
157
return
157
158
158
159
user = u .User .get_by_mxid (user_id , create = False )
@@ -166,7 +167,7 @@ async def handle_kick_ban(self, ban: bool, room_id: RoomID, user_id: UserID, sen
166
167
action = "banned" if ban else "kicked"
167
168
self .log .debug (f"{ user_id } was { action } from { room_id } by { sender } for { reason } " )
168
169
portal = po .Portal .get_by_mxid (room_id )
169
- if not portal :
170
+ if not portal or not portal . allow_bridging :
170
171
return
171
172
172
173
if user_id == self .az .bot_mxid :
@@ -229,7 +230,7 @@ async def handle_redaction(evt: RedactionEvent) -> None:
229
230
return
230
231
231
232
portal = po .Portal .get_by_mxid (evt .room_id )
232
- if not portal :
233
+ if not portal or not portal . allow_bridging :
233
234
return
234
235
235
236
await portal .handle_matrix_deletion (sender , evt .redacts , evt .event_id )
@@ -238,7 +239,7 @@ async def handle_redaction(evt: RedactionEvent) -> None:
238
239
async def handle_power_levels (evt : StateEvent ) -> None :
239
240
portal = po .Portal .get_by_mxid (evt .room_id )
240
241
sender = await u .User .get_by_mxid (evt .sender ).ensure_started ()
241
- if await sender .has_full_access (allow_bot = True ) and portal :
242
+ if await sender .has_full_access (allow_bot = True ) and portal and portal . allow_bridging :
242
243
await portal .handle_matrix_power_levels (sender , evt .content .users ,
243
244
evt .unsigned .prev_content .users ,
244
245
evt .event_id )
@@ -248,7 +249,7 @@ async def handle_room_meta(evt_type: EventType, room_id: RoomID, sender_mxid: Us
248
249
content : RoomMetaStateEventContent , event_id : EventID ) -> None :
249
250
portal = po .Portal .get_by_mxid (room_id )
250
251
sender = await u .User .get_by_mxid (sender_mxid ).ensure_started ()
251
- if await sender .has_full_access (allow_bot = True ) and portal :
252
+ if await sender .has_full_access (allow_bot = True ) and portal and portal . allow_bridging :
252
253
handler , content_type , content_key = {
253
254
EventType .ROOM_NAME : (portal .handle_matrix_title , RoomNameStateEventContent , "name" ),
254
255
EventType .ROOM_TOPIC : (portal .handle_matrix_about , RoomTopicStateEventContent , "topic" ),
@@ -264,7 +265,7 @@ async def handle_room_pin(room_id: RoomID, sender_mxid: UserID,
264
265
event_id : EventID ) -> None :
265
266
portal = po .Portal .get_by_mxid (room_id )
266
267
sender = await u .User .get_by_mxid (sender_mxid ).ensure_started ()
267
- if await sender .has_full_access (allow_bot = True ) and portal :
268
+ if await sender .has_full_access (allow_bot = True ) and portal and portal . allow_bridging :
268
269
if not new_events :
269
270
await portal .handle_matrix_unpin_all (sender , event_id )
270
271
else :
@@ -276,7 +277,7 @@ async def handle_room_pin(room_id: RoomID, sender_mxid: UserID,
276
277
async def handle_room_upgrade (room_id : RoomID , sender : UserID , new_room_id : RoomID ,
277
278
event_id : EventID ) -> None :
278
279
portal = po .Portal .get_by_mxid (room_id )
279
- if portal :
280
+ if portal and portal . allow_bridging :
280
281
await portal .handle_matrix_upgrade (sender , new_room_id , event_id )
281
282
282
283
async def handle_member_info_change (self , room_id : RoomID , user_id : UserID ,
@@ -287,7 +288,7 @@ async def handle_member_info_change(self, room_id: RoomID, user_id: UserID,
287
288
return
288
289
289
290
portal = po .Portal .get_by_mxid (room_id )
290
- if not portal or not portal .has_bot :
291
+ if not portal or not portal .has_bot or not portal . allow_bridging :
291
292
return
292
293
293
294
user = await u .User .get_by_mxid (user_id ).ensure_started ()
@@ -305,7 +306,7 @@ def parse_read_receipts(content: ReceiptEventContent) -> Iterable[Tuple[UserID,
305
306
async def handle_read_receipts (room_id : RoomID , receipts : Iterable [Tuple [UserID , EventID ]]
306
307
) -> None :
307
308
portal = po .Portal .get_by_mxid (room_id )
308
- if not portal :
309
+ if not portal or not portal . allow_bridging :
309
310
return
310
311
311
312
for user_id , event_id in receipts :
@@ -321,7 +322,7 @@ async def handle_presence(user_id: UserID, presence: PresenceState) -> None:
321
322
322
323
async def handle_typing (self , room_id : RoomID , now_typing : Set [UserID ]) -> None :
323
324
portal = po .Portal .get_by_mxid (room_id )
324
- if not portal :
325
+ if not portal or not portal . allow_bridging :
325
326
return
326
327
327
328
previously_typing = self .previously_typing .get (room_id , set ())
0 commit comments