Private
Public Access
1
0

Attachment uploading support

This commit is contained in:
James Magahern
2019-01-16 14:17:31 -08:00
parent 6aaa2ff5b3
commit 90775ebbba
4 changed files with 106 additions and 3 deletions

View File

@@ -20,7 +20,7 @@
return @"sendMessage";
}
- (BOOL)_sendMessage:(NSString *)messageBody toChatWithGUID:(NSString *)chatGUID
- (BOOL)_sendMessage:(NSString *)messageBody toChatWithGUID:(NSString *)chatGUID attachmentGUIDs:(NSArray<NSString *> *)guids
{
__block BOOL result = YES;
@@ -32,7 +32,16 @@
IMHandle *senderHandle = [iMessageAccount loginIMHandle];
NSAttributedString *replyAttrString = [[NSAttributedString alloc] initWithString:messageBody];
IMMessage *reply = [IMMessage fromMeIMHandle:senderHandle withText:replyAttrString fileTransferGUIDs:@[] flags:kIMMessageFinished];
NSAttributedString *attrStringWithFileTransfers = IMCreateSuperFormatStringWithAppendedFileTransfers(replyAttrString, guids);
IMMessage *reply = [IMMessage fromMeIMHandle:senderHandle
withText:attrStringWithFileTransfers
fileTransferGUIDs:guids
flags:(kIMMessageFinished | kIMMessageIsFromMe)];
for (NSString *guid in [reply fileTransferGUIDs]) {
[[IMFileTransferCenter sharedInstance] assignTransfer:guid toHandle:chat.recipient];
}
if (!chat) {
NSLog(@"Chat does not exist: %@", chatGUID);
@@ -63,7 +72,12 @@
return;
}
BOOL result = [self _sendMessage:messageBody toChatWithGUID:guid];
NSArray *transferGUIDs = [args objectForKey:@"fileTransferGUIDs"];
if (!transferGUIDs) {
transferGUIDs = @[];
}
BOOL result = [self _sendMessage:messageBody toChatWithGUID:guid attachmentGUIDs:transferGUIDs];
if (result) {
response = [[HTTPErrorResponse alloc] initWithErrorCode:200];
}