Handle new notifications for comments

This commit is contained in:
JustArchi
2020-04-06 20:37:53 +02:00
parent 5360cba93a
commit ae2f3ce1ff

View File

@@ -70,6 +70,10 @@ namespace ArchiSteamFarm {
LastPacketReceived = DateTime.UtcNow;
switch (packetMsg.MsgType) {
case EMsg.ClientCommentNotifications:
HandleCommentNotifications(packetMsg);
break;
case EMsg.ClientItemAnnouncements:
HandleItemAnnouncements(packetMsg);
@@ -629,6 +633,17 @@ namespace ArchiSteamFarm {
Client.Send(request);
}
private void HandleCommentNotifications(IPacketMsg packetMsg) {
if (packetMsg == null) {
ArchiLogger.LogNullError(nameof(packetMsg));
return;
}
ClientMsgProtobuf<CMsgClientCommentNotifications> response = new ClientMsgProtobuf<CMsgClientCommentNotifications>(packetMsg);
Client.PostCallback(new UserNotificationsCallback(packetMsg.TargetJobID, response.Body));
}
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
if (packetMsg == null) {
ArchiLogger.LogNullError(nameof(packetMsg));
@@ -837,6 +852,15 @@ namespace ArchiSteamFarm {
Notifications = new Dictionary<EUserNotification, uint>(1) { { EUserNotification.Items, msg.count_new_items } };
}
internal UserNotificationsCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientCommentNotifications msg) {
if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
}
JobID = jobID;
Notifications = new Dictionary<EUserNotification, uint>(1) { { EUserNotification.Comments, msg.count_new_comments + msg.count_new_comments_owner + msg.count_new_comments_subscriptions } };
}
[PublicAPI]
public enum EUserNotification : byte {
Unknown,