aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/API/DTO/RoomMessageResponse.cs
blob: 3a804b65785e71f2e284ee40561fec495254549d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace slskd.API.DTO
{
    using System;
    using slskd.Entities;

    public class RoomMessageResponse
    {
        /// <summary>
        ///     The timestamp of the message.
        /// </summary>
        public DateTime Timestamp { get; set; } = DateTime.UtcNow;

        /// <summary>
        ///     The username of the user who sent the message.
        /// </summary>
        public string Username { get; set; }

        /// <summary>
        ///     The message.
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        ///     The room to which the message pertains.
        /// </summary>
        public string RoomName { get; set; }

        /// <summary>
        ///     A value indicating whether this user data belongs to the currently logged in user.
        /// </summary>
        public bool? Self { get; set; }

        public static RoomMessageResponse FromRoomMessage(RoomMessage roomMessage, bool self = false)
        {
            return new RoomMessageResponse()
            {
                Timestamp = roomMessage.Timestamp,
                Username = roomMessage.Username,
                Message = roomMessage.Message,
                RoomName = roomMessage.RoomName,
                Self = self ? self : (bool?)null
            };
        }
    }
}