feat(irc): improve reconnect and add notifications (#315)

* refactor(irc): nickserv and methods

* feat(notifications): add new events and refactor send

* feat(irc): handle disconnect reconnect and connect

* feat(irc): update config for ergo local irc server

* feat(irc): retry initial connect

* feat(irc): show nickserv errors
This commit is contained in:
Ludvig Lundgren 2022-06-29 16:50:38 +02:00 committed by GitHub
parent 41eef4e8be
commit f63ace662a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1343 additions and 133 deletions

View file

@ -315,5 +315,15 @@ export const EventOptions: SelectOption[] = [
label: "Push Error",
value: "PUSH_ERROR",
description: "On push error for the arrs or download client"
},
{
label: "IRC Disconnected",
value: "IRC_DISCONNECTED",
description: "Unexpectedly disconnected from irc network"
},
{
label: "IRC Reconnected",
value: "IRC_RECONNECTED",
description: "Reconnected to irc network after error"
}
];

View file

@ -11,6 +11,7 @@ import {
import { useToggle } from "../../hooks/hooks";
import { APIClient } from "../../api/APIClient";
import { EmptySimple } from "../../components/emptystates";
import {ExclamationCircleIcon} from "@heroicons/react/outline";
export const IrcSettings = () => {
const [addNetworkIsOpen, toggleAddNetwork] = useToggle(false);
@ -88,12 +89,12 @@ const ListItem = ({ idx, network }: ListItemProps) => {
<span className="relative inline-flex items-center">
{
network.enabled ? (
network.connected ? (
networkHealthy(network) ? (
<span className="mr-3 flex h-3 w-3 relative" title={`Connected since: ${simplifyDate(network.connected_since)}`}>
<span className="animate-ping inline-flex h-full w-full rounded-full bg-green-400 opacity-75"/>
<span className="inline-flex absolute rounded-full h-3 w-3 bg-green-500"/>
</span>
) : <span className="mr-3 flex h-3 w-3 rounded-full opacity-75 bg-red-400" />
) : <span className="mr-3 flex items-center" title={network.connection_errors.toString()}><ExclamationCircleIcon className="h-4 w-4 text-red-400 hover:text-red-600" /></span>
) : <span className="mr-3 flex h-3 w-3 rounded-full opacity-75 bg-gray-500" />
}
{network.name}
@ -155,3 +156,11 @@ const ListItem = ({ idx, network }: ListItemProps) => {
</li>
);
};
function networkHealthy(network: IrcNetworkWithHealth): boolean {
if (network.connection_errors.length > 0) {
return false
}
return true
}

View file

@ -53,6 +53,7 @@ interface IrcNetworkWithHealth {
channels: IrcChannelWithHealth[];
connected: boolean;
connected_since: string;
connection_errors: string[];
}
interface NickServ {

View file

@ -1,11 +1,12 @@
type NotificationType = "DISCORD" | "TELEGRAM";
type NotificationEvent = "PUSH_APPROVED" | "PUSH_REJECTED" | "PUSH_ERROR" | "IRC_DISCONNECTED" | "IRC_RECONNECTED";
interface Notification {
id: number;
name: string;
enabled: boolean;
type: NotificationType;
events: string[];
events: NotificationEvent[];
webhook?: string;
token?: string;
channel?: string;