update admin session filter
This commit is contained in:
parent
234dcaf458
commit
acd60f1d85
|
@ -185,12 +185,8 @@ namespace MediaBrowser.Controller.Session
|
||||||
/// Sends the message to user sessions.
|
/// Sends the message to user sessions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="userId">The user identifier.</param>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="data">The data.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task SendMessageToUserSessions<T>(string userId, string name, T data, CancellationToken cancellationToken);
|
Task SendMessageToUserSessions<T>(List<string> userIds, string name, T data, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the message to user device sessions.
|
/// Sends the message to user device sessions.
|
||||||
|
|
|
@ -54,18 +54,15 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
private async void SendMessage(string name, TimerEventInfo info)
|
private async void SendMessage(string name, TimerEventInfo info)
|
||||||
{
|
{
|
||||||
var users = _userManager.Users.Where(i => i.Policy.EnableLiveTvAccess).ToList();
|
var users = _userManager.Users.Where(i => i.Policy.EnableLiveTvAccess).Select(i => i.Id.ToString("N")).ToList();
|
||||||
|
|
||||||
foreach (var user in users)
|
try
|
||||||
{
|
{
|
||||||
try
|
await _sessionManager.SendMessageToUserSessions<TimerEventInfo>(users, name, info, CancellationToken.None);
|
||||||
{
|
}
|
||||||
await _sessionManager.SendMessageToUserSessions<TimerEventInfo>(user.Id.ToString("N"), name, info, CancellationToken.None);
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
_logger.ErrorException("Error sending message", ex);
|
||||||
{
|
|
||||||
_logger.ErrorException("Error sending message", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ using MediaBrowser.Controller.Sync;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.EntryPoints
|
namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
|
@ -164,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
private async void SendMessageToUserSession<T>(User user, string name, T data)
|
private async void SendMessageToUserSession<T>(User user, string name, T data)
|
||||||
{
|
{
|
||||||
await _sessionManager.SendMessageToUserSessions(user.Id.ToString("N"), name, data, CancellationToken.None);
|
await _sessionManager.SendMessageToUserSessions(new List<string> { user.Id.ToString("N") }, name, data, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1871,29 +1871,15 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
public Task SendMessageToAdminSessions<T>(string name, T data, CancellationToken cancellationToken)
|
public Task SendMessageToAdminSessions<T>(string name, T data, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// TODO: How to identify admin sessions?
|
var adminUserIds = _userManager.Users.Where(i => i.Policy.IsAdministrator).Select(i => i.Id.ToString("N")).ToList();
|
||||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
|
||||||
|
|
||||||
var tasks = sessions.Select(session => Task.Run(async () =>
|
return SendMessageToUserSessions(adminUserIds, name, data, cancellationToken);
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await session.SessionController.SendMessage(name, data, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error sending message", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, cancellationToken));
|
|
||||||
|
|
||||||
return Task.WhenAll(tasks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SendMessageToUserSessions<T>(string userId, string name, T data,
|
public Task SendMessageToUserSessions<T>(List<string> userIds, string name, T data,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null && i.ContainsUser(userId)).ToList();
|
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null && userIds.Any(i.ContainsUser)).ToList();
|
||||||
|
|
||||||
var tasks = sessions.Select(session => Task.Run(async () =>
|
var tasks = sessions.Select(session => Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 14.0.24720.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F0E0E64C-2A6F-4E35-9533-D53AC07C2CD1}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F0E0E64C-2A6F-4E35-9533-D53AC07C2CD1}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -65,6 +65,9 @@ EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
|
Loading…
Reference in New Issue
Block a user