Skip to content

Commit

Permalink
Check power level before starting live sharing location
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Buquet <nbuquet@buquet-net.com>
  • Loading branch information
Nicolas Buquet committed Jun 24, 2024
1 parent 087f0cc commit b44685c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,16 @@ final class LocationSharingCoordinator: Coordinator, Presentable {

// Check if user can send beacon info state event
private func canShareLiveLocation() -> Bool {
guard let myUserId = parameters.roomDataSource.mxSession.myUserId else {
guard let myUserId = parameters.roomDataSource.mxSession.myUserId,
let roomPowerLevels = parameters.roomDataSource.roomState.powerLevels,
let userPowerLevel = RoomPowerLevel(rawValue: roomPowerLevels.powerLevelOfUser(withUserID: myUserId)) else {
return false
}

let userPowerLevelRawValue = parameters.roomDataSource.roomState.powerLevels.powerLevelOfUser(withUserID: myUserId)

guard let userPowerLevel = RoomPowerLevel(rawValue: userPowerLevelRawValue) else {
return false
}

return userPowerLevel.rawValue >= RoomPowerLevel.moderator.rawValue
// CHeck user power level in room against power level needed to post geolocation state event.
let liveSharingPowerLevel = parameters.roomDataSource.roomState.powerLevels.minimumPowerLevelForSendingStateEvent(.beaconInfo)

Check failure on line 176 in RiotSwiftUI/Modules/LocationSharing/StartLocationSharing/Coordinator/LocationSharingCoordinator.swift

View workflow job for this annotation

GitHub Actions / Tests

'minimumPowerLevelForSendingStateEvent' is inaccessible due to 'internal' protection level

Check failure on line 176 in RiotSwiftUI/Modules/LocationSharing/StartLocationSharing/Coordinator/LocationSharingCoordinator.swift

View workflow job for this annotation

GitHub Actions / Tests

'minimumPowerLevelForSendingStateEvent' is inaccessible due to 'internal' protection level

return userPowerLevel.rawValue >= liveSharingPowerLevel
}

private func showLabFlagPromotionIfNeeded(completion: @escaping ((Bool) -> Void)) {
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7808.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check power level before starting live sharing location

0 comments on commit b44685c

Please sign in to comment.