添加撤回消息回调

This commit is contained in:
heavyrian2012
2023-03-24 15:55:11 +08:00
parent 68abeed907
commit c29370ac61
6 changed files with 91 additions and 3 deletions
@@ -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";
@@ -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());
@@ -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) {