From dece1d7a1c69610ea35dce8c82d181033a779c2d Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Wed, 20 Jul 2022 22:25:46 +0800 Subject: [PATCH] =?UTF-8?q?sdk=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E9=98=85=E8=AF=BB=E6=97=B6=E9=97=B4=E5=92=8C?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=81=E8=BE=BE=E6=97=B6=E9=97=B4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/wildfirechat/common/APIPath.java | 2 + .../cn/wildfirechat/pojos/Conversation.java | 9 +++ .../wildfirechat/pojos}/InputDestroyUser.java | 0 .../pojos/InputGetConvReadTime.java | 58 +++++++++++++++++++ .../cn/wildfirechat/pojos/InputUserId.java | 7 +++ .../wildfirechat/pojos/OutputTimestamp.java | 28 +++++++++ .../main/java/cn/wildfirechat/sdk/Main.java | 14 +++++ .../cn/wildfirechat/sdk/MessageAdmin.java | 12 ++++ 8 files changed, 130 insertions(+) rename common/src/main/java/{cn.wildfirechat.pojos => cn/wildfirechat/pojos}/InputDestroyUser.java (100%) create mode 100755 common/src/main/java/cn/wildfirechat/pojos/InputGetConvReadTime.java create mode 100755 common/src/main/java/cn/wildfirechat/pojos/OutputTimestamp.java diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index ed95c013..cd64000e 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -57,6 +57,8 @@ public interface APIPath { String Msg_Multicast = "/admin/message/multicast"; String Msg_RecallBroadCast = "/admin/message/recall_broadcast"; String Msg_RecallMultiCast = "/admin/message/recall_multicast"; + String Msg_ConvRead = "/admin/message/conv_read"; + String Msg_Delivery = "/admin/message/delivery"; String Create_Group = "/admin/group/create"; String Group_Dismiss = "/admin/group/del"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/Conversation.java b/common/src/main/java/cn/wildfirechat/pojos/Conversation.java index 573a888e..5601d43b 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/Conversation.java +++ b/common/src/main/java/cn/wildfirechat/pojos/Conversation.java @@ -13,6 +13,15 @@ public class Conversation { private String target; private int line; + public Conversation() { + } + + public Conversation(int type, String target, int line) { + this.type = type; + this.target = target; + this.line = line; + } + public int getType() { return type; } diff --git a/common/src/main/java/cn.wildfirechat.pojos/InputDestroyUser.java b/common/src/main/java/cn/wildfirechat/pojos/InputDestroyUser.java similarity index 100% rename from common/src/main/java/cn.wildfirechat.pojos/InputDestroyUser.java rename to common/src/main/java/cn/wildfirechat/pojos/InputDestroyUser.java diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputGetConvReadTime.java b/common/src/main/java/cn/wildfirechat/pojos/InputGetConvReadTime.java new file mode 100755 index 00000000..356cdb12 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputGetConvReadTime.java @@ -0,0 +1,58 @@ +/* + * 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; + +public class InputGetConvReadTime { + private String userId; + private int conversationType; + private String target; + private int line; + + public InputGetConvReadTime() { + } + + public InputGetConvReadTime(String userId, int conversationType, String target, int line) { + this.userId = userId; + this.conversationType = conversationType; + this.target = target; + this.line = line; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public int getConversationType() { + return conversationType; + } + + public void setConversationType(int conversationType) { + this.conversationType = conversationType; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public int getLine() { + return line; + } + + public void setLine(int line) { + this.line = line; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputUserId.java b/common/src/main/java/cn/wildfirechat/pojos/InputUserId.java index 313ee80d..d361cb55 100755 --- a/common/src/main/java/cn/wildfirechat/pojos/InputUserId.java +++ b/common/src/main/java/cn/wildfirechat/pojos/InputUserId.java @@ -11,6 +11,13 @@ package cn.wildfirechat.pojos; public class InputUserId { private String userId; + public InputUserId() { + } + + public InputUserId(String userId) { + this.userId = userId; + } + public String getUserId() { return userId; } diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputTimestamp.java b/common/src/main/java/cn/wildfirechat/pojos/OutputTimestamp.java new file mode 100755 index 00000000..c65101da --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputTimestamp.java @@ -0,0 +1,28 @@ +/* + * 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; + +public class OutputTimestamp { + private long timestamp; + + public OutputTimestamp() { + } + + public OutputTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 14c2edc8..1ea6dad8 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -750,6 +750,20 @@ public class Main { } else { System.out.println("failure"); } + + IMResult timestampResult = MessageAdmin.getConversationReadTimestamp("57gqmws2k", new Conversation(0, "admin", 0)); + if(timestampResult != null && timestampResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("Get conversation read time success"); + } else { + System.out.println("Get conversation read time failure"); + } + + timestampResult = MessageAdmin.getMessageDelivery("57gqmws2k"); + if(timestampResult != null && timestampResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("Get message delivery success"); + } else { + System.out.println("Get message delivery failure"); + } } List multicastReceivers = Arrays.asList("user2", "user3", "user4"); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/MessageAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/MessageAdmin.java index 6b27d9ef..d189cc0c 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/MessageAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/MessageAdmin.java @@ -103,4 +103,16 @@ public class MessageAdmin { messageData.setPayload(payload); return AdminHttpUtils.httpJsonPost(path, messageData, MultiMessageResult.class); } + + public static IMResult getConversationReadTimestamp(String userId, Conversation conversation) throws Exception { + String path = APIPath.Msg_ConvRead; + InputGetConvReadTime input = new InputGetConvReadTime(userId, conversation.getType(), conversation.getTarget(), conversation.getLine()); + return AdminHttpUtils.httpJsonPost(path, input, OutputTimestamp.class); + } + + public static IMResult getMessageDelivery(String userId) throws Exception { + String path = APIPath.Msg_Delivery; + InputUserId input = new InputUserId(userId); + return AdminHttpUtils.httpJsonPost(path, input, OutputTimestamp.class); + } }