Skip to content

Commit

Permalink
Merge branch 'ismail/5117_thread_message_actions' into ismail/5092_th…
Browse files Browse the repository at this point in the history
…read_list
  • Loading branch information
ismailgulek committed Nov 29, 2021
2 parents 65335ce + 88ab52c commit 7f53684
Show file tree
Hide file tree
Showing 22 changed files with 192 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/triage-move-labelled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: konradpabjan/move-labeled-or-milestoned-issue@219d384e03fa4b6460cd24f9f37d19eb033a4338
with:
action-token: "${{ secrets.ELEMENT_BOT_TOKEN }}"
project-url: "https://github.com/vector-im/element-android/projects/4"
project-url: "https://github.com/vector-im/element-ios/projects/12"
column-name: "Need info"
label-name: "X-Needs-Info"

Expand Down
2 changes: 1 addition & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ Tap the + to start adding people.";
"room_event_action_share" = "Share";
"room_event_action_forward" = "Forward";
"room_event_action_view_in_room" = "View in room";
"room_event_action_permalink" = "Permalink";
"room_event_action_permalink" = "Copy link to message";
"room_event_action_view_source" = "View Source";
"room_event_action_view_decrypted_source" = "View Decrypted Source";
"room_event_action_report" = "Report content";
Expand Down
2 changes: 1 addition & 1 deletion Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2935,7 +2935,7 @@ public class VectorL10n: NSObject {
public static var roomEventActionMore: String {
return VectorL10n.tr("Vector", "room_event_action_more")
}
/// Permalink
/// Copy link to message
public static var roomEventActionPermalink: String {
return VectorL10n.tr("Vector", "room_event_action_permalink")
}
Expand Down
9 changes: 9 additions & 0 deletions Riot/Managers/PushNotification/PushNotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ - (void)setShouldReceiveVoIPPushes:(BOOL)shouldReceiveVoIPPushes
- (void)configurePushKit
{
MXLogDebug(@"[PushNotificationService] configurePushKit")
NSData* token = [_pushRegistry pushTokenForType:PKPushTypeVoIP];
if (token) {
// If the token is available, store it. This can happen if you sign out and back in.
// i.e We are registered, but we have cleared it from the the store on logout and the
// _pushRegistry lives through signin/signout as PushNotificationService is a singleton
// on app delegate.
_pushNotificationStore.pushKitToken = token;
MXLogDebug(@"[PushNotificationService] configurePushKit: Restored pushKit token")
}

_pushRegistry.delegate = self;
_pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
Expand Down
3 changes: 2 additions & 1 deletion Riot/Model/Room/RoomPreviewData.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/

#import "RoomPreviewData.h"
#import <MatrixSDK-Swift.h>

#import "GeneratedInterface-Swift.h"

@implementation RoomPreviewData

Expand Down
8 changes: 4 additions & 4 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2500,17 +2500,17 @@ - (void)enableCallKit:(BOOL)enable forCallManager:(MXCallManager *)callManager

- (void)checkLocalPrivateKeysInSession:(MXSession*)mxSession
{
id<MXCryptoStore> cryptoStore = mxSession.crypto.store;
MXRecoveryService *recoveryService = mxSession.crypto.recoveryService;
NSUInteger keysCount = 0;
if ([cryptoStore secretWithSecretId:MXSecretId.keyBackup])
if ([recoveryService hasSecretWithSecretId:MXSecretId.keyBackup])
{
keysCount++;
}
if ([cryptoStore secretWithSecretId:MXSecretId.crossSigningUserSigning])
if ([recoveryService hasSecretWithSecretId:MXSecretId.crossSigningUserSigning])
{
keysCount++;
}
if ([cryptoStore secretWithSecretId:MXSecretId.crossSigningSelfSigning])
if ([recoveryService hasSecretWithSecretId:MXSecretId.crossSigningSelfSigning])
{
keysCount++;
}
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Authentication/Views/AuthInputsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#import <MatrixKit/MatrixKit.h>

#import "GeneratedInterface-Swift.h"
@class TermsView;

@interface AuthInputsView : MXKAuthInputsView <MXKCountryPickerViewControllerDelegate>

Expand Down
2 changes: 2 additions & 0 deletions Riot/Modules/Authentication/Views/AuthInputsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#import "RiotNavigationController.h"

#import "GeneratedInterface-Swift.h"

@interface AuthInputsView ()
{
/**
Expand Down
1 change: 0 additions & 1 deletion Riot/Modules/Common/Recents/Model/RecentCellData.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#import "RecentCellData.h"

#import "MXRoom+Riot.h"
#import "MatrixSDK-Swift.h"

#import "GeneratedInterface-Swift.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,18 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol {
}

private func updateDirectFetcher(_ fetcher: MXRoomListDataFetcher, for mode: RecentsDataSourceMode) {
switch mode {
case .home:
fetcher.fetchOptions.filterOptions.notDataTypes = [.invited, .favorited, .lowPriority]
case .people:
fetcher.fetchOptions.filterOptions.notDataTypes = [.lowPriority]
default:
break
var notDataTypes: MXRoomSummaryDataTypes = [.hidden, .conferenceUser, .space]
switch mode {
case .home:
notDataTypes.insert([.invited, .favorited, .lowPriority])
fetcher.fetchOptions.filterOptions.notDataTypes = notDataTypes
case .people:
notDataTypes.insert([.lowPriority])
fetcher.fetchOptions.filterOptions.notDataTypes = notDataTypes
default:
break
}
}
}

private func updateFavoritedFetcher(_ fetcher: MXRoomListDataFetcher, for mode: RecentsDataSourceMode) {
switch mode {
Expand Down
196 changes: 106 additions & 90 deletions Riot/Modules/Communities/Home/GroupHomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ @interface GroupHomeViewController ()

// The options used to load long description html content.
NSDictionary *options;
NSString *sanitisedGroupLongDescription;
NSString *groupLongDescription;

// The current pushed view controller
UIViewController *pushedViewController;
}

@property (nonatomic, readonly) DTHTMLAttributedStringBuilderWillFlushCallback longDescriptionSanitizationCallback;

@end

@implementation GroupHomeViewController
Expand Down Expand Up @@ -75,6 +78,23 @@ - (void)finalizeInit

// Keep visible the status bar by default.
isStatusBarHidden = NO;

// Set up sanitization for the long description
NSArray<NSString *> *allowedHTMLTags = @[
@"font", // custom to matrix for IRC-style font coloring
@"del", // for markdown
@"body", // added internally by DTCoreText
@"h1", @"h2", @"h3", @"h4", @"h5", @"h6", @"blockquote", @"p", @"a", @"ul", @"ol",
@"nl", @"li", @"b", @"i", @"u", @"strong", @"em", @"strike", @"code", @"hr", @"br", @"div",
@"table", @"thead", @"caption", @"tbody", @"tr", @"th", @"td", @"pre",
@"img"
];

MXWeakify(self);
_longDescriptionSanitizationCallback = ^(DTHTMLElement *element) {
MXStrongifyAndReturnIfNil(self);
[element sanitizeWith:allowedHTMLTags bodyFont:self->_groupLongDescription.font imageHandler:[self groupLongDescriptionImageHandler]];
};
}

- (void)viewDidLoad
Expand Down Expand Up @@ -154,15 +174,16 @@ - (void)userInterfaceThemeDidChange
font-size: small; \
}", (unsigned long)bgColor];

// Apply the css style
// Apply the css style with some sanitisation.
options = @{
DTUseiOS6Attributes: @(YES), // Enable it to be able to display the attributed string in a UITextView
DTDefaultFontFamily: _groupLongDescription.font.familyName,
DTDefaultFontName: _groupLongDescription.font.fontName,
DTDefaultFontSize: @(_groupLongDescription.font.pointSize),
DTDefaultTextColor: _groupLongDescription.textColor,
DTDefaultLinkDecoration: @(NO),
DTDefaultStyleSheet: [[DTCSSStylesheet alloc] initWithStyleBlock:defaultCSS]
DTDefaultStyleSheet: [[DTCSSStylesheet alloc] initWithStyleBlock:defaultCSS],
DTWillFlushBlockCallBack: self.longDescriptionSanitizationCallback
};
}

Expand Down Expand Up @@ -489,107 +510,25 @@ - (void)refreshGroupLongDescription
{
if (_group.summary.profile.longDescription.length)
{
// Render this html content in a text view.
NSArray <NSString*>* allowedHTMLTags = @[
@"font", // custom to matrix for IRC-style font coloring
@"del", // for markdown
@"h1", @"h2", @"h3", @"h4", @"h5", @"h6", @"blockquote", @"p", @"a", @"ul", @"ol",
@"nl", @"li", @"b", @"i", @"u", @"strong", @"em", @"strike", @"code", @"hr", @"br", @"div",
@"table", @"thead", @"caption", @"tbody", @"tr", @"th", @"td", @"pre",
@"img"
];

// Do some sanitisation by handling the potential image
MXWeakify(self);
sanitisedGroupLongDescription = [MXKTools sanitiseHTML:_group.summary.profile.longDescription withAllowedHTMLTags:allowedHTMLTags imageHandler:^NSString *(NSString *sourceURL, CGFloat width, CGFloat height) {

MXStrongifyAndReturnValueIfNil(self, nil);
NSString *localSourcePath;

if (width != -1 && height != -1)
{
CGSize size = CGSizeMake(width, height);
// Build the cache path for the a thumbnail of this image.
NSString *cacheFilePath = [MXMediaManager thumbnailCachePathForMatrixContentURI:sourceURL
andType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
toFitViewSize:size
withMethod:MXThumbnailingMethodScale];
// Check whether the provided URL is a valid Matrix Content URI.
if (cacheFilePath)
{
// Download the thumbnail if it is not already stored in the cache.
if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath])
{
MXWeakify(self);
[self.mxSession.mediaManager downloadThumbnailFromMatrixContentURI:sourceURL
withType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
toFitViewSize:size
withMethod:MXThumbnailingMethodScale
success:^(NSString *outputFilePath) {
MXStrongifyAndReturnIfNil(self);
[self refreshGroupLongDescription];
}
failure:nil];
}
else
{
// Update the local path
localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath];
}
}
}
else
{
// Build the cache path for this image.
NSString* cacheFilePath = [MXMediaManager cachePathForMatrixContentURI:sourceURL
andType:nil
inFolder:kMXMediaManagerDefaultCacheFolder];

// Check whether the provided URL is a valid Matrix Content URI.
if (cacheFilePath)
{
// Download the image if it is not already stored in the cache.
if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath])
{
MXWeakify(self);
[self.mxSession.mediaManager downloadMediaFromMatrixContentURI:sourceURL
withType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
success:^(NSString *outputFilePath) {
MXStrongifyAndReturnIfNil(self);
[self refreshGroupLongDescription];
}
failure:nil];
}
else
{
// Update the local path
localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath];
}
}
}
return localSourcePath;

}];
groupLongDescription = _group.summary.profile.longDescription;
}
else
{
sanitisedGroupLongDescription = nil;
groupLongDescription = nil;
}

[self renderGroupLongDescription];
}

- (void)renderGroupLongDescription
{
if (sanitisedGroupLongDescription)
if (groupLongDescription)
{
// Using DTCoreText, which renders static string, helps to avoid code injection attacks
// that could happen with the default HTML renderer of NSAttributedString which is a
// webview.
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:[sanitisedGroupLongDescription dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:NULL];
// The supplied options include a callback to sanitize html tags and load image data.
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:[groupLongDescription dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:NULL];

// Apply additional treatments
NSInteger mxIdsBitMask = (MXKTOOLS_USER_IDENTIFIER_BITWISE | MXKTOOLS_ROOM_IDENTIFIER_BITWISE | MXKTOOLS_ROOM_ALIAS_BITWISE | MXKTOOLS_EVENT_IDENTIFIER_BITWISE | MXKTOOLS_GROUP_IDENTIFIER_BITWISE);
Expand All @@ -605,6 +544,83 @@ - (void)renderGroupLongDescription
}
}

- (NSURL *(^)(NSString *sourceURL, CGFloat width, CGFloat height))groupLongDescriptionImageHandler
{
MXWeakify(self);
return ^NSURL *(NSString *sourceURL, CGFloat width, CGFloat height) {

MXStrongifyAndReturnValueIfNil(self, nil);
NSURL *localSourceURL;

if (width != -1 && height != -1)
{
CGSize size = CGSizeMake(width, height);
// Build the cache path for the a thumbnail of this image.
NSString *cacheFilePath = [MXMediaManager thumbnailCachePathForMatrixContentURI:sourceURL
andType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
toFitViewSize:size
withMethod:MXThumbnailingMethodScale];
// Check whether the provided URL is a valid Matrix Content URI.
if (cacheFilePath)
{
// Download the thumbnail if it is not already stored in the cache.
if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath])
{
MXWeakify(self);
[self.mxSession.mediaManager downloadThumbnailFromMatrixContentURI:sourceURL
withType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
toFitViewSize:size
withMethod:MXThumbnailingMethodScale
success:^(NSString *outputFilePath) {
MXStrongifyAndReturnIfNil(self);
[self refreshGroupLongDescription];
}
failure:nil];
}
else
{
// Update the local url
localSourceURL = [NSURL fileURLWithPath:cacheFilePath];
}
}
}
else
{
// Build the cache path for this image.
NSString* cacheFilePath = [MXMediaManager cachePathForMatrixContentURI:sourceURL
andType:nil
inFolder:kMXMediaManagerDefaultCacheFolder];

// Check whether the provided URL is a valid Matrix Content URI.
if (cacheFilePath)
{
// Download the image if it is not already stored in the cache.
if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath])
{
MXWeakify(self);
[self.mxSession.mediaManager downloadMediaFromMatrixContentURI:sourceURL
withType:nil
inFolder:kMXMediaManagerDefaultCacheFolder
success:^(NSString *outputFilePath) {
MXStrongifyAndReturnIfNil(self);
[self refreshGroupLongDescription];
}
failure:nil];
}
else
{
// Update the local path
localSourceURL = [NSURL fileURLWithPath:cacheFilePath];
}
}
}
return localSourceURL;

};
}

- (void)didSelectRoomId:(NSString*)roomId
{
// Check first if the user already joined this room.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#import "FilesSearchCellData.h"

#import "GeneratedInterface-Swift.h"

@implementation FilesSearchCellData
@synthesize roomId, senderDisplayName;
@synthesize searchResult, title, message, date, shouldShowRoomDisplayName, roomDisplayName, attachment, isAttachmentWithThumbnail, attachmentIcon;
Expand Down
Loading

0 comments on commit 7f53684

Please sign in to comment.