This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Ignore incoming events for rooms that we have left #2490
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -533,6 +533,46 @@ def is_host_joined(self, room_id, host): | |
|
||
defer.returnValue(True) | ||
|
||
@cachedInlineCallbacks() | ||
def was_host_joined(self, room_id, host): | ||
"""Check whether the server is or ever was in the room. | ||
|
||
Args: | ||
room_id (str) | ||
host (str) | ||
|
||
Returns: | ||
Deferred: Resolves to True if the host is/was in the room, otherwise | ||
False. | ||
""" | ||
if '%' in host or '_' in host: | ||
raise Exception("Invalid host name") | ||
|
||
sql = """ | ||
SELECT user_id FROM room_memberships | ||
WHERE room_id = ? | ||
AND user_id LIKE ? | ||
AND membership = 'join' | ||
LIMIT 1 | ||
""" | ||
|
||
# We do need to be careful to ensure that host doesn't have any wild cards | ||
# in it, but we checked above for known ones and we'll check below that | ||
# the returned user actually has the correct domain. | ||
like_clause = "%:" + host | ||
|
||
rows = yield self._execute("was_host_joined", None, sql, room_id, like_clause) | ||
|
||
if not rows: | ||
defer.returnValue(False) | ||
|
||
user_id = rows[0][0] | ||
if get_domain_from_id(user_id) != host: | ||
# This can only happen if the host name has something funky in it | ||
raise Exception("Invalid host name") | ||
|
||
defer.returnValue(True) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is almost an exact copy of |
||
def get_joined_hosts(self, room_id, state_entry): | ||
state_group = state_entry.state_group | ||
if not state_group: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
erm; do we not need to arrange for this cache to be flushed?