diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 68472a79..f3856491 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -12,7 +12,7 @@ #服务器的接入IP。给客户端提供是${server.ip}和${http_port}。 #客户端会从${http_port}端口获取到长链接端口。这个地址一定要改成客户端可以访问到的IP地址 #(如果您部署云服务器上或者具有独立公网出口的服务器上,请改为对应的公网IP;如果您部署在在内网环境下,在内网使用,这个地方改成内网地址) -server.ip 192.168.3.124 +server.ip 192.168.1.81 ##原生客户端长链接端口 port 1883 @@ -320,6 +320,9 @@ push.ios.server.address http://localhost:8085/ios/push ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! #message.mentionmsg.forward.url http://localhost:8888/im_event/message +##撤回消息转发地址,当用户撤回消息会回调此地址。 +##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! +#message.recallmsg.forward.url http://localhost:8888/im_event/recall_message ##设备信息转发地址 ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 89773044..8820904b 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -129,7 +129,7 @@ public final class BrokerConstants { public static final String MESSAGE_Forward_Types = "message.forward.types"; public static final String MESSAGE_Forward_Exclude_Types = "message.forward.exclude_types"; public static final String MESSAGE_MentionMsg_Forward_Url = "message.mentionmsg.forward.url"; - + public static final String MESSAGE_RecallMsg_Forward_Url = "message.recallmsg.forward.url"; public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint"; public static final String SERVER_MULTI_PC_ENDPOINT = "server.multi_pc_endpoint"; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index bf826d5d..74b084e9 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -174,6 +174,7 @@ public class MemoryMessagesStore implements IMessagesStore { private int mGroupForbiddenClientOperation; private int mSyncDataPartSize = 0; private boolean keepDisplayNameWhenDestroyUser = true; + private String mRecallForwardUrl = null; private boolean mForwardMessageWithClientInfo = false; private boolean mRobotCallbackWithClientInfo = false; @@ -518,7 +519,11 @@ public class MemoryMessagesStore implements IMessagesStore { } catch (Exception e) { } + try { + mRecallForwardUrl = server.getConfig().getProperty(BrokerConstants.MESSAGE_RecallMsg_Forward_Url); + } catch (Exception e) { + } } private void printMissConfigLog(String config, String defaultValue) { @@ -2222,6 +2227,19 @@ public class MemoryMessagesStore implements IMessagesStore { return ErrorCode.ERROR_CODE_SUCCESS; } + if(!StringUtil.isNullOrEmpty(mRecallForwardUrl)) { + OutputRecallMessageData event = new OutputRecallMessageData(OutputMessageData.fromProtoMessage(message, null), operatorId, System.currentTimeMillis(), isAdmin); + m_Server.getCallbackScheduler().execute(() -> { + try { + HttpUtils.httpJsonPost(mRecallForwardUrl, GsonUtil.gson.toJson(event), HttpUtils.HttpPostType.POST_TYPE_Forward_Recall_Callback); + } catch (Exception e) { + e.printStackTrace(); + Utility.printExecption(LOG, e, EVENT_CALLBACK_Exception); + } + }); + } + + JSONObject json = new JSONObject(); json.put("s", message.getFromUser()); json.put("ts", message.getServerTimestamp()); diff --git a/broker/src/main/java/win/liyufan/im/HttpUtils.java b/broker/src/main/java/win/liyufan/im/HttpUtils.java index 0043b1a7..ea81676a 100644 --- a/broker/src/main/java/win/liyufan/im/HttpUtils.java +++ b/broker/src/main/java/win/liyufan/im/HttpUtils.java @@ -50,7 +50,8 @@ public class HttpUtils { POST_TYPE_Channel_Message_Callback, POST_TYPE_Forward_Message_Callback, POST_TYPE_User_Online_Event_Callback, - POST_TYPE_Server_Exception_Callback; + POST_TYPE_Server_Exception_Callback, + POST_TYPE_Forward_Recall_Callback; } public static void httpJsonPost(String url, String jsonStr, HttpPostType postType) { diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputRecallMessageData.java b/common/src/main/java/cn/wildfirechat/pojos/OutputRecallMessageData.java new file mode 100644 index 00000000..033b8620 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputRecallMessageData.java @@ -0,0 +1,62 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +import cn.wildfirechat.proto.WFCMessage; + +import java.util.List; + +public class OutputRecallMessageData { + private OutputMessageData message; + private String userId; + private long timestamp; + private boolean isAdmin; + + public OutputRecallMessageData() { + } + + public OutputRecallMessageData(OutputMessageData message, String userId, long timestamp, boolean isAdmin) { + this.message = message; + this.userId = userId; + this.timestamp = timestamp; + this.isAdmin = isAdmin; + } + + public OutputMessageData getMessage() { + return message; + } + + public void setMessage(OutputMessageData message) { + this.message = message; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public boolean isAdmin() { + return isAdmin; + } + + public void setAdmin(boolean admin) { + isAdmin = admin; + } +} diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index de278628..a1cc26cf 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -318,6 +318,10 @@ push.ios.server.address http://localhost:8085/ios/push ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! #message.mentionmsg.forward.url http://localhost:8888/im_event/message +##撤回消息转发地址,当用户撤回消息会回调此地址。 +##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! +#message.recallmsg.forward.url http://localhost:8888/im_event/recall_message + ##设备信息转发地址 ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! #things_message.forward.url http://localhost:8087/im_event/things/message