mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 15:48:03 +00:00
Allow non-admin users to subscribe to their own Sessions (#13767)
Some checks failed
Stale PR Check / Check PRs with merge conflicts (push) Has been cancelled
Stale Issue Labeler / Check for stale issues (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
OpenAPI / OpenAPI - HEAD (push) Has been cancelled
OpenAPI / OpenAPI - BASE (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
OpenAPI / OpenAPI - Difference (push) Has been cancelled
OpenAPI / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI / OpenAPI - Publish Stable Spec (push) Has been cancelled
Some checks failed
Stale PR Check / Check PRs with merge conflicts (push) Has been cancelled
Stale Issue Labeler / Check for stale issues (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
OpenAPI / OpenAPI - HEAD (push) Has been cancelled
OpenAPI / OpenAPI - BASE (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
OpenAPI / OpenAPI - Difference (push) Has been cancelled
OpenAPI / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI / OpenAPI - Publish Stable Spec (push) Has been cancelled
This commit is contained in:
@@ -80,6 +80,16 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <returns>Task{`1}.</returns>
|
||||
protected abstract Task<TReturnDataType> GetDataToSend();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data to send for a specific connection.
|
||||
/// </summary>
|
||||
/// <param name="connection">The connection.</param>
|
||||
/// <returns>Task{`1}.</returns>
|
||||
protected virtual Task<TReturnDataType> GetDataToSendForConnection(IWebSocketConnection connection)
|
||||
{
|
||||
return GetDataToSend();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the message.
|
||||
/// </summary>
|
||||
@@ -174,17 +184,11 @@ namespace MediaBrowser.Controller.Net
|
||||
continue;
|
||||
}
|
||||
|
||||
var data = await GetDataToSend().ConfigureAwait(false);
|
||||
if (data is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<Task> GetTasks()
|
||||
{
|
||||
foreach (var tuple in tuples)
|
||||
{
|
||||
yield return SendDataInternal(data, tuple);
|
||||
yield return SendDataForConnectionAsync(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,12 +202,19 @@ namespace MediaBrowser.Controller.Net
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendDataInternal(TReturnDataType data, (IWebSocketConnection Connection, CancellationTokenSource CancellationTokenSource, TStateType State) tuple)
|
||||
private async Task SendDataForConnectionAsync((IWebSocketConnection Connection, CancellationTokenSource CancellationTokenSource, TStateType State) tuple)
|
||||
{
|
||||
try
|
||||
{
|
||||
var (connection, cts, state) = tuple;
|
||||
var cancellationToken = cts.Token;
|
||||
|
||||
var data = await GetDataToSendForConnection(connection).ConfigureAwait(false);
|
||||
if (data is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await connection.SendAsync(
|
||||
new OutboundWebSocketMessage<TReturnDataType> { MessageType = Type, Data = data },
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user