-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a query param participant
to admin endpoint /members
to filter for participants in a room
#18040
base: develop
Are you sure you want to change the base?
Add a query param participant
to admin endpoint /members
to filter for participants in a room
#18040
Changes from all commits
0f9a6ba
9ec4d7c
827cb66
b4d5885
c13e2fb
74d95f2
180b784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a query param `participant` to `/members` admin api to filter for room participants. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -358,6 +358,13 @@ The API is: | |||||||
GET /_synapse/admin/v1/rooms/<room_id>/members | ||||||||
``` | ||||||||
|
||||||||
**Parameters** | ||||||||
|
||||||||
The following query parameters are available: | ||||||||
|
||||||||
* `participant` - Optional. If provided and set to true, only returns currently joined members who have | ||||||||
also posted to the room. Defaults to false. | ||||||||
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.
Suggested change
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. Do you want to track |
||||||||
|
||||||||
A response body like the following is returned: | ||||||||
|
||||||||
```json | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1606,6 +1606,34 @@ def _get_rooms_for_user_by_join_date_txn( | |
from_ts, | ||
) | ||
|
||
async def get_participants_in_room(self, room_id: str) -> Sequence[str]: | ||
""" | ||
Return a list of all currently joined room members who have posted | ||
in the given room. | ||
|
||
Args: | ||
room_id: room ID of the room to search in | ||
""" | ||
|
||
def _get_participants_in_room_txn( | ||
txn: LoggingTransaction, room_id: str | ||
) -> List[str]: | ||
sql = """ | ||
SELECT DISTINCT c.state_key | ||
FROM current_state_events AS c | ||
INNER JOIN events AS e USING(room_id) | ||
WHERE room_id = ? | ||
AND c.membership = 'join' | ||
AND e.type = 'm.room.message' | ||
AND c.state_key = e.sender | ||
Comment on lines
+1622
to
+1628
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. Unfortunately, this query is currently quite slow. Testing this on matrix.org with Matrix HQ as the room, this query took about 50 seconds to run. It would be much slower on typical homeserver hardware. Postgres' Rather than iterating through SELECT DISTINCT rm.user_id
FROM room_memberships AS rm
INNER JOIN events AS e USING(room_id)
WHERE room_id = ?
AND rm.membership = 'join'
AND e.type = 'm.room.message'
AND rm.user_id = e.sender; This cuts our cost down a little bit, but still not much; The majority of the cost comes from scanning
One possible way we could move forward is to add another column to |
||
""" | ||
txn.execute(sql, (room_id,)) | ||
return [r[0] for r in txn] | ||
|
||
return await self.db_pool.runInteraction( | ||
"_get_participants_in_room_txn", _get_participants_in_room_txn, room_id | ||
) | ||
|
||
|
||
class RoomMemberBackgroundUpdateStore(SQLBaseStore): | ||
def __init__( | ||
|
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.