コード例 #1
0
ファイル: RoomsController.cs プロジェクト: slskd/slskd
        public IActionResult GetUsersByRoomName([FromRoute] string roomName)
        {
            if (Tracker.TryGet(roomName, out var room))
            {
                var response = room.Users
                               .Select(user => UserDataResponse.FromUserData(user, self: user.Username == ApplicationStateMonitor.CurrentValue.User.Username));

                return(Ok(response));
            }

            return(NotFound());
        }
コード例 #2
0
ファイル: RoomsController.cs プロジェクト: slskd/slskd
        private RoomResponse MapRoomToRoomResponse(Room room)
        {
            bool IsSelf(string username)
            {
                return(username == ApplicationStateMonitor.CurrentValue.User.Username);
            }

            var response = RoomResponse.FromRoom(room);

            response.Users = room.Users
                             .Select(user => UserDataResponse.FromUserData(user, self: IsSelf(user.Username)));
            response.Messages = room.Messages
                                .Select(message => RoomMessageResponse.FromRoomMessage(message, self: IsSelf(message.Username)));

            return(response);
        }