mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	added user data save event
This commit is contained in:
		
							parent
							
								
									0abc9d3493
								
							
						
					
					
						commit
						33a3e215d0
					
				@ -64,7 +64,7 @@ namespace MediaBrowser.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device) && !string.IsNullOrEmpty(version))
 | 
					                if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device) && !string.IsNullOrEmpty(version))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    SessionManager.LogConnectionActivity(client, version, deviceId, device, user);
 | 
					                    SessionManager.LogSessionActivity(client, version, deviceId, device, user);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -413,6 +413,11 @@ namespace MediaBrowser.Common.Implementations
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                Logger.Error("Error creating {0}", ex, type.Name);
 | 
					                Logger.Error("Error creating {0}", ex, type.Name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if DEBUG
 | 
				
			||||||
 | 
					                throw;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Don't blow up in release mode
 | 
				
			||||||
                return null;
 | 
					                return null;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,11 @@ namespace MediaBrowser.Controller.Library
 | 
				
			|||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public interface IUserDataManager
 | 
					    public interface IUserDataManager
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Occurs when [user data saved].
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        event EventHandler<UserDataSaveEventArgs> UserDataSaved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Saves the user data.
 | 
					        /// Saves the user data.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										36
									
								
								MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					using MediaBrowser.Controller.Entities;
 | 
				
			||||||
 | 
					using MediaBrowser.Model.Entities;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace MediaBrowser.Controller.Library
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Class UserDataSaveEventArgs
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class UserDataSaveEventArgs : EventArgs
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the user id.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The user id.</value>
 | 
				
			||||||
 | 
					        public Guid UserId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the key.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The key.</value>
 | 
				
			||||||
 | 
					        public string Key { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the save reason.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The save reason.</value>
 | 
				
			||||||
 | 
					        public UserDataSaveReason SaveReason { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the user data.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The user data.</value>
 | 
				
			||||||
 | 
					        public UserItemData UserData { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -98,6 +98,7 @@
 | 
				
			|||||||
    <Compile Include="Library\IMetadataSaver.cs" />
 | 
					    <Compile Include="Library\IMetadataSaver.cs" />
 | 
				
			||||||
    <Compile Include="Library\ItemUpdateType.cs" />
 | 
					    <Compile Include="Library\ItemUpdateType.cs" />
 | 
				
			||||||
    <Compile Include="Library\IUserDataManager.cs" />
 | 
					    <Compile Include="Library\IUserDataManager.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Library\UserDataSaveEventArgs.cs" />
 | 
				
			||||||
    <Compile Include="LiveTv\ChannelInfo.cs" />
 | 
					    <Compile Include="LiveTv\ChannelInfo.cs" />
 | 
				
			||||||
    <Compile Include="LiveTv\ILiveTvManager.cs" />
 | 
					    <Compile Include="LiveTv\ILiveTvManager.cs" />
 | 
				
			||||||
    <Compile Include="LiveTv\ILiveTvService.cs" />
 | 
					    <Compile Include="LiveTv\ILiveTvService.cs" />
 | 
				
			||||||
@ -174,7 +175,7 @@
 | 
				
			|||||||
    <Compile Include="Kernel.cs" />
 | 
					    <Compile Include="Kernel.cs" />
 | 
				
			||||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
					    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
				
			||||||
    <Compile Include="Providers\BaseMetadataProvider.cs" />
 | 
					    <Compile Include="Providers\BaseMetadataProvider.cs" />
 | 
				
			||||||
    <Compile Include="Session\ISessionRemoteController.cs" />
 | 
					    <Compile Include="Session\ISessionController.cs" />
 | 
				
			||||||
    <Compile Include="Session\PlaybackInfo.cs" />
 | 
					    <Compile Include="Session\PlaybackInfo.cs" />
 | 
				
			||||||
    <Compile Include="Session\PlaybackProgressInfo.cs" />
 | 
					    <Compile Include="Session\PlaybackProgressInfo.cs" />
 | 
				
			||||||
    <Compile Include="Session\PlaybackStopInfo.cs" />
 | 
					    <Compile Include="Session\PlaybackStopInfo.cs" />
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,7 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace MediaBrowser.Controller.Session
 | 
					namespace MediaBrowser.Controller.Session
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public interface ISessionRemoteController
 | 
					    public interface ISessionController
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Supportses the specified session.
 | 
					        /// Supportses the specified session.
 | 
				
			||||||
@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Session
 | 
				
			|||||||
        /// Adds the parts.
 | 
					        /// Adds the parts.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="remoteControllers">The remote controllers.</param>
 | 
					        /// <param name="remoteControllers">The remote controllers.</param>
 | 
				
			||||||
        void AddParts(IEnumerable<ISessionRemoteController> remoteControllers);
 | 
					        void AddParts(IEnumerable<ISessionController> remoteControllers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Occurs when [playback start].
 | 
					        /// Occurs when [playback start].
 | 
				
			||||||
@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Session
 | 
				
			|||||||
        /// <param name="user">The user.</param>
 | 
					        /// <param name="user">The user.</param>
 | 
				
			||||||
        /// <returns>Task.</returns>
 | 
					        /// <returns>Task.</returns>
 | 
				
			||||||
        /// <exception cref="System.ArgumentNullException">user</exception>
 | 
					        /// <exception cref="System.ArgumentNullException">user</exception>
 | 
				
			||||||
        Task<SessionInfo> LogConnectionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user);
 | 
					        Task<SessionInfo> LogSessionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Used to report that playback has started for an item
 | 
					        /// Used to report that playback has started for an item
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,9 @@
 | 
				
			|||||||
using System.Collections.Generic;
 | 
					using MediaBrowser.Common.Net;
 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using MediaBrowser.Common.Net;
 | 
					 | 
				
			||||||
using MediaBrowser.Controller.Entities;
 | 
					using MediaBrowser.Controller.Entities;
 | 
				
			||||||
using MediaBrowser.Model.Net;
 | 
					using MediaBrowser.Model.Net;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace MediaBrowser.Controller.Session
 | 
					namespace MediaBrowser.Controller.Session
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
using MediaBrowser.Controller.Entities;
 | 
					using MediaBrowser.Common.Events;
 | 
				
			||||||
 | 
					using MediaBrowser.Controller.Entities;
 | 
				
			||||||
using MediaBrowser.Controller.Library;
 | 
					using MediaBrowser.Controller.Library;
 | 
				
			||||||
using MediaBrowser.Controller.Persistence;
 | 
					using MediaBrowser.Controller.Persistence;
 | 
				
			||||||
using MediaBrowser.Model.Entities;
 | 
					using MediaBrowser.Model.Entities;
 | 
				
			||||||
@ -15,6 +16,8 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public class UserDataManager : IUserDataManager
 | 
					    public class UserDataManager : IUserDataManager
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        public event EventHandler<UserDataSaveEventArgs> UserDataSaved;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private readonly ConcurrentDictionary<string, UserItemData> _userData = new ConcurrentDictionary<string, UserItemData>();
 | 
					        private readonly ConcurrentDictionary<string, UserItemData> _userData = new ConcurrentDictionary<string, UserItemData>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private readonly ILogger _logger;
 | 
					        private readonly ILogger _logger;
 | 
				
			||||||
@ -84,6 +87,15 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                throw;
 | 
					                throw;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Key = key,
 | 
				
			||||||
 | 
					                UserData = userData,
 | 
				
			||||||
 | 
					                SaveReason = reason,
 | 
				
			||||||
 | 
					                UserId = userId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, _logger);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
 | 
				
			|||||||
@ -78,8 +78,8 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
            _userRepository = userRepository;
 | 
					            _userRepository = userRepository;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private List<ISessionRemoteController> _remoteControllers;
 | 
					        private List<ISessionController> _remoteControllers;
 | 
				
			||||||
        public void AddParts(IEnumerable<ISessionRemoteController> remoteControllers)
 | 
					        public void AddParts(IEnumerable<ISessionController> remoteControllers)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _remoteControllers = remoteControllers.ToList();
 | 
					            _remoteControllers = remoteControllers.ToList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        /// <returns>Task.</returns>
 | 
					        /// <returns>Task.</returns>
 | 
				
			||||||
        /// <exception cref="System.UnauthorizedAccessException"></exception>
 | 
					        /// <exception cref="System.UnauthorizedAccessException"></exception>
 | 
				
			||||||
        /// <exception cref="System.ArgumentNullException">user</exception>
 | 
					        /// <exception cref="System.ArgumentNullException">user</exception>
 | 
				
			||||||
        public async Task<SessionInfo> LogConnectionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user)
 | 
					        public async Task<SessionInfo> LogSessionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (string.IsNullOrEmpty(clientType))
 | 
					            if (string.IsNullOrEmpty(clientType))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -442,7 +442,7 @@ namespace MediaBrowser.Server.Implementations.Session
 | 
				
			|||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="session">The session.</param>
 | 
					        /// <param name="session">The session.</param>
 | 
				
			||||||
        /// <returns>IEnumerable{ISessionRemoteController}.</returns>
 | 
					        /// <returns>IEnumerable{ISessionRemoteController}.</returns>
 | 
				
			||||||
        private IEnumerable<ISessionRemoteController> GetControllers(SessionInfo session)
 | 
					        private IEnumerable<ISessionController> GetControllers(SessionInfo session)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return _remoteControllers.Where(i => i.Supports(session));
 | 
					            return _remoteControllers.Where(i => i.Supports(session));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace MediaBrowser.Server.Implementations.Session
 | 
					namespace MediaBrowser.Server.Implementations.Session
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class WebSocketController : ISessionRemoteController
 | 
					    public class WebSocketController : ISessionController
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public bool Supports(SessionInfo session)
 | 
					        public bool Supports(SessionInfo session)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
				
			|||||||
@ -427,7 +427,7 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            ProviderManager.AddParts(GetExports<BaseMetadataProvider>());
 | 
					            ProviderManager.AddParts(GetExports<BaseMetadataProvider>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            SessionManager.AddParts(GetExports<ISessionRemoteController>());
 | 
					            SessionManager.AddParts(GetExports<ISessionController>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ImageProcessor.AddParts(GetExports<IImageEnhancer>());
 | 
					            ImageProcessor.AddParts(GetExports<IImageEnhancer>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user