Attachment uploading support
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user