fix: reply from a push is sent to the correct destination (#5152)

* add tmid to msg json body

* add tmid to ios reply

* remove unused param
This commit is contained in:
Gleidson Daniel Silva 2023-08-09 15:18:50 -03:00 committed by GitHub
parent c9f4ca1197
commit 7affa268fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 4 deletions

View File

@ -34,6 +34,8 @@ public class Ejson {
String senderName; String senderName;
String msg; String msg;
String tmid;
private MMKV mmkv; private MMKV mmkv;
private String TOKEN_KEY = "reactnativemeteor_usertoken-"; private String TOKEN_KEY = "reactnativemeteor_usertoken-";

View File

@ -123,7 +123,9 @@ public class ReplyBroadcast extends BroadcastReceiver {
if (msg != message) { if (msg != message) {
msgMap.put("t", "e2e"); msgMap.put("t", "e2e");
} }
msgMap.put("tmid", null); if(ejson.tmid != null) {
msgMap.put("tmid", ejson.tmid);
}
Map m = new HashMap(); Map m = new HashMap();
m.put("message", msgMap); m.put("message", msgMap);

View File

@ -34,7 +34,7 @@ class ReplyNotification: RNNotificationEventHandler {
if let msg = (response as? UNTextInputNotificationResponse)?.userText { if let msg = (response as? UNTextInputNotificationResponse)?.userText {
let rocketchat = RocketChat.instanceForServer(server: payload.host.removeTrailingSlash()) let rocketchat = RocketChat.instanceForServer(server: payload.host.removeTrailingSlash())
let backgroundTask = UIApplication.shared.beginBackgroundTask(expirationHandler: nil) let backgroundTask = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
rocketchat.sendMessage(rid: rid, message: msg) { response in rocketchat.sendMessage(rid: rid, message: msg, threadIdentifier: payload.tmid) { response in
guard let response = response, response.success else { guard let response = response, response.success else {
let content = UNMutableNotificationContent() let content = UNMutableNotificationContent()
content.body = "Failed to reply message." content.body = "Failed to reply message."

View File

@ -19,4 +19,5 @@ struct Payload: Codable {
let messageType: MessageType? let messageType: MessageType?
let msg: String? let msg: String?
let senderName: String? let senderName: String?
let tmid: String?
} }

View File

@ -52,7 +52,7 @@ final class RocketChat {
} }
} }
func sendMessage(rid: String, message: String, completion: @escaping((MessageResponse?) -> Void)) { func sendMessage(rid: String, message: String, threadIdentifier: String?, completion: @escaping((MessageResponse?) -> Void)) {
let id = String.random(length: 17) let id = String.random(length: 17)
var msg = message var msg = message
@ -61,7 +61,7 @@ final class RocketChat {
msg = encryptMessage(rid: rid, id: id, message: message) msg = encryptMessage(rid: rid, id: id, message: message)
} }
api?.fetch(request: SendMessageRequest(id: id, roomId: rid, text: msg, messageType: encrypted ? .e2e : nil )) { response in api?.fetch(request: SendMessageRequest(id: id, roomId: rid, text: msg, threadIdentifier: threadIdentifier, messageType: encrypted ? .e2e : nil )) { response in
switch response { switch response {
case .resource(let response): case .resource(let response):
completion(response) completion(response)