Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
darkalfx committed Apr 5, 2020
2 parents f0d1e61 + 8cbd8e8 commit 1ac8fb4
Show file tree
Hide file tree
Showing 80 changed files with 1,351 additions and 619 deletions.
2 changes: 1 addition & 1 deletion Requestrr.WebApi/ClientApp/package.json
@@ -1,6 +1,6 @@
{
"name": "Requestrr",
"version": "1.0.8",
"version": "1.0.9",
"description": "Requestrr is a server designed to faciliate the request of media through chat applications.",
"main": "index.js",
"author": "Darkalfx",
Expand Down
Expand Up @@ -67,6 +67,11 @@
}

.react-dropdown-select-content {
height: 23px !important;
overflow: hidden !important;
}

.react-dropdown-select-type-multi {
height: 28px !important;
overflow: hidden !important;
}
Expand Down
Expand Up @@ -161,7 +161,7 @@ class Ombi extends React.Component {
<Dropdown
name="API"
value={this.state.apiVersion}
items={[{ name: "Version 3", value: "3" }]}
items={[{ name: "Version 3-4", value: "3" }]}
onChange={newApiVersion => this.setState({ apiVersion: newApiVersion }, this.onValueChange)} />
</Col>
<Col lg="6">
Expand Down
Expand Up @@ -29,7 +29,7 @@ class Footer extends React.Component {
<Col xl="6">
<div className="copyright text-center text-xl-left text-muted">
© {new Date().getFullYear()}{" "}
Requestrr (v1.0.8)
Requestrr (v1.0.9)
</div>
</Col>
</Row>
Expand Down
Expand Up @@ -31,7 +31,7 @@ class AuthFooter extends React.Component {
<Col xl="6">
<div className="copyright text-center text-xl-left text-muted">
© {new Date().getFullYear()}{" "}
Requestrr (v1.0.8)
Requestrr (v1.0.9)
</div>
</Col>
</Row>
Expand Down
Expand Up @@ -72,7 +72,12 @@ export function save(saveModel) {
'MonitoredChannels': saveModel.monitoredChannels,
'TvShowRoles': saveModel.tvShowRoles,
'MovieRoles': saveModel.movieRoles,
'EnableDirectMessageSupport': saveModel.enableDirectMessageSupport,
'EnableRequestsThroughDirectMessages': saveModel.enableRequestsThroughDirectMessages,
'AutomaticallyNotifyRequesters': saveModel.automaticallyNotifyRequesters,
'NotificationMode': saveModel.notificationMode,
'NotificationChannels': saveModel.notificationChannels,
'AutomaticallyPurgeCommandMessages': saveModel.automaticallyPurgeCommandMessages,
'DisplayHelpCommandInDMs': saveModel.displayHelpCommandInDMs,
})
})
.then(data => data.json())
Expand All @@ -87,7 +92,12 @@ export function save(saveModel) {
monitoredChannels: saveModel.monitoredChannels,
tvShowRoles: saveModel.tvShowRoles,
movieRoles: saveModel.movieRoles,
enableDirectMessageSupport: saveModel.enableDirectMessageSupport
enableRequestsThroughDirectMessages: saveModel.enableRequestsThroughDirectMessages,
automaticallyNotifyRequesters: saveModel.automaticallyNotifyRequesters,
notificationMode: saveModel.notificationMode,
notificationChannels: saveModel.notificationChannels,
automaticallyPurgeCommandMessages: saveModel.automaticallyPurgeCommandMessages,
displayHelpCommandInDMs: saveModel.displayHelpCommandInDMs,
}));
return { ok: true };
}
Expand Down
Expand Up @@ -11,7 +11,12 @@ export default function ChatClientsReducer(state = {}, action) {
monitoredChannels: action.payload.monitoredChannels,
tvShowRoles: action.payload.tvShowRoles,
movieRoles: action.payload.movieRoles,
enableDirectMessageSupport: action.payload.enableDirectMessageSupport
enableRequestsThroughDirectMessages: action.payload.enableRequestsThroughDirectMessages,
automaticallyNotifyRequesters: action.payload.automaticallyNotifyRequesters,
notificationMode: action.payload.notificationMode,
notificationChannels: action.payload.notificationChannels,
automaticallyPurgeCommandMessages: action.payload.automaticallyPurgeCommandMessages,
displayHelpCommandInDMs: action.payload.displayHelpCommandInDMs,
}
}

Expand Down
149 changes: 133 additions & 16 deletions Requestrr.WebApi/ClientApp/src/views/ChatClients.jsx
Expand Up @@ -23,6 +23,7 @@ import { testSettings } from "../store/actions/ChatClientsActions"
import { getSettings } from "../store/actions/ChatClientsActions"
import { save } from "../store/actions/ChatClientsActions"
import MultiDropdown from "../components/Inputs/MultiDropdown"
import Dropdown from "../components/Inputs/Dropdown"

// reactstrap components
import {
Expand Down Expand Up @@ -58,7 +59,7 @@ class ChatClients extends React.Component {
commandPrefix: "",
monitoredChannels: [],
statusMessage: "",
enableDirectMessageSupport: true,
enableRequestsThroughDirectMessages: true,
chatClient: "",
chatClientChanged: false,
chatClientInvalid: false,
Expand All @@ -70,6 +71,11 @@ class ChatClients extends React.Component {
botTokenInvalid: false,
tvShowRoles: [],
movieRoles: [],
automaticallyNotifyRequesters: true,
notificationMode: "PrivateMessages",
notificationChannels: [],
automaticallyPurgeCommandMessages: true,
displayHelpCommandInDMs: true,
};

this.onSaving = this.onSaving.bind(this);
Expand All @@ -94,9 +100,14 @@ class ChatClients extends React.Component {
statusMessage: this.props.settings.statusMessage,
commandPrefix: this.props.settings.commandPrefix,
monitoredChannels: this.props.settings.monitoredChannels,
enableDirectMessageSupport: this.props.settings.enableDirectMessageSupport,
enableRequestsThroughDirectMessages: this.props.settings.enableRequestsThroughDirectMessages,
tvShowRoles: this.props.settings.tvShowRoles,
movieRoles: this.props.settings.movieRoles,
automaticallyNotifyRequesters: this.props.settings.automaticallyNotifyRequesters,
notificationMode: this.props.settings.notificationMode,
notificationChannels: this.props.settings.notificationChannels,
automaticallyPurgeCommandMessages: this.props.settings.automaticallyPurgeCommandMessages,
displayHelpCommandInDMs: this.props.settings.displayHelpCommandInDMs,
});
});
}
Expand Down Expand Up @@ -160,12 +171,6 @@ class ChatClients extends React.Component {
this.setState({ commandPrefix: event.target.value });
}

onDmEnabledChanged = event => {
this.setState({
enableDirectMessageSupport: !this.state.enableDirectMessageSupport
});
}

onSaving = e => {
e.preventDefault();

Expand All @@ -188,7 +193,12 @@ class ChatClients extends React.Component {
monitoredChannels: this.state.monitoredChannels,
tvShowRoles: this.state.tvShowRoles,
movieRoles: this.state.movieRoles,
enableDirectMessageSupport: this.state.enableDirectMessageSupport,
enableRequestsThroughDirectMessages: this.state.enableRequestsThroughDirectMessages,
automaticallyNotifyRequesters: this.state.automaticallyNotifyRequesters,
notificationMode: this.state.notificationMode,
notificationChannels: this.state.notificationChannels,
automaticallyPurgeCommandMessages: this.state.automaticallyPurgeCommandMessages,
displayHelpCommandInDMs: this.state.displayHelpCommandInDMs,
})
.then(data => {
this.setState({ isSaving: false });
Expand Down Expand Up @@ -341,7 +351,7 @@ class ChatClients extends React.Component {
<hr className="my-4" />
<div>
<h6 className="heading-small text-muted mb-4">
Discord
Discord Bot Settings
</h6>
</div>
<div className="pl-lg-4">
Expand Down Expand Up @@ -463,27 +473,134 @@ class ChatClients extends React.Component {
</FormGroup>
</Col>
</Row>
</div>
<div>
<h6 className="heading-small text-muted mt-4">
Discord Notification Settings
</h6>
</div>
<div className="pl-lg-4">
<Row>
<Col lg="6">
<Dropdown
name="Notifications"
value={this.state.notificationMode}
items={[{ name: "Disabled", value: "Disabled" }, { name: "Via private messages", value: "PrivateMessages" }, { name: "Via channel(s)", value: "Channels" }]}
onChange={newNotificationMode => this.setState({ notificationMode: newNotificationMode }, this.onValueChange)} />
</Col>
<Col lg="6">
{
this.state.notificationMode === "Channels"
? <>
<FormGroup>
<MultiDropdown
name="Channel(s) to send notifications to"
create={true}
searchable={true}
placeholder="Enter channels here"
labelField="name"
valueField="id"
dropdownHandle={false}
selectedItems={this.state.notificationChannels.map(x => { return { name: x, id: x } })}
items={this.state.notificationChannels.map(x => { return { name: x, id: x } })}
onChange={newNotificationChannels => this.setState({ notificationChannels: newNotificationChannels.filter(x => /\S/.test(x.id)).map(x => x.id.trim().replace(/#/g, '').replace(/\s+/g, '-')) })} />
</FormGroup>
</>
: null
}
</Col>
</Row>
{
this.state.notificationMode !== "Disabled"
? <>
<Row>
<Col md="12">
<FormGroup className="custom-control custom-control-alternative custom-checkbox mb-3">
<Input
className="custom-control-input"
id="automaticRequests"
type="checkbox"
onChange={e => { this.setState({ automaticallyNotifyRequesters: !this.state.automaticallyNotifyRequesters }); }}
checked={this.state.automaticallyNotifyRequesters}
/>
<label
className="custom-control-label"
htmlFor="automaticRequests"
>
<span className="text-muted">Automatically notify users of downloaded content when they make requests</span>
</label>
</FormGroup>
</Col>
</Row>
</>
: null
}
</div>
<div>
<h6 className="heading-small text-muted mt-4">
Discord Miscellaneous Settings
</h6>
</div>
<div className="pl-lg-4">
<Row>
<Col md="12">
<FormGroup className="custom-control custom-control-alternative custom-checkbox mb-3">
<Input
className="custom-control-input"
id="enableDM"
id="enableRequestDM"
type="checkbox"
onChange={this.onDmEnabledChanged}
checked={this.state.enableDirectMessageSupport}
onChange={e => { this.setState({ enableRequestsThroughDirectMessages: !this.state.enableRequestsThroughDirectMessages }); }}
checked={this.state.enableRequestsThroughDirectMessages}
/>
<label
className="custom-control-label"
htmlFor="enableDM"
htmlFor="enableRequestDM"
>
<span className="text-muted">Enable anyone to request via direct messaging. <strong>(DMs will ignore configured roles)</strong></span>
<span className="text-muted">Enable anyone to request via a private message. <strong>(Those will ignore configured roles)</strong></span>
</label>
</FormGroup>
</Col>
<Col lg="6">
</Row>
<Row>
<Col md="12">
<FormGroup className="custom-control custom-control-alternative custom-checkbox mb-3">
<Input
className="custom-control-input"
id="deleteRequestMessages"
type="checkbox"
onChange={e => { this.setState({ automaticallyPurgeCommandMessages: !this.state.automaticallyPurgeCommandMessages }); }}
checked={this.state.automaticallyPurgeCommandMessages}
/>
<label
className="custom-control-label"
htmlFor="deleteRequestMessages"
>
<span className="text-muted">Automatically delete user/bot messages (ex: !movie the matrix)</span>
</label>
</FormGroup>
</Col>
</Row>
<Row>
<Col md="12">
<FormGroup className="custom-control custom-control-alternative custom-checkbox mb-3">
<Input
className="custom-control-input"
id="helpInDMs"
type="checkbox"
onChange={e => { this.setState({ displayHelpCommandInDMs: !this.state.displayHelpCommandInDMs }); }}
checked={this.state.displayHelpCommandInDMs}
/>
<label
className="custom-control-label"
htmlFor="helpInDMs"
>
<span className="text-muted">Send the help command response in a private message instead of the current channel</span>
</label>
</FormGroup>
</Col>
</Row>
</div>
<div className="pl-lg-4">
<div className="mt-4">
{
this.state.testSettingsRequested && !this.state.isTestingSettings ?
Expand Down
24 changes: 14 additions & 10 deletions Requestrr.WebApi/Controllers/ChatClients/ChatClientsController.cs
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Discord;
Expand All @@ -16,12 +15,6 @@ namespace Requestrr.WebApi.Controllers.ChatClients
[Route("/api/chatclients")]
public class ChatClientsController : ControllerBase
{
public class TestDiscordSettingsModel
{
[Required]
public string BotToken { get; set; }
}

private readonly ChatClientsSettings _chatClientsSettings;
private readonly BotClientSettings _botClientsSettings;

Expand All @@ -42,16 +35,21 @@ public async Task<IActionResult> GetAsync()
StatusMessage = _chatClientsSettings.Discord.StatusMessage,
BotToken = _chatClientsSettings.Discord.BotToken,
ClientId = _chatClientsSettings.Discord.ClientId,
EnableDirectMessageSupport = _chatClientsSettings.Discord.EnableDirectMessageSupport,
EnableRequestsThroughDirectMessages = _chatClientsSettings.Discord.EnableRequestsThroughDirectMessages,
CommandPrefix = _botClientsSettings.CommandPrefix,
TvShowRoles = _chatClientsSettings.Discord.TvShowRoles ?? Array.Empty<string>(),
MovieRoles = _chatClientsSettings.Discord.MovieRoles ?? Array.Empty<string>(),
MonitoredChannels = _chatClientsSettings.Discord.MonitoredChannels ?? Array.Empty<string>(),
AutomaticallyNotifyRequesters = _chatClientsSettings.Discord.AutomaticallyNotifyRequesters,
NotificationMode = _chatClientsSettings.Discord.NotificationMode,
NotificationChannels = _chatClientsSettings.Discord.NotificationChannels ?? Array.Empty<string>(),
AutomaticallyPurgeCommandMessages = _chatClientsSettings.Discord.AutomaticallyPurgeCommandMessages,
DisplayHelpCommandInDMs = _chatClientsSettings.Discord.DisplayHelpCommandInDMs,
});
}

[HttpPost("discord/test")]
public async Task<IActionResult> TestDiscordSettings([FromBody]TestDiscordSettingsModel model)
public async Task<IActionResult> TestDiscordSettings([FromBody]ChatClientTestSettingsModel model)
{
try
{
Expand Down Expand Up @@ -82,9 +80,15 @@ public async Task<IActionResult> SaveAsync([FromBody]ChatClientsSettingsModel mo
_chatClientsSettings.Discord.StatusMessage = model.StatusMessage.Trim();
_chatClientsSettings.Discord.TvShowRoles = (model.TvShowRoles ?? Array.Empty<string>()).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();
_chatClientsSettings.Discord.MovieRoles = (model.MovieRoles ?? Array.Empty<string>()).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();
_chatClientsSettings.Discord.EnableDirectMessageSupport = model.EnableDirectMessageSupport;
_chatClientsSettings.Discord.EnableRequestsThroughDirectMessages = model.EnableRequestsThroughDirectMessages;
_chatClientsSettings.Discord.MonitoredChannels = (model.MonitoredChannels ?? Array.Empty<string>()).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();

_chatClientsSettings.Discord.AutomaticallyNotifyRequesters = model.AutomaticallyNotifyRequesters;
_chatClientsSettings.Discord.NotificationMode = model.NotificationMode;
_chatClientsSettings.Discord.NotificationChannels = (model.NotificationChannels ?? Array.Empty<string>()).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();;
_chatClientsSettings.Discord.AutomaticallyPurgeCommandMessages = model.AutomaticallyPurgeCommandMessages;
_chatClientsSettings.Discord.DisplayHelpCommandInDMs = model.DisplayHelpCommandInDMs;

_botClientsSettings.Client = model.Client;
_botClientsSettings.CommandPrefix = model.CommandPrefix.Trim();

Expand Down

0 comments on commit 1ac8fb4

Please sign in to comment.