Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated moderation UI to only show filter buttons for the enabled providers #378

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TagzApp.Blazor/Hubs/ModerationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public AvailableProvider[] GetAvailableProviders()
{

return _Service.Providers
.Where(p => p.Enabled)
.Select(p => new AvailableProvider(p.Id, p.DisplayName))
.ToArray();

Expand Down
5 changes: 5 additions & 0 deletions src/TagzApp.Common/ISocialMediaProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public interface ISocialMediaProvider : IDisposable
/// </summary>
string Description { get; }

/// <summary>
/// Whether the provider is enabled
/// </summary>
bool Enabled { get; }

/// <summary>
/// How frequently new content should be retrieved from the provider
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/TagzApp.Providers.AzureQueue/AzureQueueProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public class AzureQueueProvider : ISocialMediaProvider
public string Description => "Q+A submitted through a website form";
public TimeSpan NewContentRetrievalFrequency => TimeSpan.FromSeconds(3);

public bool Enabled { get; private set; }

public AzureQueueProvider(AzureQueueConfiguration configuration)
{
_Configuration = configuration;
Enabled = configuration.Enabled;
}


Expand Down
3 changes: 3 additions & 0 deletions src/TagzApp.Providers.Blazot/BlazotProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public sealed class BlazotProvider : ISocialMediaProvider
private bool _DisposedValue;

public string Description { get; init; } = "Blazot is an all new social networking platform and your launchpad to the social universe!";
public bool Enabled { get; }

public BlazotProvider(ILogger<BlazotProvider> logger, BlazotConfiguration settings,
IContentConverter contentConverter, ITransmissionsService transmissionsService, IAuthService authService)
Expand All @@ -36,6 +37,8 @@ public BlazotProvider(ILogger<BlazotProvider> logger, BlazotConfiguration settin
_WindowSeconds = settings?.WindowSeconds ?? throw new ArgumentNullException(nameof(settings));
_WindowRequests = settings.WindowRequests;

Enabled = settings.Enabled;

if (!string.IsNullOrWhiteSpace(settings.Description))
{
Description = settings.Description;
Expand Down
5 changes: 5 additions & 0 deletions src/TagzApp.Providers.Bluesky/BlueskyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using FishyFlip;
using FishyFlip.Models;
using FishyFlip.Tools;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Debug;

namespace TagzApp.Providers.Bluesky;
Expand All @@ -22,6 +23,8 @@ public class BlueskyProvider : ISocialMediaProvider

public TimeSpan NewContentRetrievalFrequency => TimeSpan.FromMilliseconds(1000);

public bool Enabled { get; private set; }

private ConcurrentQueue<Content> _messageQueue = new();
private BlueskyConfiguration _Config;

Expand Down Expand Up @@ -70,6 +73,8 @@ public async Task StartAsync()

_Config = (await GetConfiguration(ConfigureTagzAppFactory.Current)) as BlueskyConfiguration ?? new BlueskyConfiguration();

Enabled = _Config.Enabled;

var debugLog = new DebugLoggerProvider();

_AtProtocol = new ATProtocolBuilder()
Expand Down
2 changes: 2 additions & 0 deletions src/TagzApp.Providers.Mastodon/MastodonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public MastodonProvider(IHttpClientFactory httpClientFactory, ILogger<MastodonPr
{
_HttpClient = httpClientFactory.CreateClient(nameof(MastodonProvider));
_Logger = logger;
Enabled = configuration.Enabled;

if (!string.IsNullOrWhiteSpace(configuration.Description))
{
Expand All @@ -32,6 +33,7 @@ public MastodonProvider(IHttpClientFactory httpClientFactory, ILogger<MastodonPr
public TimeSpan NewContentRetrievalFrequency => TimeSpan.FromSeconds(20);

public string NewestId { get; set; } = string.Empty;
public bool Enabled { get; }

public void Dispose()
{
Expand Down
5 changes: 4 additions & 1 deletion src/TagzApp.Providers.TwitchChat/TwitchChatProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Concurrent;
using System.Web;
Expand All @@ -14,6 +15,7 @@ public class TwitchChatProvider : ISocialMediaProvider, IDisposable
public string DisplayName => "TwitchChat";
public TimeSpan NewContentRetrievalFrequency => TimeSpan.FromSeconds(1);
public string Description { get; init; } = "Twitch is where millions of people come together live every day to chat, interact, and make their own entertainment together.";
public bool Enabled { get; }

private SocialMediaStatus _Status = SocialMediaStatus.Unhealthy;
private string _StatusMessage = "Not started";
Expand All @@ -29,6 +31,7 @@ public TwitchChatProvider(ILogger<TwitchChatProvider> logger, HttpClient client)
_Settings = ConfigureTagzAppFactory.Current.GetConfigurationById<TwitchChatConfiguration>(Id).GetAwaiter().GetResult();
_Logger = logger;
_ProfileRepository = new TwitchProfileRepository(_Settings.ClientId, _Settings.ClientSecret, client);
Enabled = _Settings.Enabled;

if (!string.IsNullOrWhiteSpace(_Settings.Description))
{
Expand Down
2 changes: 2 additions & 0 deletions src/TagzApp.Providers.Twitter/TwitterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ public class TwitterProvider : ISocialMediaProvider, IHasNewestId
public string NewestId { get; set; } = string.Empty;

public string Description { get; init; } = "Twitter is a service for friends, family, and coworkers to communicate and stay connected through the exchange of quick, frequent messages";
public bool Enabled { get; }

public TwitterProvider(IHttpClientFactory httpClientFactory, ILogger<TwitterProvider> logger,
TwitterConfiguration configuration)
{
_HttpClient = httpClientFactory.CreateClient(nameof(TwitterProvider));
_Configuration = configuration;
_Logger = logger;
Enabled = configuration.Enabled;

if (!string.IsNullOrWhiteSpace(configuration.Description))
{
Expand Down
3 changes: 3 additions & 0 deletions src/TagzApp.Providers.YouTubeChat/YouTubeChatProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class YouTubeChatProvider : ISocialMediaProvider, IDisposable
public string LiveChatId { get; set; }
public string RefreshToken { get; set; }
public string YouTubeEmailId { get; set; }
public bool Enabled { get; }

private string _GoogleException = string.Empty;

Expand All @@ -38,6 +39,8 @@ public class YouTubeChatProvider : ISocialMediaProvider, IDisposable
public YouTubeChatProvider(YouTubeChatConfiguration config, IConfiguration configuration)
{
_ChatConfig = config;
Enabled = config.Enabled;

var rawConfig = configuration["ApplicationConfiguration:YouTubeChatConfiguration"];

if (rawConfig == null || rawConfig == "{}") return;
Expand Down
3 changes: 3 additions & 0 deletions src/TagzApp.Providers.Youtube/YoutubeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ internal class YoutubeProvider : ISocialMediaProvider

public TimeSpan NewContentRetrievalFrequency => TimeSpan.FromSeconds(30);

public bool Enabled { get; }

public YoutubeProvider(YoutubeConfiguration options)
{
_Configuration = options;
Enabled = options.Enabled;
}

public async Task<IEnumerable<Content>> GetContentForHashtag(Hashtag tag, DateTimeOffset since)
Expand Down
2 changes: 2 additions & 0 deletions src/TagzApp.WebTest/StubSocialMediaProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class StubSocialMediaProvider : ISocialMediaProvider

public string Description => "TEST";

public bool Enabled { get; } = true;

public void Dispose()
{
// do nothing
Expand Down
Loading