Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replies: Implement sending #534

Merged
merged 18 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d604933
[MXTools] Add method to build permalink to user
SBiOSoftWhare Jul 19, 2018
1c1a950
Create MXSendReplyEventStringsLocalizable protocol. Used to provide s…
SBiOSoftWhare Jul 19, 2018
4972d2d
Create MXSendReplyEventDefaultStringLocalizations that represent defa…
SBiOSoftWhare Jul 19, 2018
04dab3b
[MXRoom] Implement send reply to an event with a text message.
SBiOSoftWhare Jul 19, 2018
c5337bf
[MXRoomTests] Add integration tests for send reply to text message
SBiOSoftWhare Jul 19, 2018
79bf9fe
[MXRoom] Handle `m.relates_to` move from event clear content to encry…
SBiOSoftWhare Jul 20, 2018
b6fe90b
[MXEvent] Handle `m.relates_to` move from event encrypted content to …
SBiOSoftWhare Jul 20, 2018
0fb3355
[MXCryptoTests] Add integration tests for send reply to text message …
SBiOSoftWhare Jul 20, 2018
442ea2a
Add send reply to changes
SBiOSoftWhare Jul 20, 2018
7c2b36d
[MXEvent] Fix `m.relates_to` move from wired content to clear content.
SBiOSoftWhare Jul 23, 2018
8ed848e
[MXRoom] Fix `m.relates_to` move from event clear content to encrypte…
SBiOSoftWhare Jul 23, 2018
05b5ed7
[MXRoom] Add `-canReplyToEvent:` method to check possibility to reply…
SBiOSoftWhare Jul 23, 2018
31c1b5b
[MXCryptoTests] Update integration tests for send reply to text messa…
SBiOSoftWhare Jul 23, 2018
67af7b6
[MXRoom] Add Swift refinement for `sendReplyToEvent` method.
SBiOSoftWhare Jul 23, 2018
48232de
[MXRoom] Fix send reply to image.
SBiOSoftWhare Jul 23, 2018
282fe71
[MXRoom] Fix event id JSON field name used for send reply.
SBiOSoftWhare Jul 23, 2018
13cba47
[MXRoom] Fix boolean typo in `-canReplyToEvent`
SBiOSoftWhare Jul 24, 2018
6d7381d
Update string comparison assertions in send reply tests in MXRoomTest…
SBiOSoftWhare Jul 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Improvements:
* MXRoomSummary: Add a membersCount property to cache MXRoomState one
* MXRoomSummary: Add a membership property to cache MXRoomState one
* MXStore: Add Obj-C annotations.
* MXRoom: Add send reply with text message (vector-im/riot-ios#1911).

Bug fix:

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: 35 additions & 0 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#import "MXEventTimeline.h"
#import "MXEventsEnumerator.h"
#import "MXCryptoConstants.h"
#import "MXSendReplyEventStringsLocalizable.h"

@class MXRoom;
@class MXSession;
Expand Down Expand Up @@ -755,6 +756,40 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidFlushDataNotification;
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 timeline
/**
Open a new `MXEventTimeline` instance around the passed event.
Expand Down
Loading