Skip to content

Commit

Permalink
Attributedbody changes to support server
Browse files Browse the repository at this point in the history
  • Loading branch information
tneotia committed Mar 27, 2023
1 parent 7ec2227 commit 9dfa316
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
8 changes: 4 additions & 4 deletions MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 16;
CURRENT_PROJECT_VERSION = 17;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = S6D73TBQQU;
DSTROOT = /;
Expand All @@ -677,7 +677,7 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 0.0.14;
MARKETING_VERSION = 0.0.15;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.bluebubbles.messaging;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -698,7 +698,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 16;
CURRENT_PROJECT_VERSION = 17;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = S6D73TBQQU;
DSTROOT = /;
Expand All @@ -713,7 +713,7 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 0.0.14;
MARKETING_VERSION = 0.0.15;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.bluebubbles.messaging;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
27 changes: 3 additions & 24 deletions MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa
} else if ([event isEqualToString:@"send-multipart"]) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: @""];
NSMutableArray<NSString*> *transfers = [[NSMutableArray alloc] init];
NSUInteger index = 0;
for (NSDictionary *dict in data[@"parts"]) {
NSUInteger index = [dict[@"partIndex"] integerValue];
if (dict[@"filePath"] != [NSNull null] && [dict[@"filePath"] length] != 0) {
NSString *filePath = dict[@"filePath"];
NSURL * fileUrl = [NSURL fileURLWithPath:filePath];
Expand All @@ -458,33 +458,13 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa
[attributedString appendAttributedString:attachmentStr];
} else {
if (dict[@"mention"] != [NSNull null] && [dict[@"mention"] length] != 0) {
NSMutableAttributedString *beforeStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange(0, [[dict[@"range"] firstObject] integerValue])]];
[beforeStr addAttributes:@{
@"__kIMBaseWritingDirectionAttributeName": @"-1",
@"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index],
} range:NSMakeRange(0, [[beforeStr string] length])];
NSMutableAttributedString *mentionStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange([[dict[@"range"] firstObject] integerValue], [[dict[@"range"] lastObject] integerValue])]];
NSMutableAttributedString *mentionStr = [[NSMutableAttributedString alloc] initWithString: dict[@"text"]];
[mentionStr addAttributes:@{
@"__kIMBaseWritingDirectionAttributeName": @"-1",
@"__kIMMentionConfirmedMention": dict[@"mention"],
@"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index],
} range:NSMakeRange(0, [[mentionStr string] length])];
NSUInteger begin = [[dict[@"range"] firstObject] integerValue] + [[dict[@"range"] lastObject] integerValue];
NSUInteger end = [dict[@"text"] length] - begin;
NSMutableAttributedString *afterStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange(begin, end)]];
[afterStr addAttributes:@{
@"__kIMBaseWritingDirectionAttributeName": @"-1",
@"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index],
} range:NSMakeRange(0, [[afterStr string] length])];
if ([[beforeStr string] length] != 0) {
[attributedString appendAttributedString:beforeStr];
}
if ([[mentionStr string] length] != 0) {
[attributedString appendAttributedString:mentionStr];
}
if ([[afterStr string] length] != 0) {
[attributedString appendAttributedString:afterStr];
}
[attributedString appendAttributedString:mentionStr];
} else {
NSMutableAttributedString *messageStr = [[NSMutableAttributedString alloc] initWithString: dict[@"text"]];
[messageStr addAttributes:@{
Expand All @@ -494,7 +474,6 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa
[attributedString appendAttributedString:messageStr];
}
}
index++;
}
[BlueBubblesHelper sendMessage:(data) transfers:[transfers copy] attributedString:attributedString transaction:(transaction)];
// If the server tells us to get the vetted aliases
Expand Down

0 comments on commit 9dfa316

Please sign in to comment.