Skip to content

Commit

Permalink
Merge pull request #534 from matrix-org/riot_1911 Replies: Implement …
Browse files Browse the repository at this point in the history
…sending
  • Loading branch information
SBiOSoftWhare authored and manuroe committed Jul 24, 2018
2 parents 781e64f + dc7db23 commit 0871d68
Show file tree
Hide file tree
Showing 13 changed files with 861 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changes in Matrix iOS SDK in 0.11.0 ()

Improvements:
* MXRestClient: Add Matrix filter API.
* MXRoom: Add send reply with text message (vector-im/riot-ios#1911).
* MXRoom: Add an asynchronous methods for liveTimeline, state and members.
* MXRoom: Add methods to manage the room liveTimeline listeners synchronously.
* MXRoomState: Add a membersCount property to store members stats independently from MXRoomMember objects.
Expand Down
12 changes: 12 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
9274AFE81EE580240009BEB6 /* MXCallKitAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9274AFE61EE580240009BEB6 /* MXCallKitAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
9274AFE91EE580240009BEB6 /* MXCallKitAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9274AFE71EE580240009BEB6 /* MXCallKitAdapter.m */; };
A23A8594855481FEFA0E9A22 /* libPods-MatrixSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1674C6FF8BBF074E7F76059 /* libPods-MatrixSDK.a */; };
B17285792100C8EA0052C51E /* MXSendReplyEventStringsLocalizable.h in Headers */ = {isa = PBXBuildFile; fileRef = B17285782100C88A0052C51E /* MXSendReplyEventStringsLocalizable.h */; settings = {ATTRIBUTES = (Public, ); }; };
B172857C2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.h in Headers */ = {isa = PBXBuildFile; fileRef = B172857A2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.h */; };
B172857D2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.m in Sources */ = {isa = PBXBuildFile; fileRef = B172857B2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.m */; };
C60165381E3AA57900B92CFA /* MXSDKOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = F0C34CB91C18C80000C36F09 /* MXSDKOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
C602B58C1F2268F700B67D87 /* MXRoom.swift in Sources */ = {isa = PBXBuildFile; fileRef = C602B58B1F2268F700B67D87 /* MXRoom.swift */; };
C602B58E1F22A8D700B67D87 /* MXImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C602B58D1F22A8D700B67D87 /* MXImage.swift */; };
Expand Down Expand Up @@ -504,6 +507,9 @@
92634B811EF2E3C400DB9F60 /* MXCallKitConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallKitConfiguration.m; sourceTree = "<group>"; };
9274AFE61EE580240009BEB6 /* MXCallKitAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCallKitAdapter.h; sourceTree = "<group>"; };
9274AFE71EE580240009BEB6 /* MXCallKitAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallKitAdapter.m; sourceTree = "<group>"; };
B17285782100C88A0052C51E /* MXSendReplyEventStringsLocalizable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXSendReplyEventStringsLocalizable.h; sourceTree = "<group>"; };
B172857A2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXSendReplyEventDefaultStringLocalizations.h; sourceTree = "<group>"; };
B172857B2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXSendReplyEventDefaultStringLocalizations.m; sourceTree = "<group>"; };
B1F1AE550CF4C15B653DDE6E /* Pods-MatrixSDKTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MatrixSDKTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MatrixSDKTests/Pods-MatrixSDKTests.debug.xcconfig"; sourceTree = "<group>"; };
C602B58B1F2268F700B67D87 /* MXRoom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXRoom.swift; sourceTree = "<group>"; };
C602B58D1F22A8D700B67D87 /* MXImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXImage.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -629,6 +635,9 @@
329FB17E1A0B665800A5E88E /* MXUser.m */,
327137251A24D50A00DB6757 /* MXMyUser.h */,
327137261A24D50A00DB6757 /* MXMyUser.m */,
B17285782100C88A0052C51E /* MXSendReplyEventStringsLocalizable.h */,
B172857A2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.h */,
B172857B2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.m */,
);
path = Data;
sourceTree = "<group>";
Expand Down Expand Up @@ -1190,6 +1199,7 @@
32114A851A262CE000FF2EC4 /* MXStore.h in Headers */,
32A151391DAD292400400192 /* MXMegolmEncryption.h in Headers */,
F03EF5041DF01596009DF592 /* MXLRUCache.h in Headers */,
B172857C2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.h in Headers */,
329FB1791A0A74B100A5E88E /* MXTools.h in Headers */,
322691321E5EF77D00966A6E /* MXDeviceListOperation.h in Headers */,
32481A841C03572900782AD3 /* MXRoomAccountData.h in Headers */,
Expand All @@ -1199,6 +1209,7 @@
323F3F9420D3F0C700D26D6A /* MXRoomEventFilter.h in Headers */,
32A9E8251EF4026E0081358A /* MXUIKitBackgroundModeHandler.h in Headers */,
325D1C261DFECE0D0070B8BF /* MXCrypto_Private.h in Headers */,
B17285792100C8EA0052C51E /* MXSendReplyEventStringsLocalizable.h in Headers */,
32A151521DAF8A7200400192 /* MXQueuedEncryption.h in Headers */,
32A30B181FB4813400C8309E /* MXIncomingRoomKeyRequestManager.h in Headers */,
F03EF5081DF071D5009DF592 /* MXEncryptedAttachments.h in Headers */,
Expand Down Expand Up @@ -1458,6 +1469,7 @@
32A1515C1DB525DA00400192 /* NSObject+sortedKeys.m in Sources */,
32618E7C20EFA45B00E1D2EA /* MXRoomMembers.m in Sources */,
F03EF5091DF071D5009DF592 /* MXEncryptedAttachments.m in Sources */,
B172857D2100D4F60052C51E /* MXSendReplyEventDefaultStringLocalizations.m in Sources */,
32FA10CF1FA1C9F700E54233 /* MXOutgoingRoomKeyRequest.m in Sources */,
32322A4C1E575F65005DD155 /* MXAllowedCertificates.m in Sources */,
F03EF5051DF01596009DF592 /* MXLRUCache.m in Sources */,
Expand Down
33 changes: 33 additions & 0 deletions MatrixSDK/Contrib/Swift/Data/MXRoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,39 @@ public extension MXRoom {
return __reportEvent(eventId, score: score, reason: reason, success: currySuccess(completion), failure: curryFailure(completion))
}

/**
Send a reply to an event with text message to the room.
It's only supported to reply to event with 'm.room.message' event type and following message types: 'm.text', 'm.text', 'm.emote', 'm.notice', 'm.image', 'm.file', 'm.video', 'm.audio'.
- parameters:
- eventToReply: The event to reply.
- textMessage: The text to send.
- formattedTextMessage: The optional HTML formatted string of the text to send.
- stringLocalizations: String localizations used when building reply message.
- localEcho: a pointer to an MXEvent object.
When the event type is `MXEventType.roomMessage`, this pointer is set to an actual
MXEvent object containing the local created event which should be used to echo the
message in the messages list until the resulting event comes through the server sync.
For information, the identifier of the created local event has the prefix:
`kMXEventLocalEventIdPrefix`.
You may specify nil for this parameter if you do not want this information.
You may provide your own MXEvent object, in this case only its send state is updated.
When the event type is `kMXEventTypeStringRoomEncrypted`, no local event is created.
- completion: A block object called when the operation completes.
- response: Provides the event id of the event generated on the home server on success
- returns: a `MXHTTPOperation` instance.
*/
@nonobjc @discardableResult func sendReply(to eventToReply: MXEvent, textMessage: String, formattedTextMessage: String?, stringLocalizations: MXSendReplyEventStringsLocalizable?, localEcho: inout MXEvent?, completion: @escaping (_ response: MXResponse<String?>) -> Void) -> MXHTTPOperation {
return __sendReply(to: eventToReply, withTextMessage: textMessage, formattedTextMessage: formattedTextMessage, stringLocalizations: stringLocalizations, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion))
}


// MARK: - Room Tags Operations

Expand Down
35 changes: 34 additions & 1 deletion MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#import "MXEventTimeline.h"
#import "MXEventsEnumerator.h"
#import "MXCryptoConstants.h"
#import "MXSendReplyEventStringsLocalizable.h"

@class MXRoom;
@class MXSession;
Expand Down Expand Up @@ -764,6 +765,39 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidFlushDataNotification;
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;

/**
Indicate if replying to the provided event is supported.
Only event of type 'MXEventTypeRoomMessage' are supported for the moment, and for certain msgtype.
@param eventToReply the event to reply to
@return YES if it is possible to reply to this event
*/
- (BOOL)canReplyToEvent:(MXEvent *)eventToReply;

/**
Send a reply to an event with text message to the room.
It's only supported to reply to event with 'm.room.message' event type and following message types: 'm.text', 'm.text', 'm.emote', 'm.notice', 'm.image', 'm.file', 'm.video', 'm.audio'.
@param eventToReply The event to reply.
@param textMessage the text to send.
@param formattedTextMessage the optional HTML formatted string of the text to send.
@param stringLocalizations string localizations used when building reply message.
@param localEcho a pointer to a MXEvent object (@see sendMessageWithContent: for details).
@param success A block object called when the operation succeeds. It returns
the event id of the event generated on the home server
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)sendReplyToEvent:(MXEvent*)eventToReply
withTextMessage:(NSString*)textMessage
formattedTextMessage:(NSString*)formattedTextMessage
stringLocalizations:(id<MXSendReplyEventStringsLocalizable>)stringLocalizations
localEcho:(MXEvent**)localEcho
success:(void (^)(NSString *eventId))success
failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;


#pragma mark - Events listeners on the live timeline
/**
Expand Down Expand Up @@ -795,7 +829,6 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidFlushDataNotification;
*/
- (void)removeAllListeners;


#pragma mark - Events timeline
/**
Open a new `MXEventTimeline` instance around the passed event.
Expand Down

0 comments on commit 0871d68

Please sign in to comment.