mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
Merge branch 'develop' into 'feature/5365_photos_picker'
# Conflicts: # Config/BWIBuildSettings.swift
This commit is contained in:
@@ -713,4 +713,6 @@ class BWIBuildSettings: NSObject {
|
||||
// MARK: New photos picker API
|
||||
var useNewPhotosPickerAPI = true
|
||||
|
||||
// MARK: Contacts List
|
||||
var showContactIdentifierInDetailRow = true
|
||||
}
|
||||
|
||||
2
Podfile
2
Podfile
@@ -43,7 +43,7 @@ when String # specific MatrixSDK released version
|
||||
$matrixSDKVersionSpec = $matrixSDKVersion
|
||||
end
|
||||
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v2.15.0-RC02' }
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v2.15.0-RC03' }
|
||||
|
||||
# Method to import the MatrixSDK
|
||||
def import_MatrixSDK
|
||||
|
||||
@@ -120,13 +120,12 @@
|
||||
self.federationImageView.hidden = YES;
|
||||
}
|
||||
}
|
||||
else if (room.isRoomFederated)
|
||||
{
|
||||
self.federationImageView.hidden = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImageView.hidden = YES;
|
||||
[room getFederationStatusWithCompletion:^(BOOL isFederated) {
|
||||
self.federationImageView.hidden = !isFederated;
|
||||
}];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +594,11 @@
|
||||
[contactCell render:contact];
|
||||
|
||||
contactCell.selectionStyle = UITableViewCellSelectionStyleDefault;
|
||||
contactCell.showMatrixIdInDisplayName = showMatrixIdInDisplayName;
|
||||
if([BWIBuildSettings.shared showContactIdentifierInDetailRow]) {
|
||||
contactCell.showMatrixIdInDisplayName = false;
|
||||
} else {
|
||||
contactCell.showMatrixIdInDisplayName = showMatrixIdInDisplayName;
|
||||
}
|
||||
|
||||
// The search displays contacts to invite.
|
||||
if (indexPath.section == filteredLocalContactsSection || indexPath.section == filteredMatrixContactsSection)
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
|
||||
[self refreshContactPresence];
|
||||
[self refreshContactBadgeImage];
|
||||
[self refreshLocalContactInformation];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -323,22 +324,31 @@
|
||||
{
|
||||
// Display the first contact method in sub label.
|
||||
NSString *subLabelText = nil;
|
||||
if (contact.emailAddresses.count)
|
||||
{
|
||||
MXKEmail* email = contact.emailAddresses.firstObject;
|
||||
subLabelText = email.emailAddress;
|
||||
}
|
||||
else if (contact.phoneNumbers.count)
|
||||
{
|
||||
MXKPhoneNumber *phoneNumber = contact.phoneNumbers.firstObject;
|
||||
|
||||
if (phoneNumber.nbPhoneNumber)
|
||||
if(![BWIBuildSettings.shared showContactIdentifierInDetailRow]) {
|
||||
if (contact.emailAddresses.count)
|
||||
{
|
||||
subLabelText = [[NBPhoneNumberUtil sharedInstance] format:phoneNumber.nbPhoneNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL error:nil];
|
||||
MXKEmail* email = contact.emailAddresses.firstObject;
|
||||
subLabelText = email.emailAddress;
|
||||
}
|
||||
else
|
||||
else if (contact.phoneNumbers.count)
|
||||
{
|
||||
subLabelText = phoneNumber.textNumber;
|
||||
MXKPhoneNumber *phoneNumber = contact.phoneNumbers.firstObject;
|
||||
|
||||
if (phoneNumber.nbPhoneNumber)
|
||||
{
|
||||
subLabelText = [[NBPhoneNumberUtil sharedInstance] format:phoneNumber.nbPhoneNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
subLabelText = phoneNumber.textNumber;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NSArray *identifiers = contact.matrixIdentifiers;
|
||||
if (identifiers.count)
|
||||
{
|
||||
NSString *userId = identifiers.firstObject;
|
||||
subLabelText = userId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -15,7 +13,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="74"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="L2L-l5-wPx" id="aXz-IR-jj5">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="73.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="74"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RX5-eD-c3c" userLabel="member avatar" customClass="MXKImageView">
|
||||
@@ -31,6 +29,7 @@
|
||||
<rect key="frame" x="41" y="43" width="16" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="16" id="Rcc-M1-2hb"/>
|
||||
<constraint firstAttribute="width" secondItem="Wg7-no-cax" secondAttribute="height" multiplier="1:1" id="sZo-F2-fpL"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Display name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lg1-xQ-AGn" userLabel="member display name">
|
||||
@@ -48,9 +47,9 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="info label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dQt-mN-T6b">
|
||||
<rect key="frame" x="69" y="39" width="531" height="19.5"/>
|
||||
<rect key="frame" x="69" y="39" width="531" height="20"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="ContactInformationLabel"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
|
||||
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -74,7 +73,6 @@
|
||||
<constraint firstItem="RX5-eD-c3c" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="15" id="mga-fG-I0L"/>
|
||||
<constraint firstItem="Ogo-Qt-u2C" firstAttribute="leading" secondItem="1nR-ck-5Xd" secondAttribute="trailing" id="nbn-Je-HEE"/>
|
||||
<constraint firstItem="Wg7-no-cax" firstAttribute="bottom" secondItem="RX5-eD-c3c" secondAttribute="bottom" constant="2" id="pck-mZ-FjJ"/>
|
||||
<constraint firstItem="Wg7-no-cax" firstAttribute="width" secondItem="Wg7-no-cax" secondAttribute="height" multiplier="1:1" id="sZo-F2-fpL"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dQt-mN-T6b" secondAttribute="trailing" id="t2m-pb-5zd"/>
|
||||
<constraint firstItem="Lg1-xQ-AGn" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="14" id="tY3-6V-A3B"/>
|
||||
<constraint firstItem="1nR-ck-5Xd" firstAttribute="leading" secondItem="Lg1-xQ-AGn" secondAttribute="trailing" constant="5" id="tat-Fj-BSw"/>
|
||||
|
||||
@@ -143,15 +143,7 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
}
|
||||
|
||||
func pinUnlocked() {
|
||||
checkMaintenanceStatus()
|
||||
enableMaintenanceTimer(true)
|
||||
|
||||
self.bwiCheckForMatomoPromt()
|
||||
BWIAnalytics.sharedTracker.readUserConfig()
|
||||
|
||||
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
|
||||
self.bwiCheckForPersonalNotesRoom()
|
||||
}
|
||||
onBWIAppStart()
|
||||
}
|
||||
|
||||
func bwiOnUnlockedByPin() {
|
||||
@@ -765,6 +757,21 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
maintenanceTimer = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(checkMaintenanceStatus), userInfo: nil, repeats: true)
|
||||
}
|
||||
}
|
||||
|
||||
private func onBWIAppStart() {
|
||||
checkMaintenanceStatus()
|
||||
enableMaintenanceTimer(true)
|
||||
|
||||
self.bwiCheckForMatomoPromt()
|
||||
BWIAnalytics.sharedTracker.readUserConfig()
|
||||
|
||||
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
|
||||
self.bwiCheckForPersonalNotesRoom()
|
||||
}
|
||||
|
||||
// bwi #4478: refresh wellknown a bit more often
|
||||
self.currentMatrixSession?.refreshHomeserverWellknown(false, success: nil, failure: nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension AllChatsCoordinator: SignOutFlowPresenterDelegate {
|
||||
@@ -788,15 +795,7 @@ extension AllChatsCoordinator: AllChatsViewControllerDelegate {
|
||||
func allChatsViewControllerDidCompleteAuthentication(_ allChatsViewController: AllChatsViewController) {
|
||||
self.delegate?.splitViewMasterCoordinatorDidCompleteAuthentication(self)
|
||||
|
||||
checkMaintenanceStatus()
|
||||
enableMaintenanceTimer(true)
|
||||
|
||||
self.bwiCheckForMatomoPromt()
|
||||
BWIAnalytics.sharedTracker.resetMatomo()
|
||||
|
||||
if BWIBuildSettings.shared.bwiPersonalNotesRoom {
|
||||
self.bwiCheckForPersonalNotesRoom()
|
||||
}
|
||||
onBWIAppStart()
|
||||
}
|
||||
|
||||
func allChatsViewController(_ allChatsViewController: AllChatsViewController, didSelectRoomWithParameters roomNavigationParameters: RoomNavigationParameters, completion: @escaping () -> Void) {
|
||||
|
||||
@@ -657,7 +657,8 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
// The targeted member display name (if any) is available in content
|
||||
if (isEventSenderMyUser)
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomInviteByYou:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomInviteByYou:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
else if ([targetDisplayName isEqualToString:mxSession.myUserId])
|
||||
{
|
||||
@@ -670,7 +671,8 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
targetDisplayName = contentDisplayname;
|
||||
}
|
||||
|
||||
displayText = [VectorL10n noticeRoomInvite:senderDisplayName :targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomInvite:senderDisplayName :[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -694,8 +696,8 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
{
|
||||
targetDisplayName = contentDisplayname;
|
||||
}
|
||||
|
||||
displayText = [VectorL10n noticeRoomJoin:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomJoin:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -729,7 +731,8 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomReject:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomReject:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -740,7 +743,8 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [BWIL10n noticeRoomLeave:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [BWIL10n noticeRoomLeave:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -751,11 +755,13 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
{
|
||||
if (isEventSenderMyUser)
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomWithdrawByYou:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomWithdrawByYou:[self formattedMemberDisplayname:event isSender:YES]];
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomWithdraw:senderDisplayName :targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomWithdraw:senderDisplayName :[self formattedMemberDisplayname:event isSender:YES]];
|
||||
}
|
||||
if (event.content[@"reason"])
|
||||
{
|
||||
@@ -767,11 +773,13 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
{
|
||||
if (isEventSenderMyUser)
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomKickByYou:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomKickByYou:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomKick:senderDisplayName :targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomKick:senderDisplayName :[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
|
||||
// add reason if exists
|
||||
@@ -784,11 +792,13 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
{
|
||||
if (isEventSenderMyUser)
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomUnbanByYou:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomUnbanByYou:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomUnban:senderDisplayName :targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomUnban:senderDisplayName :[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -803,11 +813,13 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
|
||||
if (isEventSenderMyUser)
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomBanByYou:targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomBanByYou:[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = [VectorL10n noticeRoomBan:senderDisplayName :targetDisplayName];
|
||||
// bwi #5290 federated user get additional status text
|
||||
displayText = [VectorL10n noticeRoomBan:senderDisplayName :[self formattedMemberDisplayname:event isSender:NO]];
|
||||
}
|
||||
if (event.content[@"reason"])
|
||||
{
|
||||
@@ -2494,4 +2506,54 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
|
||||
return timeString.lowercaseString;
|
||||
}
|
||||
|
||||
#pragma mark - federation
|
||||
|
||||
// bwi #5290 federated user get additional status text
|
||||
- (NSString *)formattedMemberDisplayname:(MXEvent*)event isSender:(BOOL)isSender {
|
||||
NSString *targetDisplayName = event.stateKey;
|
||||
|
||||
NSString *contentDisplayname;
|
||||
MXJSONModelSetString(contentDisplayname, event.content[@"displayname"]);
|
||||
NSString *prevContentDisplayname;
|
||||
MXJSONModelSetString(prevContentDisplayname, event.prevContent[@"displayname"]);
|
||||
|
||||
NSString *userId = isSender ? event.sender : event.stateKey;
|
||||
MXRoom *room = [mxSession roomWithRoomId:event.roomId];
|
||||
|
||||
NSString *displayName;
|
||||
if (contentDisplayname.length) {
|
||||
displayName = [self formattedMemberEvent:contentDisplayname room:room userId:userId];
|
||||
} else if (prevContentDisplayname.length) {
|
||||
displayName = [self formattedMemberEvent:prevContentDisplayname room:room userId:userId];
|
||||
}
|
||||
else {
|
||||
displayName = [self formattedMemberEvent:targetDisplayName room:room userId:userId];
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
// bwi #5290 federated user get additional status text
|
||||
- (NSString *)formattedMemberEvent:(NSString *)displayName room:(MXRoom *)room userId:(NSString *)userId {
|
||||
|
||||
if ( BWIBuildSettings.shared.isFederationEnabled && [room isRoomMemberFederated:userId]) {
|
||||
NSArray *memberUserIdComponents = [userId componentsSeparatedByString:@":"];
|
||||
|
||||
if (memberUserIdComponents.count == 2) {
|
||||
NSString *component = [memberUserIdComponents lastObject];
|
||||
|
||||
// remove subdomains
|
||||
NSArray *domainComponents = [userId componentsSeparatedByString:@"."];
|
||||
|
||||
if (domainComponents.count >= 2) {
|
||||
return [NSString stringWithFormat:@"%@ (%@.%@)", displayName, domainComponents[domainComponents.count-2], domainComponents[domainComponents.count-1]];
|
||||
} else {
|
||||
return [NSString stringWithFormat:@"%@ (%@)", displayName, component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -318,23 +318,30 @@ extension ContactsPickerViewModel: ContactsTableViewControllerDelegate {
|
||||
if let identifiere = identifieres.first as? String {
|
||||
// Check if user is federated
|
||||
if room.isRoomMemberFederated(identifiere) {
|
||||
// Get current serverACL settings for room
|
||||
room.getCurrentRoomServerACLSettings { serverACL in
|
||||
if let serverACL = serverACL {
|
||||
if serverACL.elementsEqual("*") {
|
||||
// Federation is active
|
||||
canInvite = true
|
||||
} else {
|
||||
// Federation is deactivated
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
// Check if room federation flag "isFederated" is true
|
||||
room.getFederatedFlag { isFederated in
|
||||
if isFederated {
|
||||
// Get current serverACL settings for room
|
||||
self.room.getCurrentRoomServerACLSettings { serverACL in
|
||||
if let serverACL = serverACL {
|
||||
if serverACL.elementsEqual("*") {
|
||||
// Federation is active
|
||||
canInvite = true
|
||||
} else {
|
||||
// Federation is deactivated
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
} else {
|
||||
// ServerACL not configured
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptServerAclForRoomNotConfiguredText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// ServerACL not configured
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptServerAclForRoomNotConfiguredText, actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
// Federation is deactivated
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -44,8 +44,16 @@ final class RoomInfoListViewModel: NSObject, RoomInfoListViewModelType {
|
||||
let directUserPresence = session.user(withUserId: room.directUserId)?.presence ?? .unknown
|
||||
|
||||
// bwi: 5216 - federation
|
||||
let isFederated = isFederationEnabled(room: room)
|
||||
|
||||
var isFederated = true
|
||||
|
||||
let group = DispatchGroup()
|
||||
group.enter()
|
||||
self.isFederationEnabled(room: self.room) { federationStatus in
|
||||
isFederated = federationStatus
|
||||
group.leave()
|
||||
}
|
||||
group.wait()
|
||||
|
||||
let basicInfoViewData = RoomInfoBasicViewData(avatarUrl: room.summary.avatar,
|
||||
mediaManager: session.mediaManager,
|
||||
roomId: room.roomId,
|
||||
@@ -66,18 +74,19 @@ final class RoomInfoListViewModel: NSObject, RoomInfoListViewModelType {
|
||||
}
|
||||
|
||||
// bwi: 5216 - federation
|
||||
private func isFederationEnabled(room: MXRoom) -> Bool {
|
||||
private func isFederationEnabled(room: MXRoom, completion: ((_ isFederated: Bool) -> Void)?) {
|
||||
guard BWIBuildSettings.shared.isFederationEnabled else {
|
||||
return false
|
||||
completion?(false)
|
||||
return
|
||||
}
|
||||
|
||||
if room.isPersonalNotesRoom() {
|
||||
return false
|
||||
completion?(false)
|
||||
} else {
|
||||
if room.isDirect {
|
||||
return room.isDMFederated()
|
||||
completion?(room.isDMFederated())
|
||||
} else {
|
||||
return room.isRoomFederated()
|
||||
room.getFederationStatus(completion: completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8320,35 +8320,37 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
if (!self.roomDataSource.room.isPersonalNotesRoom)
|
||||
{
|
||||
// Do not show sheet if isFederated room flag is false (default == true)
|
||||
if (self.roomDataSource.room.isRoomFederated)
|
||||
{
|
||||
// Do not show sheet if users power level is lower than admin
|
||||
MXRoomPowerLevels *powerLevels = self.roomDataSource.roomState.powerLevels;
|
||||
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] >= RoomPowerLevelAdmin)
|
||||
[self.roomDataSource.room getFederatedFlagWithCompletion:^(BOOL isFederated) {
|
||||
if (isFederated)
|
||||
{
|
||||
// Show sheet if no serverACL have been configured
|
||||
[self.roomDataSource.room getCurrentRoomServerACLSettingsWithCompletion:^(NSString *serverACL)
|
||||
{
|
||||
if (serverACL == nil) {
|
||||
self.wasFederationDecisionSheetShownBefore = true;
|
||||
RoomFederationDecisionSheet *federationDecisionView = [[RoomFederationDecisionSheet alloc] init];
|
||||
UIImage *roomAvatarImage;
|
||||
MXKImageView *roomAvatarImageView = ((RoomTitleView*)self.titleView).pictureView;
|
||||
if (roomAvatarImageView && roomAvatarImageView.image)
|
||||
{
|
||||
roomAvatarImage = roomAvatarImageView.image;
|
||||
// Do not show sheet if users power level is lower than admin
|
||||
MXRoomPowerLevels *powerLevels = self.roomDataSource.roomState.powerLevels;
|
||||
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] >= RoomPowerLevelAdmin)
|
||||
{
|
||||
// Show sheet if no serverACL have been configured
|
||||
[self.roomDataSource.room getCurrentRoomServerACLSettingsWithCompletion:^(NSString *serverACL)
|
||||
{
|
||||
if (serverACL == nil) {
|
||||
self.wasFederationDecisionSheetShownBefore = true;
|
||||
RoomFederationDecisionSheet *federationDecisionView = [[RoomFederationDecisionSheet alloc] init];
|
||||
UIImage *roomAvatarImage;
|
||||
MXKImageView *roomAvatarImageView = ((RoomTitleView*)self.titleView).pictureView;
|
||||
if (roomAvatarImageView && roomAvatarImageView.image)
|
||||
{
|
||||
roomAvatarImage = roomAvatarImageView.image;
|
||||
}
|
||||
else
|
||||
{
|
||||
roomAvatarImage = [AvatarGenerator generateAvatarForMatrixItem:self.roomDataSource.roomId withDisplayName:self.roomDataSource.room.summary.displayName];
|
||||
}
|
||||
UIViewController *sheetViewController = [federationDecisionView makeViewControllerWithRoom:self.roomDataSource.room roomAvatarImage: roomAvatarImage];
|
||||
sheetViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
[self presentViewController:sheetViewController animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
roomAvatarImage = [AvatarGenerator generateAvatarForMatrixItem:self.roomDataSource.roomId withDisplayName:self.roomDataSource.room.summary.displayName];
|
||||
}
|
||||
UIViewController *sheetViewController = [federationDecisionView makeViewControllerWithRoom:self.roomDataSource.room roomAvatarImage: roomAvatarImage];
|
||||
sheetViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
[self presentViewController:sheetViewController animated:YES completion:nil];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,8 +605,23 @@ BOOL reloadToggleCell = false;
|
||||
[tmpSections addObject:[self sectionForAccessSwitch]];
|
||||
}
|
||||
|
||||
if ( BWIBuildSettings.shared.isFederationEnabled && !mxRoom.isDirect){
|
||||
[tmpSections addObject:[self sectionForFederationSwitch]];
|
||||
if (BWIBuildSettings.shared.isFederationEnabled)
|
||||
{
|
||||
// Do not show federation settings for DMs
|
||||
if (!mxRoom.isDirect)
|
||||
{
|
||||
// Do not show federation settings for personal note room
|
||||
if (!mxRoom.isPersonalNotesRoom)
|
||||
{
|
||||
// Show federation settings if "isFederated" flag is true (default == true)
|
||||
[mxRoom getFederatedFlagWithCompletion:^(BOOL isFederated) {
|
||||
if (isFederated)
|
||||
{
|
||||
[tmpSections addObject:[self sectionForFederationSwitch]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RiotSettings.shared.roomSettingsScreenAllowChangingHistorySettings)
|
||||
@@ -1693,10 +1708,8 @@ BOOL reloadToggleCell = false;
|
||||
NSString *serverACLRule = updatedItemsDict[kRoomSettingsFederationKey];
|
||||
if (serverACLRule)
|
||||
{
|
||||
NSMutableDictionary *content = [[NSMutableDictionary alloc] initWithDictionary:@{
|
||||
@"allow": @[serverACLRule],
|
||||
@"allowIPLiterals" : @false
|
||||
}];
|
||||
|
||||
NSDictionary *content = [mxRoom createServerACLContentWithServerACL:serverACLRule];
|
||||
|
||||
pendingOperation = [mxRoom sendStateEventOfType:kMXEventTypeStringRoomServerACL content:content stateKey:nil success:^(NSString *eventId) {
|
||||
if (weakSelf)
|
||||
|
||||
@@ -146,33 +146,43 @@
|
||||
// bwi: #5226 us12 add federation icons to navigationViewTitle
|
||||
if (self.pillImageView)
|
||||
{
|
||||
if ([self.mxRoom isDirect])
|
||||
if (![self.mxRoom isPersonalNotesRoom])
|
||||
{
|
||||
if ([self.mxRoom isDMFederated])
|
||||
if ([self.mxRoom isDirect])
|
||||
{
|
||||
self.pillImageView.hidden = false;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeAlways;
|
||||
self.displayNameTextField.rightView = [FederationIconHelper.shared getRoomFederationPillViewWithTextView:self.displayNameTextField];
|
||||
if ([self.mxRoom isDMFederated])
|
||||
{
|
||||
self.pillImageView.hidden = false;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeAlways;
|
||||
self.displayNameTextField.rightView = [FederationIconHelper.shared getRoomFederationPillViewWithTextView:self.displayNameTextField];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.pillImageView.hidden = true;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.pillImageView.hidden = true;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
||||
[self.mxRoom getFederationStatusWithCompletion:^(BOOL isFederated) {
|
||||
if (isFederated)
|
||||
{
|
||||
self.pillImageView.hidden = false;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeAlways;
|
||||
self.displayNameTextField.rightView = [FederationIconHelper.shared getRoomFederationPillViewWithTextView:self.displayNameTextField];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.pillImageView.hidden = true;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([self.mxRoom isRoomFederated])
|
||||
{
|
||||
self.pillImageView.hidden = false;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeAlways;
|
||||
self.displayNameTextField.rightView = [FederationIconHelper.shared getRoomFederationPillViewWithTextView:self.displayNameTextField];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.pillImageView.hidden = true;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
||||
}
|
||||
self.pillImageView.hidden = true;
|
||||
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ targets:
|
||||
- path: ../bwi/MatomoAnalytics/DecryptedEvent.swift
|
||||
- path: ../bwi/MatomoAnalytics/E2EEError.swift
|
||||
- path: ../bwi/URLScheme/CustomURLSchemeHelper.swift
|
||||
- path: ../bwi/Federation/MXRoom+Federation.swift
|
||||
- path: ../Riot/Managers/Settings/RiotSettings.swift
|
||||
- path: ../Config/BuildSettings.swift
|
||||
- path: ../Config/BWIBuildSettings.swift
|
||||
|
||||
@@ -236,6 +236,7 @@ class AuthenticationService: NSObject {
|
||||
|
||||
var identityServerURL: URL?
|
||||
|
||||
// FRROT wellknown call for identity server after server selection
|
||||
if let wellKnown = try? await wellKnown(for: homeserverURL) {
|
||||
self.wellknown = wellKnown
|
||||
|
||||
|
||||
@@ -20,37 +20,31 @@ import MatrixSDK
|
||||
|
||||
@objc extension MXRoom {
|
||||
|
||||
func isRoomFederated() -> Bool {
|
||||
var isFederated: Bool = true
|
||||
state { state in
|
||||
// Search for federate flag. If the flag is not found, default value is true
|
||||
if let events = state?.stateEvents(with: .roomCreate) {
|
||||
for event in events {
|
||||
if let federateContentValue = event.wireContent["m.federate"] {
|
||||
isFederated = federateContentValue as? Bool ?? true
|
||||
}
|
||||
}
|
||||
}
|
||||
if isFederated {
|
||||
// Federation status for room, "isFederated" flag + serverACL
|
||||
func getFederationStatus(completion: ((_ isFederated:Bool) -> Void)?) {
|
||||
var federationStatus = true
|
||||
// Get federated flag
|
||||
getFederatedFlag { isFederated in
|
||||
federationStatus = isFederated
|
||||
if federationStatus {
|
||||
// Check Server ACLs
|
||||
if let events = state?.stateEvents(with: .roomServerACL) {
|
||||
let myUserId = self.mxSession.myUser.userId ?? ""
|
||||
let myUserIdComponents = myUserId.components(separatedBy: ":")
|
||||
if let event = events.last {
|
||||
if let allowedServerList = event.wireContent["allow"] as? [String] {
|
||||
if allowedServerList.count == 1 {
|
||||
if allowedServerList[0] != "*" && myUserIdComponents.count == 2 && allowedServerList[0] == myUserIdComponents.last ?? "" {
|
||||
isFederated = false
|
||||
}
|
||||
}
|
||||
self.getCurrentRoomServerACLSettings { serverACL in
|
||||
if let serverACL = serverACL {
|
||||
let myUserId = self.mxSession.myUser.userId ?? ""
|
||||
let myUserIdComponents = myUserId.components(separatedBy: ":")
|
||||
if serverACL != "*" && myUserIdComponents.count == 2 && serverACL == myUserIdComponents.last ?? "" {
|
||||
federationStatus = false
|
||||
}
|
||||
}
|
||||
completion?(federationStatus)
|
||||
}
|
||||
} else {
|
||||
completion?(federationStatus)
|
||||
}
|
||||
}
|
||||
return isFederated
|
||||
}
|
||||
|
||||
|
||||
func isDMFederated() -> Bool {
|
||||
var isFederated: Bool = false
|
||||
// Check if the user is from the same homeserver
|
||||
@@ -81,6 +75,23 @@ import MatrixSDK
|
||||
return isFederated
|
||||
}
|
||||
|
||||
// Get "isFederated" flag for room, default == true
|
||||
func getFederatedFlag(completion: ((_ isFederated: Bool) -> Void)?) {
|
||||
state { state in
|
||||
var isFederated = true
|
||||
// Search for federate flag. If the flag is not found, default value is true
|
||||
if let events = state?.stateEvents(with: .roomCreate) {
|
||||
for event in events {
|
||||
if let federateContentValue = event.wireContent["m.federate"] {
|
||||
isFederated = federateContentValue as? Bool ?? true
|
||||
}
|
||||
}
|
||||
}
|
||||
completion?(isFederated)
|
||||
}
|
||||
}
|
||||
|
||||
// Get serverACL for room
|
||||
func getCurrentRoomServerACLSettings(completion: ((_ serverACL: String?)-> Void)?) {
|
||||
state { state in
|
||||
if let events = state?.stateEvents(with: .roomServerACL) {
|
||||
@@ -96,6 +107,9 @@ import MatrixSDK
|
||||
// No ServerACL settings found
|
||||
completion?(nil)
|
||||
}
|
||||
} else {
|
||||
// No ServerACL settings found
|
||||
completion?(nil)
|
||||
}
|
||||
} else {
|
||||
// No ServerACL settings found
|
||||
@@ -103,4 +117,32 @@ import MatrixSDK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create map for content json with boolean
|
||||
func createServerACL(isFederated: Bool) -> [String:Any] {
|
||||
var serverACL: String = ""
|
||||
if isFederated {
|
||||
serverACL = "*"
|
||||
} else {
|
||||
if let myUserIDComponents = self.mxSession.myUserId?.components(separatedBy: ":")
|
||||
{
|
||||
if myUserIDComponents.count == 2 {
|
||||
serverACL = myUserIDComponents[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return createServerACLContent(serverACL: serverACL)
|
||||
}
|
||||
|
||||
// Create map for content json with serverACL string
|
||||
func createServerACLContent(serverACL: String) -> [String:Any] {
|
||||
var content: [String:Any] = [String:Any]()
|
||||
var serverACLList: [String] = [String]()
|
||||
serverACLList.append(serverACL)
|
||||
content.updateValue(serverACLList, forKey: "allow")
|
||||
content.updateValue(false, forKey: "allow_ip_literals")
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -161,21 +161,7 @@ struct RoomFederationDecisionView: View {
|
||||
|
||||
|
||||
func setServerACL(isFederated: Bool) {
|
||||
var serverACL: [String] = [String]()
|
||||
if isFederated {
|
||||
serverACL.append("*")
|
||||
} else {
|
||||
if let myUserIDComponents = room.mxSession.myUserId?.components(separatedBy: ":")
|
||||
{
|
||||
if myUserIDComponents.count == 2 {
|
||||
serverACL.append(myUserIDComponents[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var content: [String:Any] = [String:Any]()
|
||||
content.updateValue(serverACL, forKey: "allow")
|
||||
content.updateValue(false, forKey: "allowIPLiterals")
|
||||
let content: [String:Any] = room.createServerACL(isFederated: isFederated)
|
||||
isUpdatingServerACLs = true
|
||||
pendingRequest = room.sendStateEvent(MXEventType.roomServerACL, content: content, stateKey: "") { response in
|
||||
isUpdatingServerACLs = false
|
||||
|
||||
Reference in New Issue
Block a user