diff --git a/Realtime/Conversation/LCIMConversation.cs b/Realtime/Conversation/LCIMConversation.cs index 26c4f3e..8f19470 100644 --- a/Realtime/Conversation/LCIMConversation.cs +++ b/Realtime/Conversation/LCIMConversation.cs @@ -61,10 +61,28 @@ namespace LeanCloud.Realtime { get; internal set; } - public DateTime LastMessageAt { + public long LastDeliveredTimestamp { get; internal set; } + public DateTime LastDeliveredAt { + get { + DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(LastDeliveredTimestamp); + return dateTimeOffset.DateTime; + } + } + + public long LastReadTimestamp { + get; internal set; + } + + public DateTime LastReadAt { + get { + DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(LastReadTimestamp); + return dateTimeOffset.DateTime; + } + } + public object this[string key] { get { return customProperties[key]; @@ -243,6 +261,11 @@ namespace LeanCloud.Realtime { return await Client.ConversationController.BlockMembers(Id, clientIds); } + /// + /// 将用户移除黑名单 + /// + /// + /// public async Task UnblockMembers(IEnumerable clientIds) { if (clientIds == null || clientIds.Count() == 0) { throw new ArgumentNullException(nameof(clientIds)); @@ -334,14 +357,23 @@ namespace LeanCloud.Realtime { /// /// 查询黑名单用户 /// - /// - /// + /// 限制 + /// 其实用户 Id /// public async Task QueryBlockedMembers(int limit = 10, string next = null) { return await Client.ConversationController.QueryBlockedMembers(Id, limit, next); } + /// + /// 查询聊天记录 + /// + /// 起点 + /// 终点 + /// 查找方向 + /// 限制 + /// 消息类型 + /// public async Task> QueryMessages(LCIMMessageQueryEndpoint start = null, LCIMMessageQueryEndpoint end = null, LCIMMessageQueryDirection direction = LCIMMessageQueryDirection.NewToOld, @@ -350,6 +382,14 @@ namespace LeanCloud.Realtime { return await Client.MessageController.QueryMessages(Id, start, end, direction, limit, messageType); } + /// + /// 获取会话已收/已读时间戳 + /// + /// + public async Task FetchReciptTimestamps() { + await Client.ConversationController.FetchReciptTimestamp(Id); + } + internal static bool IsTemporayConversation(string convId) { return convId.StartsWith("_tmp:"); } @@ -381,9 +421,9 @@ namespace LeanCloud.Realtime { IEnumerable ids = (muo as IList).Cast(); mutedIds = new HashSet(ids); } - if (conv.TryGetValue("lm", out object lmo)) { - LastMessageAt = (DateTime)LCDecoder.Decode(lmo); - } + //if (conv.TryGetValue("lm", out object lmo)) { + // LastMessageAt = (DateTime)LCDecoder.Decode(lmo); + //} } internal void MergeInfo(Dictionary attr) { diff --git a/Realtime/Internal/Controller/LCIMConversationController.cs b/Realtime/Internal/Controller/LCIMConversationController.cs index 12749a9..122bb53 100644 --- a/Realtime/Internal/Controller/LCIMConversationController.cs +++ b/Realtime/Internal/Controller/LCIMConversationController.cs @@ -498,6 +498,19 @@ namespace LeanCloud.Realtime.Internal.Controller { return convList; } + internal async Task FetchReciptTimestamp(string convId) { + ConvCommand convCommand = new ConvCommand { + Cid = convId + }; + GenericCommand request = Client.NewCommand(CommandType.Conv, OpType.MaxRead); + request.ConvMessage = convCommand; + GenericCommand response = await Connection.SendRequest(request); + convCommand = response.ConvMessage; + LCIMConversation conversation = await Client.GetOrQueryConversation(convCommand.Cid); + conversation.LastDeliveredTimestamp = convCommand.MaxAckTimestamp; + conversation.LastReadTimestamp = convCommand.MaxReadTimestamp; + } + private LCIMPartiallySuccessResult NewPartiallySuccessResult(IEnumerable succesfulIds, IEnumerable errors) { LCIMPartiallySuccessResult result = new LCIMPartiallySuccessResult {