* LCIMConversation.cs:

* LCIMConversationController.cs:

* LCIMMessageController.cs: chore: 完善提醒功能
oneRain 2020-04-28 14:48:36 +08:00
parent 5d0c5a32e6
commit c3fbf36971
3 changed files with 16 additions and 0 deletions

View File

@ -187,6 +187,7 @@ namespace LeanCloud.Realtime {
return; return;
} }
await Client.MessageController.Read(Id, LastMessage); await Client.MessageController.Read(Id, LastMessage);
Unread = 0;
} }
/// <summary> /// <summary>

View File

@ -597,6 +597,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.Id = conv.Mid; message.Id = conv.Mid;
message.FromClientId = conv.From; message.FromClientId = conv.From;
message.SentTimestamp = conv.Timestamp; message.SentTimestamp = conv.Timestamp;
message.Mentioned = conv.Mentioned;
conversation.LastMessage = message; conversation.LastMessage = message;
} }
return conversation; return conversation;

View File

@ -46,6 +46,15 @@ namespace LeanCloud.Realtime.Internal.Controller {
if (options.Will) { if (options.Will) {
direct.Will = options.Will; direct.Will = options.Will;
} }
// 提醒所有人
if (message.MentionAll) {
direct.MentionAll = message.MentionAll;
}
// 提醒用户列表
if (message.MentionIdList != null &&
message.MentionIdList.Count > 0) {
direct.MentionPids.AddRange(message.MentionIdList);
}
GenericCommand command = NewCommand(CommandType.Direct); GenericCommand command = NewCommand(CommandType.Direct);
command.DirectMessage = direct; command.DirectMessage = direct;
// 优先级 // 优先级
@ -177,6 +186,8 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.PatchedTimestamp = item.PatchTimestamp; message.PatchedTimestamp = item.PatchTimestamp;
message.MentionAll = item.MentionAll; message.MentionAll = item.MentionAll;
message.MentionIdList = item.MentionPids.ToList(); message.MentionIdList = item.MentionPids.ToList();
message.Mentioned = message.MentionAll ||
message.MentionIdList.Contains(Client.Id);
return message; return message;
}).ToList().AsReadOnly(); }).ToList().AsReadOnly();
} }
@ -256,6 +267,8 @@ namespace LeanCloud.Realtime.Internal.Controller {
message.SentTimestamp = direct.Timestamp; message.SentTimestamp = direct.Timestamp;
message.MentionAll = direct.MentionAll; message.MentionAll = direct.MentionAll;
message.MentionIdList = direct.MentionPids.ToList(); message.MentionIdList = direct.MentionPids.ToList();
message.Mentioned = message.MentionAll ||
message.MentionIdList.Contains(Client.Id);
message.PatchedTimestamp = direct.PatchTimestamp; message.PatchedTimestamp = direct.PatchTimestamp;
message.IsTransient = direct.Transient; message.IsTransient = direct.Transient;
// 通知服务端已接收 // 通知服务端已接收
@ -265,6 +278,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
// 获取对话 // 获取对话
LCIMConversation conversation = await Client.GetOrQueryConversation(direct.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(direct.Cid);
conversation.Unread++;
conversation.LastMessage = message; conversation.LastMessage = message;
Client.OnMessage?.Invoke(conversation, message); Client.OnMessage?.Invoke(conversation, message);
} }