aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Messaging/Types
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-12-29 16:47:43 -0600
committerGitHub <noreply@github.com>2022-12-29 16:47:43 -0600
commit49bc255026aa5ef2c4df0727134b7627808270fc (patch)
tree89349c7aeb4beac343e0e70388dce7063e243388 /src/slskd/Messaging/Types
parent5276699801f25eec692e48a39c73f45424a22d27 (diff)
parent8352d28eb6eae848530aa2d6b4a4196d53f4ac88 (diff)
downloadslskd-49bc255026aa5ef2c4df0727134b7627808270fc.tar.gz
Merge pull request #809 from slskd/chat-logs
Save chat logs in a database (prevent message loss when restarting)
Diffstat (limited to 'src/slskd/Messaging/Types')
-rw-r--r--src/slskd/Messaging/Types/Conversation.cs30
-rw-r--r--src/slskd/Messaging/Types/MessageDirection.cs25
-rw-r--r--src/slskd/Messaging/Types/PrivateMessage.cs24
-rw-r--r--src/slskd/Messaging/Types/RoomMessage.cs5
4 files changed, 72 insertions, 12 deletions
diff --git a/src/slskd/Messaging/Types/Conversation.cs b/src/slskd/Messaging/Types/Conversation.cs
new file mode 100644
index 00000000..6fabfcf1
--- /dev/null
+++ b/src/slskd/Messaging/Types/Conversation.cs
@@ -0,0 +1,30 @@
+// <copyright file="Conversation.cs" company="slskd Team">
+// Copyright (c) slskd Team. All rights reserved.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see https://www.gnu.org/licenses/.
+// </copyright>
+
+namespace slskd.Messaging
+{
+ using System.Collections.Generic;
+
+ public class Conversation
+ {
+ public string Username { get; set; }
+ public bool IsActive { get; set; } = true;
+ public int UnAcknowledgedMessageCount { get; set; }
+ public bool HasUnAcknowledgedMessages => UnAcknowledgedMessageCount > 0;
+ public IEnumerable<PrivateMessage> Messages { get; set; }
+ }
+}
diff --git a/src/slskd/Messaging/Types/MessageDirection.cs b/src/slskd/Messaging/Types/MessageDirection.cs
new file mode 100644
index 00000000..e0b9a0b5
--- /dev/null
+++ b/src/slskd/Messaging/Types/MessageDirection.cs
@@ -0,0 +1,25 @@
+// <copyright file="MessageDirection.cs" company="slskd Team">
+// Copyright (c) slskd Team. All rights reserved.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see https://www.gnu.org/licenses/.
+// </copyright>
+
+namespace slskd.Messaging
+{
+ public enum MessageDirection
+ {
+ Out = 0,
+ In = 1,
+ }
+}
diff --git a/src/slskd/Messaging/Types/PrivateMessage.cs b/src/slskd/Messaging/Types/PrivateMessage.cs
index 236632aa..a4b1c325 100644
--- a/src/slskd/Messaging/Types/PrivateMessage.cs
+++ b/src/slskd/Messaging/Types/PrivateMessage.cs
@@ -26,9 +26,9 @@ namespace slskd.Messaging
public class PrivateMessage
{
/// <summary>
- /// A value indicating whether the message has been acknowledged.
+ /// The UTC timestamp of the message.
/// </summary>
- public bool Acknowledged { get; set; } = false;
+ public DateTime Timestamp { get; set; } = DateTime.UtcNow;
/// <summary>
/// The unique message id, used to acknowledge receipt.
@@ -36,24 +36,24 @@ namespace slskd.Messaging
public int Id { get; set; }
/// <summary>
- /// The message.
+ /// The username of the remote user.
/// </summary>
- public string Message { get; set; }
+ public string Username { get; set; }
/// <summary>
- /// A value indicating whether the message was replayed.
+ /// Gets or sets the message direction.
/// </summary>
- public bool Replayed { get; set; }
+ public MessageDirection Direction { get; set; }
/// <summary>
- /// The UTC timestamp of the message.
+ /// The message.
/// </summary>
- public DateTime Timestamp { get; set; } = DateTime.UtcNow;
+ public string Message { get; set; }
/// <summary>
- /// The username of the user who sent the message.
+ /// A value indicating whether the message has been acknowledged.
/// </summary>
- public string Username { get; set; }
+ public bool IsAcknowledged { get; set; } = false;
public static PrivateMessage FromEventArgs(PrivateMessageReceivedEventArgs eventArgs)
{
@@ -63,8 +63,8 @@ namespace slskd.Messaging
Timestamp = eventArgs.Timestamp,
Username = eventArgs.Username,
Message = eventArgs.Message,
- Acknowledged = false,
- Replayed = eventArgs.Replayed,
+ IsAcknowledged = false,
+ Direction = MessageDirection.In,
};
}
}
diff --git a/src/slskd/Messaging/Types/RoomMessage.cs b/src/slskd/Messaging/Types/RoomMessage.cs
index 7a06a192..6d109464 100644
--- a/src/slskd/Messaging/Types/RoomMessage.cs
+++ b/src/slskd/Messaging/Types/RoomMessage.cs
@@ -45,6 +45,11 @@ namespace slskd.Messaging
/// </summary>
public string RoomName { get; set; }
+ /// <summary>
+ /// Gets or sets the message direction.
+ /// </summary>
+ public MessageDirection Direction { get; set; }
+
public static RoomMessage FromEventArgs(RoomMessageReceivedEventArgs eventArgs, DateTime? timestamp = null)
{
return new RoomMessage()