-
Notifications
You must be signed in to change notification settings - Fork 187
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
Unify the way we decide whether a room is a DM or a group room #3100
Changes from 7 commits
e40884c
c610aa3
5266c32
e103163
84e1c66
c1e23f9
6f3deb0
c583311
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,38 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.libraries.matrix.api.room | ||
|
||
/** | ||
* Returns whether the room with the provided info is a DM. | ||
* A DM is a room with at most 2 active members (one of them may have left). | ||
* | ||
* @param isDirect true if the room is direct | ||
* @param activeMembersCount the number of active members in the room (joined or invited) | ||
*/ | ||
fun isDm(isDirect: Boolean, activeMembersCount: Int): Boolean { | ||
return isDirect && activeMembersCount <= 2 | ||
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. Sadly we cannot rely on the number of activeMembersCount since we can have bot like We will have to find a solution to manage such rooms. But I agree that this is not new with this PR, so we may handle this later, and so this is not a blocker. 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. Yeah, we should make explicit changes in the SDK to support bots in DMs. |
||
} | ||
|
||
/** | ||
* Returns whether the [MatrixRoom] is a DM. | ||
*/ | ||
val MatrixRoom.isDm get() = isDm(isDirect, activeMemberCount.toInt()) | ||
|
||
/** | ||
* Returns whether the [MatrixRoomInfo] is from a DM. | ||
*/ | ||
val MatrixRoomInfo.isDm get() = isDm(isDirect, activeMembersCount.toInt()) | ||
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. Thanks for those handy extensions! |
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.
Maybe rename also the parameter.