//
// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄
// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █
// █__ --█ █__ --█ ◄█ - █
// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█
// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉
// │ Copyright (c) JP Dillingham.
// │
// │ 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, version 3.
// │
// │ 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/.
// │
// │ This program is distributed with Additional Terms pursuant to Section 7
// │ of the AGPLv3. See the LICENSE file in the root directory of this
// │ project for the complete terms and conditions.
// │
// │ https://slskd.org
// │
// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌
// │ SPDX-FileCopyrightText: JP Dillingham
// │ SPDX-License-Identifier: AGPL-3.0-only
// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈
//
namespace slskd.Messaging
{
using System;
using Soulseek;
///
/// A private message.
///
public class PrivateMessage
{
///
/// The UTC timestamp of the message.
///
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
///
/// The unique message id, used to acknowledge receipt.
///
public int Id { get; set; }
///
/// The username of the remote user.
///
public string Username { get; set; }
///
/// Gets or sets the message direction.
///
public MessageDirection Direction { get; set; }
///
/// The message.
///
public string Message { get; set; }
///
/// A value indicating whether the message has been acknowledged.
///
public bool IsAcknowledged { get; set; } = false;
///
/// A value indicating whether the message has was replayed by the server.
///
public bool WasReplayed { get; set; } = false;
public static PrivateMessage FromEventArgs(PrivateMessageReceivedEventArgs eventArgs)
{
return new PrivateMessage()
{
Id = eventArgs.Id,
Timestamp = eventArgs.Timestamp,
Username = eventArgs.Username,
Message = eventArgs.Message,
IsAcknowledged = false,
WasReplayed = eventArgs.Replayed,
Direction = MessageDirection.In,
};
}
}
}